/* AI Agent workspace split layout — integrated with main chat surface */

.chat-workspace-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.chat-pane {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    position: relative;
}

/* Side-by-side Canvas split */
.chat-workspace-layout.agent-split {
    display: grid !important;
    grid-template-columns: minmax(280px, var(--agent-chat-width, 50%)) 4px minmax(280px, 1fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
}

.main-content.agent-mode.agent-workspace-collapsed .chat-workspace-layout,
.chat-workspace-layout.agent-split.agent-workspace-collapsed {
    display: flex;
    flex-direction: column;
    grid-template-columns: unset;
}

.chat-workspace-layout.agent-split .chat-pane {
    flex: unset;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* Expanded: workspace fills the chat area */
.chat-workspace-layout.agent-split.agent-workspace-expanded {
    grid-template-columns: 1fr;
}

.chat-workspace-layout.agent-split.agent-workspace-expanded .chat-pane,
.chat-workspace-layout.agent-split.agent-workspace-expanded .agent-workspace-divider {
    display: none !important;
}

.agent-workspace-divider {
    display: none;
    width: 4px;
    min-width: 4px;
    cursor: col-resize;
    background: transparent;
    transition: background 0.15s ease;
    align-self: stretch;
    position: relative;
}

.agent-workspace-divider::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    transform: translateX(-50%);
    background: var(--border-color, #e5e7eb);
}

.chat-workspace-layout.agent-split .agent-workspace-divider {
    display: block !important;
}

.agent-workspace-divider:hover,
body.resizing-agent-workspace .agent-workspace-divider {
    background: rgba(148, 163, 184, 0.12);
}

.agent-workspace-divider:hover::after,
body.resizing-agent-workspace .agent-workspace-divider::after {
    background: #94a3b8;
}

.agent-workspace-pane {
    display: none;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg-main, #fff);
    border-left: none;
}

.chat-workspace-layout.agent-split .agent-workspace-pane {
    display: flex !important;
}

.agent-workspace-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: transparent;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.agent-workspace-toolbar::-webkit-scrollbar {
    display: none;
}

.agent-workspace-btn[hidden] {
    display: none !important;
}

.agent-document-tabs {
    display: flex;
    gap: 8px;
    overflow: hidden;
    flex: 1;
    min-width: 0;
    align-items: center;
}

.agent-document-tab-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
}

.agent-document-tab-wrap:only-child {
    flex: 1;
}

.agent-document-title {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary, #64748b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.agent-document-title.is-editable {
    cursor: text;
    border-radius: 4px;
    padding: 2px 4px;
    margin: -2px -4px;
}

.agent-document-title.is-editable:hover,
.agent-document-title.is-editable:focus-visible {
    color: var(--text-primary, #0f172a);
    background: rgba(15, 23, 42, 0.04);
    outline: none;
}

.agent-document-title-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    font-size: 13px;
    font-weight: 400;
    font-family: inherit;
    color: var(--text-primary, #0f172a);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color, #cbd5e1);
    border-radius: 0;
    padding: 2px 0;
    outline: none;
}

.agent-document-tab-rev {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-secondary, #64748b);
    background: var(--bg-hover, #f1f5f9);
    border-radius: 999px;
    padding: 1px 7px;
}

.agent-document-tab {
    border: none;
    background: transparent;
    color: var(--text-secondary, #64748b);
    border-radius: 0;
    padding: 0;
    font-size: 13px;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    cursor: pointer;
}

.agent-document-tab:hover:not(.active) {
    color: var(--text-primary, #0f172a);
}

.agent-document-tab.active {
    background: transparent;
    border: none;
    color: var(--text-secondary, #64748b);
    font-weight: 400;
}

.agent-document-tab-status {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-secondary, #64748b);
}

.agent-document-tab-status.unsaved,
.agent-document-tab-status.conflict {
    color: #b91c1c;
}

.agent-document-tab-status.saved {
    color: #15803d;
}

.agent-workspace-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary, #64748b);
    border-radius: 6px;
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.agent-workspace-btn:hover {
    background: var(--bg-hover, #f1f5f9);
    color: var(--text-primary, #0f172a);
}

.agent-workspace-btn-danger:hover:not(:disabled) {
    background: #fef2f2;
    color: #dc2626;
}

.agent-workspace-btn:disabled,
.agent-document-editor:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.agent-download-dropdown-container,
.agent-more-dropdown-container {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.agent-history-dropdown-container {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.agent-history-dropdown,
.agent-download-dropdown,
.agent-more-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background-color: var(--bg-panel, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    min-width: 150px;
    z-index: 1000;
    overflow: hidden;
    padding: 4px;
}

.agent-more-dropdown {
    min-width: 170px;
}

.agent-history-dropdown {
    min-width: 240px;
    max-height: 280px;
    overflow-y: auto;
}

.agent-history-dropdown.is-fixed,
.agent-download-dropdown.is-fixed,
.agent-more-dropdown.is-fixed {
    position: fixed;
    z-index: 10050;
}

.agent-history-dropdown.is-fixed {
    max-height: min(280px, 50vh);
}

.agent-history-dropdown-empty {
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text-secondary, #64748b);
}

.agent-history-dropdown-row {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 100%;
}

.agent-history-dropdown-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-primary, #0f172a);
    text-align: left;
    transition: background-color 0.15s;
}

.agent-history-dropdown-item:hover {
    background-color: var(--bg-hover, #f1f5f9);
}

.agent-history-dropdown-item.is-current {
    background-color: #f8fafc;
}

.agent-history-dropdown-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
}

.agent-history-dropdown-delete:hover {
    background: #fef2f2;
    color: #dc2626;
}

.agent-history-dropdown-item-top {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.agent-history-dropdown-rev {
    font-weight: 700;
    flex-shrink: 0;
}

.agent-history-dropdown-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary, #64748b);
}

.agent-history-dropdown-meta {
    font-size: 11px;
    color: var(--text-secondary, #94a3b8);
}

.agent-version-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-hover, #eff6ff);
    color: var(--text-primary, #1e3a5f);
    font-size: 12px;
}

.agent-version-preview-bar.is-historical-only {
    background: #f8fafc;
    color: #475569;
}

.agent-version-preview-bar[hidden] {
    display: none;
}

.agent-version-preview-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.agent-version-preview-restore,
.agent-version-preview-back {
    border: 1px solid #93c5fd;
    border-radius: 6px;
    padding: 5px 9px;
    font: inherit;
    cursor: pointer;
}

.agent-version-preview-restore {
    border-color: #3b82f6;
    background: #2563eb;
    color: #fff;
}

.agent-version-preview-restore:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.agent-version-preview-back {
    background: var(--bg-panel, #fff);
    color: var(--text-primary, #0f172a);
}

.agent-edit-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    background: #fff7ed;
    color: #9a3412;
    font-size: 12px;
}

.agent-edit-actions-bar[hidden] {
    display: none;
}

.agent-edit-actions-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.agent-edit-actions-save,
.agent-edit-actions-discard {
    border-radius: 6px;
    padding: 5px 9px;
    font: inherit;
    cursor: pointer;
}

.agent-edit-actions-save {
    border: 1px solid #ea580c;
    background: #ea580c;
    color: #fff;
}

.agent-edit-actions-save:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.agent-edit-actions-discard {
    border: 1px solid #fdba74;
    background: var(--bg-panel, #fff);
    color: var(--text-primary, #0f172a);
}

.message-wrapper.workspace-activity {
    display: flex;
    justify-content: center;
    margin: 8px 0;
}

.agent-workspace-activity {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: min(680px, 90%);
    padding: 7px 11px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 999px;
    background: var(--bg-panel, #fff);
    color: var(--text-secondary, #64748b);
    font-size: 12px;
    line-height: 1.35;
}

.agent-workspace-activity svg {
    flex: 0 0 auto;
}

.agent-download-dropdown-item,
.agent-more-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-primary, #0f172a);
    text-align: left;
    transition: background-color 0.15s;
    white-space: nowrap;
}

.agent-download-dropdown-item:hover,
.agent-more-dropdown-item:hover:not(:disabled) {
    background-color: var(--bg-hover, #f1f5f9);
}

.agent-download-dropdown-item svg,
.agent-more-dropdown-item svg {
    flex-shrink: 0;
    color: var(--text-secondary, #64748b);
}

.agent-more-dropdown-item:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.agent-more-dropdown-item-danger:hover:not(:disabled) {
    background-color: #fef2f2;
    color: #dc2626;
}

.agent-more-dropdown-item-danger:hover:not(:disabled) svg {
    color: #dc2626;
}

.agent-view-toggle {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: auto;
    padding: 2px;
    border-radius: 8px;
    background: #e8eaed;
    gap: 0;
}

.agent-view-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #5f6368;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.agent-view-toggle-btn:hover {
    color: #202124;
}

.agent-view-toggle-btn.active {
    background: #fff;
    color: #202124;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.2), 0 1px 3px rgba(60, 64, 67, 0.1);
}

.agent-view-toggle-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.agent-workspace-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: transparent;
}

.agent-document-editor,
.agent-document-preview {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 20px 24px;
}

.agent-document-editor {
    width: 100%;
    border: none;
    resize: none;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    background: transparent;
    color: var(--text-primary, #0f172a);
}

.agent-document-preview {
    background: transparent;
    outline: none;
    cursor: default;
}

.agent-document-preview.is-editable,
.agent-document-preview[contenteditable="true"] {
    cursor: text;
}

.agent-document-preview.is-editable:focus,
.agent-document-preview[contenteditable="true"]:focus {
    box-shadow: inset 0 0 0 1px var(--border-color, #e5e7eb);
}

.agent-document-preview [contenteditable="false"] {
    cursor: default;
    user-select: text;
}

.agent-md-lock {
    outline: none;
}

.agent-document-empty {
    margin: 0;
    color: var(--text-secondary, #94a3b8);
    font-size: 13px;
}

.agent-tool-status {
    margin: 0 0 8px;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--bg-hover, #f1f5f9);
    color: var(--text-primary, #334155);
    font-size: 12px;
}

.agent-tool-status.done {
    background: #ecfdf5;
    color: #166534;
}

.agent-tool-status.error {
    background: #fef2f2;
    color: #b91c1c;
}

/* Cursor-style tool timeline (outside chat bubble) */
.message-wrapper.agent-tool-call-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 2px 16px 2px 16px;
    margin: 0;
    animation: none;
}

.agent-tool-call {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    margin-left: 36px;
    font-size: 12px;
    line-height: 1.4;
    color: #94a3b8;
    user-select: none;
}

.agent-tool-call-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1.5px solid #cbd5e1;
    box-sizing: border-box;
}

.agent-tool-call-row.is-running .agent-tool-call-icon {
    border-color: #94a3b8;
    border-top-color: transparent;
    animation: agent-tool-spin 0.7s linear infinite;
}

.agent-tool-call-row.is-done .agent-tool-call-icon {
    border: none;
    width: 10px;
    height: 6px;
    border-radius: 0;
    border-left: 1.5px solid #94a3b8;
    border-bottom: 1.5px solid #94a3b8;
    transform: rotate(-45deg);
    margin: 0 1px 2px;
    animation: none;
}

.agent-tool-call-row.is-error .agent-tool-call-icon {
    border: none;
    width: 10px;
    height: 10px;
    border-radius: 0;
    background:
        linear-gradient(#f87171, #f87171) center / 10px 1.5px no-repeat,
        linear-gradient(#f87171, #f87171) center / 1.5px 10px no-repeat;
    transform: rotate(45deg);
    margin: 0 1px;
}

.agent-tool-call-row.is-error .agent-tool-call-label {
    color: #f87171;
}

.agent-tool-call-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Thinking as collapsible timeline action (agent mode) */
.message-wrapper.agent-thinking-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 2px 16px 2px 16px;
    margin: 0;
    animation: none;
}

.agent-thinking-row .agent-thinking-toggle {
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 0;
    font-family: inherit;
    text-align: left;
}

.agent-thinking-row .agent-thinking-toggle:hover .agent-tool-call-label {
    color: #64748b;
}

.agent-thinking-row.is-running .agent-tool-call-icon {
    border-color: #94a3b8;
    border-top-color: transparent;
    animation: agent-tool-spin 0.7s linear infinite;
}

.agent-thinking-row.is-done .agent-tool-call-icon {
    border: none;
    width: 10px;
    height: 6px;
    border-radius: 0;
    border-left: 1.5px solid #94a3b8;
    border-bottom: 1.5px solid #94a3b8;
    transform: rotate(-45deg);
    margin: 0 1px 2px;
    animation: none;
}

.agent-thinking-panel {
    width: calc(100% - 36px);
    max-width: 100%;
    margin: 4px 0 8px 36px;
    max-height: 500px;
    overflow-y: auto;
    opacity: 1;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.2s ease;
}

.agent-thinking-panel.collapsed {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
    margin-bottom: 0;
}

.agent-todo-dock {
    flex-shrink: 0;
    width: 100%;
    margin: 0;
    padding: 0 16px 8px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
}

.agent-todo-dock[hidden] {
    display: none !important;
}

.agent-todo-panel {
    display: block;
    width: min(100%, 420px);
    max-width: 420px;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.agent-todo-panel.is-pinned {
    align-self: center;
}

.agent-todo-card {
    width: 100%;
    max-width: 420px;
    margin: 0;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    background: var(--bg-panel, #ffffff);
    box-shadow: none;
    overflow: hidden;
    box-sizing: border-box;
}

.agent-todo-panel .agent-todo-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.4;
    color: #64748b;
    text-align: left;
    user-select: none;
}

.agent-todo-panel .agent-todo-toggle:hover {
    color: #475569;
}

.agent-todo-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-todo-chevron {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    position: relative;
    box-sizing: border-box;
}

.agent-todo-chevron::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 2px;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.15s ease, top 0.15s ease;
}

.agent-todo-panel.is-collapsed .agent-todo-chevron::after {
    transform: rotate(-135deg);
    top: 4px;
}

.agent-todo-body {
    opacity: 1;
    transition: max-height 0.25s ease, opacity 0.25s ease;
    max-height: 320px;
    overflow-y: auto;
}

.agent-todo-body.collapsed {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

.agent-todo-list {
    list-style: none;
    margin: 0;
    padding: 0 12px 10px;
    border: none;
    background: transparent;
}

.agent-todo-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    line-height: 1.45;
    color: #475569;
}

.agent-todo-item-status {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    margin-top: 2px;
    border-radius: 50%;
    box-sizing: border-box;
    box-shadow: inset 0 0 0 1.5px #94a3b8;
    background: transparent;
    position: relative;
}

.agent-todo-item.is-in-progress .agent-todo-item-status {
    box-shadow: inset 0 0 0 1.5px #64748b;
    background: radial-gradient(circle at center, #94a3b8 35%, transparent 38%);
}

.agent-todo-item.is-completed .agent-todo-item-status {
    box-shadow: inset 0 0 0 1.5px #16a34a;
    background: transparent;
}

.agent-todo-item.is-completed .agent-todo-item-status::after {
    content: '';
    position: absolute;
    left: 4.5px;
    top: 2.5px;
    width: 3px;
    height: 5.5px;
    border-right: 1.5px solid #16a34a;
    border-bottom: 1.5px solid #16a34a;
    transform: rotate(40deg);
}

.agent-todo-item.is-completed .agent-todo-item-text {
    color: #94a3b8;
    text-decoration: line-through;
}

.agent-todo-item.is-cancelled .agent-todo-item-status {
    box-shadow: inset 0 0 0 1.5px #94a3b8;
    background: transparent;
}

.agent-todo-item.is-cancelled .agent-todo-item-status::before,
.agent-todo-item.is-cancelled .agent-todo-item-status::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 3px;
    width: 1.5px;
    height: 8px;
    background: #94a3b8;
}

.agent-todo-item.is-cancelled .agent-todo-item-status::before {
    transform: rotate(45deg);
}

.agent-todo-item.is-cancelled .agent-todo-item-status::after {
    transform: rotate(-45deg);
}

.agent-todo-item.is-cancelled .agent-todo-item-text {
    color: #94a3b8;
    text-decoration: line-through;
}

.agent-todo-empty {
    padding: 4px 0;
    font-size: 13px;
    color: #94a3b8;
}

.agent-thinking-panel .message.thinking {
    margin: 0;
    max-width: 100%;
}

.agent-thinking-panel .message.thinking .message-content {
    margin: 0;
    padding: 10px 12px;
    cursor: default;
    user-select: text;
}

.agent-thinking-panel .message.thinking .message-avatar,
.agent-thinking-panel .thinking-header,
.agent-thinking-panel .message-time {
    display: none;
}

.agent-thinking-panel .thinking-content {
    max-height: none;
    overflow: visible;
}

.agent-thinking-panel .message.thinking .message-text {
    color: #64748b;
    font-size: 13px;
    font-style: italic;
}

/* Expandable edit-diff cards — desktop: align with "Edited Document" label */
.agent-tool-diff {
    width: calc(100% - 36px);
    max-width: 100%;
    margin: 4px 0 10px 36px;
    padding: 0;
    color: #64748b;
    font-size: 11px;
    line-height: 1.45;
    user-select: text;
}

.agent-tool-diff-card {
    width: 100%;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    overflow: hidden;
}

.agent-tool-diff-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-bottom: 1px solid #eef2f7;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    text-align: left;
}

.agent-tool-diff-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    color: #334155;
}

.agent-tool-diff-stats {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: #94a3b8;
}

.agent-tool-diff-add {
    color: #3f6f5c;
    font-weight: 600;
}

.agent-tool-diff-del {
    color: #a56b6b;
    font-weight: 600;
}

.agent-tool-diff-more {
    color: #cbd5e1;
}

.agent-tool-diff-chevron {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
    border-right: 1.5px solid #94a3b8;
    border-bottom: 1.5px solid #94a3b8;
    transform: rotate(45deg);
    margin: -2px 2px 0;
    transition: transform 0.15s ease;
}

.agent-tool-diff-card.is-expanded .agent-tool-diff-chevron {
    transform: rotate(-135deg);
    margin: 2px 2px 0;
}

.agent-tool-diff-body {
    background: #ffffff;
}

.agent-tool-diff-card.is-collapsible:not(.is-expanded) .agent-tool-diff-line.is-collapsed-hide,
.agent-tool-diff-card.is-collapsible:not(.is-expanded) .agent-tool-diff-gap.is-collapsed-hide {
    display: none;
}

.agent-tool-diff-lines {
    margin: 0;
    padding: 4px 0;
    overflow: hidden;
}

.agent-tool-diff-line {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 1px 10px 1px 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 11px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.agent-tool-diff-mark {
    flex: 0 0 18px;
    width: 18px;
    text-align: center;
    user-select: none;
    color: #cbd5e1;
}

.agent-tool-diff-text {
    flex: 1 1 auto;
    min-width: 0;
    color: #64748b;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.agent-tool-diff-line.is-add {
    background: rgba(63, 111, 92, 0.08);
    box-shadow: inset 3px 0 0 #6f9b84;
}

.agent-tool-diff-line.is-add .agent-tool-diff-mark,
.agent-tool-diff-line.is-add .agent-tool-diff-text {
    color: #3f6f5c;
}

.agent-tool-diff-line.is-del {
    background: rgba(165, 107, 107, 0.08);
    box-shadow: inset 3px 0 0 #c48989;
}

.agent-tool-diff-line.is-del .agent-tool-diff-mark,
.agent-tool-diff-line.is-del .agent-tool-diff-text {
    color: #a56b6b;
}

.agent-tool-diff-line.is-ctx .agent-tool-diff-text {
    color: #94a3b8;
}

.agent-tool-diff-gap {
    height: 6px;
}

.agent-tool-diff-expand {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    border: none;
    border-top: 1px solid #f1f5f9;
    background: #fafbfc;
    color: #94a3b8;
    padding: 6px;
    cursor: pointer;
}

.agent-tool-diff-card.is-collapsible .agent-tool-diff-expand {
    display: flex;
}

.agent-tool-diff-expand-icon {
    width: 8px;
    height: 8px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    margin-top: -3px;
    transition: transform 0.15s ease;
}

.agent-tool-diff-card.is-expanded .agent-tool-diff-expand-icon {
    transform: rotate(-135deg);
    margin-top: 3px;
}

@keyframes agent-tool-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .message-wrapper.agent-tool-call-row {
        padding-left: 12px;
        padding-right: 12px;
    }

    .message-wrapper.agent-thinking-row {
        padding-left: 12px;
        padding-right: 12px;
    }

    .agent-tool-call {
        margin-left: 0;
    }

    /* Mobile: full-width left-aligned diffs for readability */
    .agent-tool-diff {
        margin-left: 0;
        width: 100%;
    }

    .agent-thinking-panel {
        margin-left: 0;
        width: 100%;
    }

    .agent-todo-dock {
        padding-left: 12px;
        padding-right: 12px;
    }

    .agent-todo-panel {
        padding: 0;
        width: min(100%, 420px);
        max-width: 420px;
    }

    .agent-todo-card {
        margin: 0;
        width: 100%;
        max-width: 420px;
    }
}

/* Ask Question card */
.message-wrapper.agent-ask-question {
    align-self: flex-start;
    margin: 4px 0 10px;
}

.agent-ask-card {
    width: min(100%, 420px);
    min-width: 0;
    border: none;
    border-radius: 18px;
    background: var(--bg-panel);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    padding: 12px 14px 14px;
}

.agent-ask-card-header {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 6px;
}

.agent-ask-card--multi {
    width: min(100%, 460px);
}

.agent-ask-block {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.agent-ask-card--multi .agent-ask-block:last-of-type {
    border-bottom: none;
    margin-bottom: 4px;
    padding-bottom: 0;
}

.agent-ask-block-header {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 6px;
}

.agent-ask-skip-one-btn {
    margin-top: 8px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
}

.agent-ask-skip-one-btn:hover {
    color: #64748b;
    text-decoration: underline;
}

.agent-ask-option.is-skipped {
    opacity: 0.45;
}

.agent-ask-question-text {
    font-size: 14.5px;
    font-weight: 500;
    color: var(--text-primary, #0f172a);
    line-height: 1.45;
    margin-bottom: 12px;
}

.agent-ask-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.agent-ask-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    text-align: left;
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 2px 0;
    cursor: pointer;
    color: var(--text-primary, #0f172a);
    font: inherit;
}

.agent-ask-option:hover .agent-ask-option-id {
    border-color: #94a3b8;
    color: #334155;
}

.agent-ask-option-id {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: transparent;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.agent-ask-option.is-selected .agent-ask-option-id {
    border-color: var(--blue-accent);
    background: color-mix(in srgb, var(--blue-accent) 10%, transparent);
    color: var(--blue-accent);
}

.agent-ask-option-label {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    line-height: 1.4;
    padding-top: 1px;
}

.agent-ask-option-label--empty {
    min-height: 1.2em;
}

.agent-ask-option-other.is-editing {
    cursor: text;
}

.agent-ask-card-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding-top: 4px;
}

.agent-ask-skip-btn {
    border: none;
    background: none;
    color: var(--text-secondary);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: color 0.15s ease, background 0.15s ease;
}

.agent-ask-skip-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.agent-ask-continue-btn {
    border: none;
    border-radius: 8px;
    background: var(--blue-accent);
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.agent-ask-continue-btn:hover:not(:disabled) {
    background: var(--gemini-blue);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(3, 105, 161, 0.3);
}

.agent-ask-continue-btn:active:not(:disabled) {
    transform: translateY(0);
}

.agent-ask-continue-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.agent-ask-inline-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    border: none;
    outline: none;
    background: transparent;
    padding: 0;
    margin: 0;
    font: inherit;
    font-size: 13.5px;
    line-height: 1.4;
    color: var(--text-primary, #0f172a);
}

.agent-ask-inline-input::placeholder {
    color: #94a3b8;
}

.agent-ask-answer-summary {
    font-size: 13.5px;
    color: var(--text-secondary, #64748b);
    line-height: 1.45;
    padding: 4px 2px;
}

.agent-ask-question.is-cancelled .agent-ask-answer-summary {
    font-style: italic;
}

.setting-group-title {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 16px;
}

/* Document Workspace modal — document cards */
#agentDocumentWorkspaceModal {
    /* Below alert/confirm/prompt overlays (10001) so rename/delete dialogs stay on top */
    z-index: 10000;
}

.agent-doc-workspace-dialog {
    max-width: 520px;
    text-align: left;
    position: relative;
}

.agent-doc-workspace-dialog .custom-dialog-title,
.agent-doc-workspace-dialog .custom-dialog-message {
    text-align: center;
}

.agent-doc-workspace-dialog .custom-dialog-icon {
    margin-left: auto;
    margin-right: auto;
}

.agent-document-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0 20px;
    max-height: min(50vh, 360px);
    overflow-y: auto;
    background: transparent;
}

.agent-doc-workspace-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.agent-doc-workspace-section + .agent-doc-workspace-section {
    margin-top: 12px;
}

.agent-doc-workspace-section-title {
    margin: 0;
    padding: 0 2px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary, #64748b);
}

.agent-doc-workspace-section-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.agent-doc-workspace-empty {
    margin: 8px 0 4px;
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary, #64748b);
}

.agent-doc-workspace-actions {
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.agent-doc-card {
    width: 100%;
    text-align: left;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    background: var(--bg-panel, #fff);
    padding: 10px 12px;
    cursor: pointer;
    color: var(--text-primary, #0f172a);
    box-shadow: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.agent-doc-card:hover {
    border-color: #cbd5e1;
    background: var(--bg-hover, #f8fafc);
}

.agent-doc-card.is-open {
    border-color: #94a3b8;
}

.agent-doc-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.agent-doc-card-icon {
    color: var(--text-secondary, #64748b);
    display: inline-flex;
    flex-shrink: 0;
}

.agent-doc-card-title {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-doc-card-rev {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-secondary, #64748b);
    background: var(--bg-hover, #f1f5f9);
    border-radius: 999px;
    padding: 1px 7px;
}

.agent-doc-card-rename,
.agent-doc-card-delete {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
}

.agent-doc-card-rename:hover {
    color: var(--text-primary, #0f172a);
    background: var(--bg-hover, #f1f5f9);
}

.agent-doc-card-delete:hover {
    color: #b91c1c;
    background: #fef2f2;
}

.agent-doc-card-expand {
    flex-shrink: 0;
    color: var(--text-secondary, #64748b);
    display: inline-flex;
}

.agent-doc-card-open-label {
    margin-top: 8px;
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: #0f172a;
    border-radius: 999px;
    padding: 2px 8px;
}

/* Document cards embedded inside the assistant chat bubble */
.agent-inline-doc-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: calc(10px + 0.5lh) 0 calc(4px + 0.5lh) 0.5lh;
    padding: 0;
    max-width: 100%;
}

/* Created before assistant text — sit above the message with a blank line after */
.agent-inline-doc-cards.before {
    margin: 0.5lh 0 calc(1.25em + 0.5lh) 0.5lh;
}

.agent-inline-doc-cards.after {
    margin: calc(10px + 0.5lh) 0 calc(4px + 0.5lh) 0.5lh;
}

.agent-doc-card--inline {
    max-width: 70%;
    background: #ffffff;
    padding: 0;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
}

.agent-doc-card--inline:hover {
    background: #ffffff;
    border-color: #cbd5e1;
}

.agent-doc-card--inline .agent-doc-card-header {
    position: relative;
    z-index: 2;
    padding: 10px 12px;
    margin: 0;
    border-bottom: 1px solid #e2e8f0;
    background: #f5f7fa;
    border-radius: 11px 11px 0 0;
}

.agent-doc-card--inline .agent-doc-card-rev {
    background: rgba(255, 255, 255, 0.75);
}

.agent-doc-card--inline .agent-doc-card-body {
    position: relative;
    margin-top: 0;
    padding: 10px 12px 12px;
    min-height: 4.5em;
    background: #ffffff;
}

.agent-doc-card--inline .agent-doc-card-preview {
    max-height: calc(1.55em * 10);
    overflow: hidden;
    position: relative;
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--text-primary, #1e293b);
    text-align: left;
    white-space: normal;
}

.agent-doc-card--inline .agent-doc-card-preview::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2.2em;
    background: linear-gradient(to bottom, transparent, #ffffff);
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.agent-doc-card--inline .agent-doc-card-hover {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background: rgba(248, 250, 252, 0.72);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    z-index: 1;
}

.agent-doc-card--inline:hover .agent-doc-card-hover,
.agent-doc-card--inline:focus-visible .agent-doc-card-hover {
    opacity: 1;
}

.agent-doc-card--inline:hover .agent-doc-card-preview::after,
.agent-doc-card--inline:focus-visible .agent-doc-card-preview::after {
    opacity: 0;
}

.agent-doc-card-hover-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 8px 16px;
    border-radius: 999px;
    background: #0f172a;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.22);
    transform: translateY(4px);
    transition: transform 0.18s ease;
}

.agent-doc-card--inline:hover .agent-doc-card-hover-btn,
.agent-doc-card--inline:focus-visible .agent-doc-card-hover-btn {
    transform: translateY(0);
}

.agent-doc-card-hover-label {
    flex-shrink: 0;
}

.agent-doc-card-hover-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    opacity: 0.92;
}

.agent-doc-card--inline .agent-doc-card-preview h1,
.agent-doc-card--inline .agent-doc-card-preview h2,
.agent-doc-card--inline .agent-doc-card-preview h3 {
    margin-top: 0.6em;
    margin-bottom: 0.4em;
    font-size: 1.15em;
}

.agent-doc-card--inline .agent-doc-card-preview h1:first-child,
.agent-doc-card--inline .agent-doc-card-preview h2:first-child,
.agent-doc-card--inline .agent-doc-card-preview h3:first-child {
    margin-top: 0;
}

.agent-doc-card--inline .agent-doc-card-preview p {
    margin: 0.45em 0;
}

.agent-doc-card--inline .agent-doc-card-preview .code-container,
.agent-doc-card--inline .agent-doc-card-preview pre {
    max-height: 4.5em;
    overflow: hidden;
}

.agent-doc-card-action {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
}

/* Desktop: << / >> ; mobile vertical split uses up / down */
.agent-workspace-icon-mobile {
    display: none;
}

@media (max-width: 768px) {
    .agent-workspace-icon-desktop {
        display: none;
    }

    .agent-workspace-icon-mobile {
        display: block;
    }

    /* Message jump controls overlap the bottom workspace pane on mobile */
    .main-content:has(.chat-workspace-layout.agent-split) .scroll-controls {
        display: none !important;
    }

    .chat-workspace-layout.agent-split:not(.agent-workspace-expanded) {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) 4px minmax(220px, 42vh);
    }

    .chat-workspace-layout.agent-split:not(.agent-workspace-expanded) .agent-workspace-divider {
        width: 100%;
        min-width: 0;
        height: 4px;
        cursor: row-resize;
    }

    .chat-workspace-layout.agent-split:not(.agent-workspace-expanded) .agent-workspace-divider::after {
        top: 50%;
        left: 0;
        right: 0;
        bottom: auto;
        width: 100%;
        height: 1px;
        transform: translateY(-50%);
    }

    .chat-workspace-layout.agent-split:not(.agent-workspace-expanded) .agent-workspace-pane {
        height: auto;
    }

    /* Inline doc cards: use the full chat bubble on narrow screens */
    .agent-doc-card--inline {
        max-width: 100%;
    }

    .agent-inline-doc-cards,
    .agent-inline-doc-cards.before,
    .agent-inline-doc-cards.after {
        margin-left: 0;
    }
}

/* AI Reviewers settings */
#agentAiReviewersSettings .agent-reviewer-card {
    margin-top: 12px;
}

#agentAiReviewersSettings .agent-reviewer-card .setting-group {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.toggle-switch.toggle-locked {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.toggle-switch.toggle-locked.toggle-locked-tooltip {
    pointer-events: auto;
}

.setting-item.toggle-item-locked .setting-label > span:first-child {
    opacity: 0.75;
}
