/* Adapted from ZCode Pocket's conversation layout: quiet chrome, open replies. */
.app-shell[data-space="agents"] .collection-header { max-width: 932px; width: 100%; margin-inline: auto; }
.app-shell[data-space="agents"] .collection-action { width: 48px; height: 48px; min-width: 48px; padding: 0; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--ink); background: var(--surface-raised); }
.app-shell[data-space="agents"] .collection-action span { display: none; }
.app-shell[data-space="agents"] .collection-action svg { width: 22px; height: 22px; }
.ai-conversations { max-width: 860px; margin: 0 auto; padding-top: 8px; }
.ai-conversation { display: grid; width: 100%; min-height: 64px; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; }
.ai-conversation:hover { background: var(--surface-soft); }
.ai-conversation-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.ai-conversation.has-unread .ai-conversation-dot { background: var(--ink); }
.ai-conversation .conversation-copy { display: flex; min-width: 0; align-items: baseline; gap: 10px; }
.ai-conversation .conversation-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 600; }
.ai-conversation .conversation-copy small { flex-shrink: 0; color: var(--muted); font-size: 11px; }
.ai-conversation .conversation-end { display: flex; align-items: center; align-self: center; gap: 8px; padding: 0; color: var(--muted); font-size: 11px; white-space: nowrap; }
.ai-conversation .conversation-end b { min-width: 20px; padding: 3px 5px; border-radius: 12px; background: var(--brand); color: var(--on-brand); text-align: center; }
.app-shell[data-space="agents"] .room-item { min-height: 64px; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 10px; border-radius: 8px; }
.app-shell[data-space="agents"] .room-item .conversation-avatar { width: 6px; height: 6px; border-radius: 50%; color: transparent; background: var(--faint) !important; font-size: 0; }
.app-shell[data-space="agents"] .room-item.active .conversation-avatar { background: var(--ink) !important; }
.app-shell[data-space="agents"] .room-copy small { display: none; }
.app-shell[data-space="agents"] .room-copy strong { font-size: 14px; font-weight: 600; }
.app-shell[data-space="agents"] .room-item-end { flex-direction: row; align-self: center; align-items: center; gap: 6px; padding: 0; font-size: 10px; }
.ai-chat { --ai-reading-width: 760px; }
.ai-chat .chat-header { border: 0; background: var(--surface); }
.ai-chat .channel-row { position: relative; min-height: 108px; display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px 48px; gap: 4px; align-items: start; padding: 12px 16px 16px; }
.ai-chat #backButton { grid-column: 1; display: grid; }
.ai-chat .chat-heading { position: absolute; grid-area: auto; top: 12px; left: 68px; right: 68px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 10px; text-align: center; pointer-events: none; }
.ai-chat .chat-heading strong { justify-content: center; max-width: calc(100% - 88px); font-size: 16px; font-weight: 650; letter-spacing: 0; }
.ai-chat .channel-prefix, .ai-chat #memberCount, .ai-chat .connection-separator, .ai-chat .connection-dot, .ai-chat #recordAudioButton, .ai-chat #membersButton, .ai-chat .channel-tabs { display: none; }
.ai-chat .chat-heading small { justify-content: center; white-space: normal; font-size: 11px; }
.ai-chat .chat-heading small.connected { display: none; }
.ai-chat #connectionState { display: inline; }
.ai-chat .channel-actions { display: contents; }
.ai-chat .channel-actions #aiNewChatButton { display: grid; grid-column: 3; grid-row: 1; }
.ai-chat .channel-actions #channelMenuButton { grid-column: 4; grid-row: 1; }
.ai-chat #backButton, .ai-chat #channelMenuButton, .ai-chat #aiNewChatButton { display: grid; place-items: center; width: 48px; height: 48px; min-width: 48px; padding: 0; color: var(--ink); border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface-raised); }
.ai-chat #aiNewChatButton { border-color: transparent; background: transparent; }
.ai-chat #aiNewChatButton svg { width: 21px; height: 21px; }
.ai-chat .encryption-state { justify-self: center; max-width: 100%; margin: 0 auto; padding: 6px 10px; border: 1px solid var(--line); border-radius: 18px; color: var(--muted); background: var(--surface-raised); font-size: 11px; font-weight: 500; }
.ai-chat .encryption-state span { position: static; width: auto; height: auto; clip: auto; overflow: visible; }
.ai-chat .encryption-state[data-state="error"], .ai-chat .encryption-state[data-state="missing"] { color: var(--danger); border-color: var(--danger); }
.ai-chat .timeline { padding: 0 max(24px, calc((100% - var(--ai-reading-width)) / 2)) 12px; scroll-padding-block: 12px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.ai-chat .day-separator { margin: 8px 0 24px; color: var(--faint); }
.ai-chat .day-separator::before, .ai-chat .day-separator::after { display: none; }
.ai-chat .day-separator span { padding: 0; border: 0; background: transparent; font-size: 11px; font-weight: 400; }
.ai-message { display: block; padding: 0; margin: 0 0 26px; }
.ai-message:hover { background: transparent; }
.ai-message .message-avatar, .ai-message::before, .ai-message .message-time { display: none; }
.ai-message .message-main { width: 100%; padding: 0; }
.ai-message .message-meta { min-height: 26px; align-items: center; gap: 7px; margin-bottom: 8px; }
.ai-message .message-sender { color: var(--muted); font-size: 12px; line-height: 1.4; font-weight: 600; }
.ai-message .message-sender:hover { text-decoration: none; }
.ai-reply-mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; color: var(--ink); background: var(--surface-hover); font-size: 19px; }
.ai-message .message-body { font-size: 16px; line-height: 1.7; }
.ai-message.incoming .message-body { white-space: normal; }
.ai-message .message-body p { margin: 0 0 14px; white-space: pre-wrap; }
.ai-message .message-body > :last-child { margin-bottom: 0; }
.ai-message .message-body h2, .ai-message .message-body h3, .ai-message .message-body h4 { margin: 18px 0 10px; line-height: 1.4; font-weight: 650; }
.ai-message .message-body h2 { font-size: 23px; }
.ai-message .message-body h3 { font-size: 20px; }
.ai-message .message-body h4 { font-size: 17px; }
.ai-message .message-body ul, .ai-message .message-body ol { margin: 0 0 14px; padding-left: 24px; }
.ai-message .message-body li { margin-bottom: 5px; padding-left: 3px; }
.ai-message .message-body li::marker { color: var(--muted); }
.ai-message .message-body blockquote { margin: 4px 0 14px; padding: 10px 12px; border-left: 2px solid var(--faint); border-radius: 0 8px 8px 0; color: var(--muted); background: var(--surface-soft); white-space: pre-wrap; }
.ai-code-block { min-width: 0; max-width: 100%; margin: 12px 0 16px; border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; background: var(--surface-raised); }
.ai-code-toolbar { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-left: 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.ai-code-toolbar > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-code-toolbar button { flex-shrink: 0; min-width: 56px; min-height: 44px; padding: 0 10px; color: var(--muted); background: transparent; font-size: 12px; }
.ai-code-block pre { max-width: 100%; margin: 0; padding: 14px; overflow-x: auto; white-space: pre; font-size: 13px; line-height: 1.6; }
.ai-code-block pre code { display: block; padding: 0; border: 0; background: transparent; color: var(--ink); }
.ai-message.outgoing .message-main { width: fit-content; max-width: 86%; margin-left: auto; }
.ai-message.outgoing .message-meta { display: none; }
.ai-message.outgoing .message-body { padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 16px 16px 6px 16px; background: var(--state-selected); font-size: 15px; line-height: 1.5; }
.ai-message.compact { padding: 0; margin-bottom: 14px; }
.ai-message.compact .message-meta { display: none; }
.ai-message .ai-message-actions { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.ai-message.outgoing .ai-message-actions { justify-content: flex-end; }
.ai-message-actions button { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 0 8px; border: 0; border-radius: 8px; color: var(--faint); background: transparent; font-size: 12px; }
.ai-message-actions button:hover { color: var(--ink); background: var(--surface-soft); }
.ai-message-actions svg { width: 15px; height: 15px; }
.ai-message .agent-run { margin: 12px 0 0; border-radius: 8px; background: var(--surface-soft); }
.ai-message .agent-run summary { min-height: 44px; align-items: center; font-size: 12px; }
.ai-chat .typing-state { padding: 4px max(24px, calc((100% - var(--ai-reading-width)) / 2)); }
.ai-chat .composer { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; grid-template-rows: auto; align-items: end; gap: 3px; width: min(calc(100% - 32px), 792px); margin: 8px auto 16px; padding: 5px; border: 1px solid var(--line-strong); border-radius: 28px; background: var(--surface-raised); box-shadow: none; }
.ai-chat .composer:focus-within { border-color: var(--muted); box-shadow: none; }
.ai-chat .composer textarea { grid-column: 2; grid-row: 1; min-height: 44px; max-height: 174px; width: 100%; padding: 10px 3px; border: 0; border-radius: 0; outline: 0; color: var(--ink); background: transparent; font-size: 16px; line-height: 24px; box-shadow: none; }
.ai-chat .composer textarea:focus { background: transparent; box-shadow: none; }
.ai-chat .composer-bottom, .ai-chat .composer-actions { display: contents; }
.ai-chat .composer-actions > button { display: none !important; }
.ai-chat .composer-actions #attachButton { grid-column: 1; grid-row: 1; display: grid !important; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; color: var(--muted); background: transparent; }
.ai-chat .composer-actions #attachButton svg { width: 23px; height: 23px; }
.ai-chat .composer .send-button { grid-column: 3; grid-row: 1; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; color: var(--on-brand); background: var(--brand); }
.ai-chat .send-button svg { display: none; }
.ai-chat .send-button::after { content: ''; width: 18px; height: 18px; background: currentColor; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M12 20V4m-7 7 7-7 7 7'/%3E%3C/svg%3E") center / contain no-repeat; }
.ai-chat .composer .send-button:disabled { color: var(--on-brand); background: var(--brand) !important; opacity: .28; }
.ai-chat .composer.show-format { grid-template-rows: auto auto; border-radius: 20px; }
.ai-chat .composer.show-format .composer-format { grid-column: 1 / -1; grid-row: 1; display: flex; overflow-x: auto; max-width: 100%; height: auto; min-height: 44px; padding: 0; }
.ai-chat .composer.show-format textarea, .ai-chat .composer.show-format #attachButton, .ai-chat .composer.show-format .send-button { grid-row: 2; }
.ai-chat .composer-format button { min-width: 44px; min-height: 44px; }
.ai-chat-empty { min-height: 48vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ai-empty-mark { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 16px; color: var(--muted); background: var(--surface-raised); font-size: 32px; }
.ai-chat-empty h2 { margin: 0; color: var(--ink); font-size: 20px; font-weight: 600; }
.ai-chat-empty p { margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.ai-conversation-tools { display: flex; gap: 8px; }
.ai-conversation-tools button { flex: 1; min-height: 48px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface-soft); }
.ai-composer-menu .dialog-card { max-width: 440px; }
.ai-composer-menu .dialog-title-row h2 { font-size: 18px; font-weight: 600; }
.ai-composer-menu .message-dialog-actions { grid-template-columns: 1fr; gap: 0; }
.ai-composer-menu .message-dialog-actions button { min-height: 48px; padding: 0 8px; border-radius: 8px; color: var(--ink); background: transparent; text-align: left; font-size: 15px; font-weight: 400; }
.ai-composer-menu .message-dialog-actions button:hover { background: var(--surface-soft); }
@media (max-width: 760px), (max-height: 500px) and (max-width: 960px) {
  .app-shell[data-space="agents"] .collection-header { align-items: center; padding: max(20px, env(safe-area-inset-top)) 20px 12px; }
  .app-shell[data-space="agents"] .collection-content { padding-inline: 20px; }
  .ai-chat .channel-row { padding: 8px 8px 16px; min-height: 108px; grid-template-columns: 48px minmax(0, 1fr) 44px 48px; gap: 2px; }
  .ai-chat .chat-heading { top: 8px; padding-top: 11px; }
  .ai-chat .channel-actions #aiNewChatButton { width: 44px; min-width: 44px; }
  .ai-chat .timeline { padding-inline: 16px; }
  .ai-chat .composer { width: calc(100% - 24px); margin: 8px 12px max(8px, env(safe-area-inset-bottom)); }
  .ai-chat .typing-state { padding-inline: 18px; }
  .ai-message { margin-bottom: 24px; }
  .ai-message.compact { margin-bottom: 10px; }
  .ai-message-actions button { min-height: 44px; }
  .ai-chat .attachment img { max-width: 100%; }
}
