/* ── Copy button ── */
.copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: 1px solid var(--foster-border);
    border-radius: 4px;
    background: var(--foster-surface);
    cursor: pointer;
    font-size: 0.625rem;
    transition: all 0.2s ease;
    vertical-align: middle;
    flex-shrink: 0;
}

.copy-btn:hover {
    background: var(--foster-primary-light);
    border-color: var(--foster-primary);
}

.copy-btn-copied {
    background: var(--foster-success-light);
    border-color: var(--foster-success);
    color: var(--foster-success);
}

.copy-btn-copied:hover {
    background: var(--foster-success-light);
    border-color: var(--foster-success);
}

.copyable {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

/* ── Toast notifications ── */
.toast-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    max-width: 22rem;
    pointer-events: none;
}

.toast-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--foster-radius);
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease-out both;
}

.toast-success {
    background: var(--foster-success);
    color: #fff;
}

.toast-error {
    background: var(--foster-danger);
    color: #fff;
}

.toast-info {
    background: var(--foster-surface);
    border: 1px solid var(--foster-border);
    color: var(--foster-text);
}

.toast-icon {
    flex-shrink: 0;
    font-size: 0.875rem;
}

.toast-message {
    flex: 1;
    min-width: 0;
}

.toast-dismiss {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0 0.125rem;
    flex-shrink: 0;
}

.toast-dismiss:hover {
    opacity: 1;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

@media (max-width: 767.98px) {
    .toast-container {
        left: 0.75rem;
        right: 0.75rem;
        max-width: none;
    }
}

/* ── Skeleton shimmer loading ── */
.skeleton-table {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.skeleton-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--foster-radius-sm);
    background: var(--foster-surface);
    border: 1px solid var(--foster-border);
    box-shadow: 0 4px 14px color-mix(in srgb, var(--foster-text) 4%, transparent);
}

.skeleton-cell {
    height: 0.75rem;
    border-radius: 4px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--foster-bg) 92%, var(--foster-surface)) 25%, color-mix(in srgb, var(--foster-border) 82%, var(--foster-surface)) 50%, color-mix(in srgb, var(--foster-bg) 92%, var(--foster-surface)) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-cell-wide   { flex: 3; }
.skeleton-cell-medium { flex: 1; width: 5rem; }
.skeleton-cell-narrow { flex: 0 0 4rem; }

/* ── Relative time ── */
.relative-time {
    font-variant-numeric: tabular-nums;
}

/* ── Delete confirm inline ── */
.delete-confirm {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    animation: fadeSlideIn 0.2s ease-out both;
}

/* ── Empty states ── */
.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
    border: 2px dashed var(--foster-border);
    border-radius: var(--foster-radius);
    background: linear-gradient(180deg, color-mix(in srgb, var(--foster-surface) 94%, var(--foster-bg-subtle)), var(--foster-surface));
    box-shadow: 0 10px 26px color-mix(in srgb, var(--foster-text) 5%, transparent);
}

.empty-state-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--foster-text);
    margin-bottom: 0.25rem;
}

.empty-state-hint {
    font-size: 0.8125rem;
    color: var(--foster-text-secondary);
    line-height: 1.5;
}

.empty-state kbd {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1;
    color: var(--foster-text);
    background: var(--foster-bg);
    border: 1px solid var(--foster-border);
    border-radius: 4px;
    box-shadow: 0 1px 0 var(--foster-border);
    font-family: inherit;
}

/* ── Typing indicator (bouncing dots) ── */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.625rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--foster-bg-subtle) 85%, var(--foster-surface));
    border: 1px solid var(--foster-border);
}

.typing-dot {
    display: inline-block;
    width: 0.4375rem;
    height: 0.4375rem;
    border-radius: 50%;
    background: var(--foster-text-secondary);
    animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* ── Typewriter cursor ── */
.typing-cursor {
    display: inline;
    color: var(--foster-primary);
    animation: cursorBlink 0.8s step-end infinite;
    font-weight: 300;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0; }
}

/* ── Page header with accent ── */
.page-header {
    border: 1px solid var(--foster-border);
    border-radius: var(--foster-radius);
    background: var(--foster-surface);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.page-header-accent {
    height: 3px;
}

.page-header-accent-upload  { background: linear-gradient(90deg, #0078d4, #50e6ff); }
.page-header-accent-ingest  { background: linear-gradient(90deg, #0078d4, #b4a0ff, #50e6ff); }
.page-header-accent-di      { background: linear-gradient(90deg, #7c3aed, #a78bfa, #c084fc); }
.page-header-accent-chat    { background: linear-gradient(90deg, #059669, #34d399, #6ee7b7); }
.page-header-accent-library { background: linear-gradient(90deg, #d97706, #fbbf24, #fde68a); }
.page-header-accent-about   { background: linear-gradient(90deg, #0078d4, #6366f1, #a855f7); }
.page-header-accent-search  { background: linear-gradient(90deg, #0891b2, #22d3ee, #67e8f9); }
.page-header-accent-metadata { background: linear-gradient(90deg, #dc2626, #f97316, #fbbf24); }
.page-header-accent-activity { background: linear-gradient(90deg, #6366f1, #8b5cf6, #a78bfa); }
.page-header-accent-extracted { background: linear-gradient(90deg, #0d9488, #2dd4bf, #99f6e4); }
.page-header-accent-index    { background: linear-gradient(90deg, #2563eb, #3b82f6, #93c5fd); }

.page-header-body {
    padding: 1.25rem 1.5rem 1rem;
}

.page-header h1 {
    margin-bottom: 0.25rem;
}

.page-header .page-description {
    margin-bottom: 0;
}

.page-header-actions {
    margin-top: 0.625rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.page-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.page-toolbar-meta {
    font-size: 0.8125rem;
    color: var(--foster-text-secondary);
}

.page-toolbar-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.page-toolbar-filter label {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--foster-text-secondary);
    white-space: nowrap;
}

.page-button-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.table-responsive {
    background: var(--foster-surface);
}

.pagination-shell {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.pagination-shell .pagination {
    flex-wrap: nowrap;
    width: max-content;
}

.page-chip-link {
    border: 1px solid var(--foster-border);
    border-radius: 999px;
    background: var(--foster-surface);
    color: var(--foster-text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.375rem 0.75rem;
    transition: all 0.15s ease;
}

.page-chip-link:hover {
    border-color: var(--foster-primary);
    color: var(--foster-primary);
    background: var(--foster-primary-light);
}

/* ── Drop zone ── */
.drop-zone {
    border: 2px dashed var(--foster-border);
    border-radius: var(--foster-radius);
    padding: 2rem 1.5rem;
    text-align: center;
    transition: border-color 0.2s ease, background 0.2s ease;
    cursor: pointer;
    position: relative;
    background: var(--foster-surface);
}

.drop-zone:hover {
    border-color: var(--foster-primary);
    background: var(--foster-primary-light);
}

.drop-zone-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

.drop-zone-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--foster-text);
    margin-bottom: 0.25rem;
}

.drop-zone-hint {
    font-size: 0.75rem;
    color: var(--foster-text-secondary);
}

.drop-zone ::deep input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* ── File chip ── */
.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--foster-border);
    border-radius: 20px;
    background: var(--foster-bg);
    font-size: 0.8125rem;
}

.file-chip-name {
    font-weight: 600;
    color: var(--foster-text);
}

.file-chip-size {
    color: var(--foster-text-secondary);
    font-size: 0.75rem;
}

/* ── Elapsed timer in processing card ── */
.elapsed-timer {
    font-variant-numeric: tabular-nums;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--foster-primary);
    min-width: 3rem;
}

/* ── Result card accent ── */
.result-card {
    border-left: 4px solid var(--foster-success);
}

.result-card.result-error {
    border-left-color: var(--foster-danger);
}

/* ── Timeline stepper ── */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-left: 0.25rem;
}

.timeline-step {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    position: relative;
    padding-bottom: 0.25rem;
}

.timeline-step:last-child { padding-bottom: 0; }
.timeline-step:last-child .timeline-track { display: none; }

.timeline-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    width: 2rem;
    position: relative;
    z-index: 1;
}

.timeline-dot {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    border: 2px solid var(--foster-border);
    background: var(--foster-surface);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.timeline-track {
    width: 2px;
    flex: 1;
    min-height: 1rem;
    background: var(--foster-border);
    margin: 0.125rem auto;
    transition: background 0.4s ease;
    border-radius: 1px;
}

.timeline-step.completed .timeline-dot {
    border-color: var(--foster-success);
    background: var(--foster-success-light);
}

.timeline-step.completed .timeline-track {
    background: var(--foster-success);
}

.timeline-step.active .timeline-dot {
    border-color: var(--foster-primary);
    background: var(--foster-primary-light);
    box-shadow: 0 0 0 4px rgba(0, 120, 212, 0.12);
    animation: timelinePulse 1.5s ease-in-out infinite;
}

.timeline-step.active .timeline-track {
    background: linear-gradient(to bottom, var(--foster-primary) 0%, var(--foster-border) 100%);
}

.timeline-step.pending .timeline-dot {
    opacity: 0.4;
}

.timeline-step.pending .timeline-track {
    opacity: 0.4;
}

@keyframes timelinePulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(0, 120, 212, 0.12); }
    50%      { box-shadow: 0 0 0 8px rgba(0, 120, 212, 0.06); }
}

.timeline-body {
    padding: 0.25rem 0 0.75rem;
    min-width: 0;
}

.timeline-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--foster-text);
    line-height: 1.75rem;
    transition: color 0.3s ease;
}

.timeline-step.active .timeline-title {
    color: var(--foster-primary);
}

.timeline-step.completed .timeline-title {
    color: var(--foster-success);
}

.timeline-step.pending .timeline-title {
    color: var(--foster-text-secondary);
    opacity: 0.6;
}

/* ── Chat page (ChatGPT-style layout) ── */
.chat-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 3rem - 1.5rem); /* top bar + .content padding-top */
    margin: -1.5rem -1.5rem 0;           /* bleed into .content.px-4 padding */
    overflow: hidden;
}

.chat-page-toolbar {
    max-width: 48rem;
    width: 100%;
    margin: 1rem auto 0;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.chat-page-toolbar-title,
.chat-page-toolbar-actions {
    min-width: 0;
}

.chat-page-toolbar-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--foster-text-secondary);
}

.chat-page-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chat-page-toolbar-actions > * {
    flex-shrink: 0;
}

.chat-toolbar-link {
    border: 1px solid var(--foster-border);
    border-radius: 999px;
    background: var(--foster-surface);
    color: var(--foster-text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.375rem 0.75rem;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--foster-text) 6%, transparent);
    transition: all 0.15s ease;
}

.chat-toolbar-link:hover {
    border-color: var(--foster-primary);
    color: var(--foster-primary);
    background: var(--foster-primary-light);
    transform: translateY(-1px);
}

.chat-toolbar-link:focus-visible,
.chat-starter-btn:focus-visible,
.search-sources-toggle:focus-visible,
.chat-export-btn:focus-visible,
.chat-new-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--foster-primary) 18%, transparent);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.chat-messages-inner {
    max-width: 48rem;
    margin: 0 auto;
    padding: 2rem 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

/* ── Empty splash ── */
.chat-empty {
    margin: auto;
    text-align: center;
    padding: 3rem 1rem;
    max-width: 42rem;
}

.chat-empty-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.chat-empty-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--foster-text);
    margin-bottom: 0.375rem;
}

.chat-empty-hint {
    color: var(--foster-text-secondary);
    font-size: 0.9375rem;
}

.chat-starters {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chat-starter-btn {
    border: 1px solid var(--foster-border);
    border-radius: 999px;
    background: var(--foster-surface);
    color: var(--foster-text);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.375rem 0.75rem;
    cursor: pointer;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--foster-text) 6%, transparent);
    transition: all 0.15s ease;
}

.chat-starter-btn:hover {
    border-color: var(--foster-primary);
    color: var(--foster-primary);
    background: var(--foster-primary-light);
    transform: translateY(-1px);
}

/* ── Message rows ── */
.chat-msg {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 0;
    animation: fadeSlideIn 0.25s ease-out both;
}

.chat-msg + .chat-msg { border-top: 1px solid var(--foster-border); }

.chat-msg-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border: 1px solid color-mix(in srgb, var(--foster-text) 10%, transparent);
    box-shadow: 0 4px 10px color-mix(in srgb, var(--foster-text) 8%, transparent);
}

.chat-avatar-user {
    background: var(--foster-primary);
    color: #fff;
}

[data-theme="dark"] .chat-avatar-user {
    color: #0d1117;
}

.chat-avatar-ai {
    background: var(--foster-success);
    color: #fff;
}

.chat-msg-body {
    flex: 1;
    min-width: 0;
}

.chat-msg-content {
    font-size: 0.9375rem;
    line-height: 1.65;
    color: var(--foster-text);
    border: 1px solid var(--foster-border);
    border-radius: 1rem;
    background: var(--foster-surface);
    padding: 0.875rem 1rem;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--foster-text) 4%, transparent);
}

.chat-msg-user .chat-msg-content {
    background: var(--foster-primary-light);
    border-color: color-mix(in srgb, var(--foster-primary) 16%, var(--foster-border));
}

[data-theme="dark"] .chat-msg-user .chat-msg-content {
    background: color-mix(in srgb, var(--foster-primary) 12%, var(--foster-surface));
}

.chat-msg-ai .chat-msg-content {
    background: color-mix(in srgb, var(--foster-surface) 88%, var(--foster-bg));
}

.chat-ai-text {
    white-space: normal;
}

/* Markdown content within chat bubbles */
.chat-ai-text .markdown-body {
    line-height: 1.6;
}

.chat-ai-text .markdown-body p {
    margin: 0 0 0.5em;
}

.chat-ai-text .markdown-body p:last-child {
    margin-bottom: 0;
}

.chat-ai-text .markdown-body ul,
.chat-ai-text .markdown-body ol {
    margin: 0.25em 0 0.5em 1.25em;
    padding: 0;
}

.chat-ai-text .markdown-body li {
    margin-bottom: 0.15em;
}

.chat-ai-text .markdown-body h1,
.chat-ai-text .markdown-body h2,
.chat-ai-text .markdown-body h3 {
    margin: 0.75em 0 0.35em;
    font-size: 1em;
    font-weight: 600;
}

.chat-ai-text .markdown-body code {
    background: var(--foster-code-bg, #f6f8fa);
    color: var(--foster-text, #24292f);
    padding: 0.125em 0.35em;
    border-radius: 3px;
    font-size: 0.9em;
}

.chat-ai-text .markdown-body pre {
    background: var(--foster-code-bg, #f6f8fa);
    color: var(--foster-text, #24292f);
    padding: 0.75em 1em;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.chat-ai-text .markdown-body pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.chat-ai-text .markdown-body blockquote {
    border-left: 3px solid var(--foster-border, #d0d7de);
    margin: 0.5em 0;
    padding: 0.25em 0.75em;
    color: var(--foster-text-secondary);
}

.chat-ai-text .markdown-body table {
    border-collapse: collapse;
    margin: 0.5em 0;
    font-size: 0.9em;
}

.chat-ai-text .markdown-body th,
.chat-ai-text .markdown-body td {
    border: 1px solid var(--foster-border, #d0d7de);
    padding: 0.35em 0.6em;
}

.chat-ai-text .markdown-body th {
    background: var(--foster-code-bg, #f6f8fa);
}

.chat-ai-text .markdown-body strong {
    font-weight: 600;
}

.chat-ai-text .markdown-body a {
    color: var(--foster-primary, #0969da);
}

.chat-msg-meta {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.375rem;
    font-size: 0.6875rem;
    color: var(--foster-text-secondary);
    font-variant-numeric: tabular-nums;
    flex-wrap: wrap;
}

/* ── Error inline ── */
.chat-error {
    text-align: center;
    padding: 0.625rem 1rem;
    margin: 0.5rem 0;
    border-radius: var(--foster-radius);
    background: var(--foster-danger-light);
    color: var(--foster-danger);
    font-size: 0.8125rem;
    font-weight: 500;
}

/* ── Bottom input bar ── */
.chat-input-bar {
    border-top: 1px solid var(--foster-border);
    background: color-mix(in srgb, var(--foster-bg) 88%, transparent);
    backdrop-filter: blur(12px);
    padding: 0.75rem 1.5rem calc(0.5rem + env(safe-area-inset-bottom, 0));
}

/* Working indicator pinned to the composer — stays visible at the very bottom while the AI generates, so it's
   obvious it's still working after scrolling down. */
.chat-working-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.5rem;
    padding: 0.375rem 0.625rem;
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--foster-primary) 8%, var(--foster-surface));
    border: 1px solid color-mix(in srgb, var(--foster-primary) 22%, var(--foster-border));
    animation: fadeSlideIn 0.2s ease-out;
}

.chat-working-banner .typing-indicator {
    padding: 0.125rem 0.375rem;
    background: transparent;
    border: none;
}

.chat-working-text {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--foster-text, #1f2328);
}

/* Active-session strip: shows which saved customization the thread is continuing, above the composer. */
.chat-session-strip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: 0.375rem 1.5rem;
    font-size: 0.75rem;
    color: var(--foster-text-secondary);
    border-top: 1px solid var(--foster-border);
    background: color-mix(in srgb, var(--foster-accent, #6c5ce7) 8%, transparent);
}

/* The currently-open session's card in the Sessions panel. */
.search-memory-card-active {
    border-color: var(--foster-accent, #6c5ce7);
    box-shadow: 0 0 0 1px var(--foster-accent, #6c5ce7) inset;
}

.chat-input-hint {
    text-align: center;
    font-size: 0.6875rem;
    color: var(--foster-text-secondary);
    padding-top: 0.375rem;
    opacity: 0.7;
}

.chat-input-hint kbd {
    display: inline-block;
    padding: 0.0625rem 0.3125rem;
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1;
    color: var(--foster-text-secondary);
    background: var(--foster-surface);
    border: 1px solid var(--foster-border);
    border-radius: 3px;
    box-shadow: 0 1px 0 var(--foster-border);
    font-family: inherit;
}

.chat-input-row {
    max-width: 48rem;
    margin: 0 auto;
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input-wrap {
    flex: 1;
    display: flex;
    align-items: flex-end;
    border: 1px solid var(--foster-border);
    border-radius: 1.5rem;
    background: var(--foster-surface);
    padding: 0.375rem 0.5rem 0.375rem 1rem;
    box-shadow: 0 6px 18px color-mix(in srgb, var(--foster-text) 6%, transparent);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-input-wrap:focus-within {
    border-color: var(--foster-primary);
    box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.15);
}

.chat-textarea {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--foster-text);
    font-size: 0.9375rem;
    line-height: 1.5;
    resize: none;
    max-height: 10rem;
    padding: 0.375rem 0;
    font-family: inherit;
}

.chat-textarea::placeholder {
    color: var(--foster-text-secondary);
}

.chat-input-actions {
    display: flex;
    align-items: flex-end;
    padding-bottom: 0.125rem;
}

.chat-send-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: none;
    background: var(--foster-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    transition: opacity 0.15s ease, transform 0.1s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    opacity: 0.85;
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

[data-theme="dark"] .chat-send-btn {
    color: #0d1117;
}

.chat-send-icon {
    line-height: 1;
}

.chat-stop-btn {
    background: var(--foster-text-secondary);
}

/* Submitting: the frame shown the instant Send is clicked, while the request is still being prepared and there is
   nothing to cancel yet. Keeps the primary colour (the click "took") but is inert and visibly busy. */
.chat-send-btn-busy {
    background: var(--foster-primary);
}

.chat-send-btn-busy:disabled {
    opacity: 0.9;   /* override the generic disabled fade — this button is busy, not unavailable */
    cursor: progress;
}

.chat-send-spinner {
    width: 0.875rem;
    height: 0.875rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: chat-send-spin 0.6s linear infinite;
}

@keyframes chat-send-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .chat-send-spinner {
        animation-duration: 2s;
    }
}

.chat-stop-icon {
    font-size: 0.625rem;
    line-height: 1;
}

.chat-new-btn {
    border: 1px solid var(--foster-border);
    border-radius: 1.5rem;
    background: var(--foster-surface);
    color: var(--foster-text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--foster-text) 6%, transparent);
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.chat-new-btn:hover {
    border-color: var(--foster-primary);
    color: var(--foster-primary);
    background: var(--foster-primary-light);
    transform: translateY(-1px);
}

/* ── Export dropdown ── */
.chat-export-group {
    position: relative;
    flex-shrink: 0;
}

.chat-export-btn {
    border: 1px solid var(--foster-border);
    border-radius: 1.5rem;
    background: var(--foster-surface);
    color: var(--foster-text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--foster-text) 6%, transparent);
    transition: all 0.15s ease;
}

.chat-export-btn:hover {
    border-color: var(--foster-primary);
    color: var(--foster-primary);
    background: var(--foster-primary-light);
    transform: translateY(-1px);
}

.chat-export-dropdown {
    position: absolute;
    bottom: calc(100% + 0.375rem);
    left: 0;
    min-width: 12rem;
    background: var(--foster-surface);
    border: 1px solid var(--foster-border);
    border-radius: var(--foster-radius);
    box-shadow: var(--foster-card-shadow);
    z-index: 20;
    padding: 0.25rem 0;
    overflow: hidden;
}

.chat-export-option {
    display: block;
    width: 100%;
    border: none;
    background: none;
    text-align: left;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    color: var(--foster-text);
    cursor: pointer;
    transition: background 0.12s ease;
}

.chat-export-option:hover {
    background: var(--foster-primary-light);
    color: var(--foster-primary);
}

@media (max-width: 767.98px) {
    .chat-page {
        height: calc(100vh - 3rem - 1rem - env(safe-area-inset-top, 0px));
        margin: -1rem -1rem 0;
    }

    .chat-page-toolbar {
        margin-top: 0.75rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .chat-page-toolbar-title,
    .chat-page-toolbar-actions {
        width: 100%;
    }

    .chat-page-toolbar-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .chat-page-toolbar-actions > * {
        width: 100%;
        text-align: center;
    }

    .chat-messages-inner,
    .chat-input-row {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .chat-input-bar {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        padding-bottom: calc(0.375rem + env(safe-area-inset-bottom, 0));
    }

    .chat-input-row {
        flex-wrap: wrap;
    }

    .chat-input-row > * {
        width: 100%;
    }

    .chat-input-actions {
        padding-bottom: 0;
    }

    .chat-export-group {
        width: 100%;
    }

    .chat-export-dropdown {
        left: 0;
        right: 0;
        min-width: 0;
        width: 100%;
    }

    .chat-new-btn,
    .chat-export-btn {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
        width: 100%;
    }

    .chat-starter-btn {
        width: 100%;
        max-width: 20rem;
    }

@media (min-width: 768px) and (max-width: 1024px) {
    .chat-page-toolbar {
        gap: 1rem;
    }

    .chat-page-toolbar-title,
    .chat-page-toolbar-actions {
        width: 100%;
    }

    .chat-input-row {
        flex-wrap: wrap;
    }

    .chat-input-wrap {
        flex: 1 1 100%;
    }
}
}

/* ── Chat bubbles (legacy, used by Search page) ── */
.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: var(--foster-radius);
    font-size: 0.875rem;
    line-height: 1.55;
    animation: fadeSlideIn 0.3s ease-out both;
}

.chat-bubble-user {
    align-self: flex-end;
    background: var(--foster-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

[data-theme="dark"] .chat-bubble-user {
    color: #0d1117;
}

.chat-bubble-ai {
    align-self: flex-start;
    background: var(--foster-surface);
    border: 1px solid var(--foster-border);
    color: var(--foster-text);
    border-bottom-left-radius: 4px;
    white-space: pre-wrap;
}

.chat-sender {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
    opacity: 0.7;
}

.chat-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.chat-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: 20px;
    font-size: 0.6875rem;
    font-weight: 500;
    background: var(--foster-bg);
    border: 1px solid var(--foster-border);
    color: var(--foster-text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ── Library search bar ── */
.library-search {
    position: relative;
    flex: 1;
    min-width: 180px;
    max-width: 320px;
}

.library-search .form-control {
    padding-left: 2rem;
    font-size: 0.8125rem;
    height: 2.25rem;
}

.library-search-icon {
    position: absolute;
    left: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--foster-text-secondary);
    pointer-events: none;
    z-index: 1;
}

/* ── Library stat pills ── */
.stat-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--foster-border);
    background: var(--foster-surface);
    color: var(--foster-text-secondary);
    font-variant-numeric: tabular-nums;
}

.stat-pill-count {
    color: var(--foster-text);
}

@media (max-width: 767.98px) {
    .page-header {
        margin-bottom: 1rem;
    }

    .page-header-body {
        padding: 1rem;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .page-header .page-description {
        font-size: 0.875rem;
        margin-bottom: 0;
    }

    .page-header-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .page-chip-link {
        width: 100%;
        text-align: center;
    }

    .page-toolbar > * {
        width: 100%;
    }

    .page-toolbar .btn,
    .page-button-row .btn {
        width: 100%;
    }

    .page-toolbar .btn-group,
    .card-header .btn-group,
    .card-header .d-flex.gap-2,
    .card-header .d-flex.gap-3,
    .card-header .input-group {
        width: 100%;
        flex-wrap: wrap;
    }

    .card-header .d-flex.gap-2 > *,
    .card-header .d-flex.gap-3 > *,
    .card-header .input-group > * {
        flex: 1 1 100%;
    }

    .page-toolbar .library-search,
    .library-search-responsive {
        max-width: none;
        min-width: 0;
    }

    .page-toolbar-filter {
        margin-left: 0;
        flex-direction: column;
        align-items: stretch;
    }

    .page-toolbar-filter label {
        white-space: normal;
    }

    .page-toolbar-filter .form-select {
        width: 100% !important;
    }

    .pagination-shell {
        justify-content: flex-start !important;
    }

    .stat-pill {
        max-width: 100%;
        white-space: normal;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .page-header-body {
        padding: 1.125rem 1.25rem 0.875rem;
    }

    .page-toolbar,
    .page-button-row,
    .card-header .d-flex.gap-2,
    .card-header .d-flex.gap-3 {
        align-items: flex-start;
    }

    .page-toolbar .library-search,
    .library-search-responsive {
        max-width: 100%;
        flex: 1 1 16rem;
    }
}

/* ── Success celebration ── */
.celebration {
    position: relative;
}

.celebration::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--foster-radius);
    pointer-events: none;
    animation: celebrationGlow 1.5s ease-out both;
}

@keyframes celebrationGlow {
    0%   { box-shadow: inset 0 0 0 2px var(--foster-success), 0 0 20px rgba(26, 127, 55, 0.3); }
    100% { box-shadow: inset 0 0 0 1px transparent, 0 0 0 transparent; }
}

/* ── Metadata page ── */

.meta-section-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--foster-text-secondary);
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--foster-border);
    display: flex;
    align-items: center;
}

.meta-value-lg {
    font-size: 1.125rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ── Step timeline (horizontal-compact) ── */
.step-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.step-timeline-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.625rem;
    border-radius: var(--foster-radius-sm);
    border: 1px solid var(--foster-border);
    background: var(--foster-surface);
    font-size: 0.8125rem;
    transition: background 0.15s ease;
}

.step-timeline-row:hover {
    background: var(--foster-bg);
}

.step-timeline-row.step-ok {
    border-left: 3px solid var(--foster-success);
}

.step-timeline-row.step-active {
    border-left: 3px solid var(--foster-primary);
}

.step-timeline-row.step-error {
    border-left: 3px solid var(--foster-danger);
}

.step-timeline-indicator {
    font-size: 0.8125rem;
    flex-shrink: 0;
    width: 1.25rem;
    text-align: center;
}

.step-timeline-content {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
}

.step-timeline-name {
    font-weight: 600;
    color: var(--foster-text);
}

.step-timeline-duration {
    font-variant-numeric: tabular-nums;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--foster-primary);
    background: var(--foster-primary-light);
    padding: 0.0625rem 0.375rem;
    border-radius: 20px;
}

.step-timeline-details {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.step-detail-tag {
    font-size: 0.6875rem;
    padding: 0.0625rem 0.375rem;
    border-radius: 20px;
    background: var(--foster-bg);
    border: 1px solid var(--foster-border);
    color: var(--foster-text-secondary);
}

/* ── Pipeline progress stepper ── */
.pipeline-stepper {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0.75rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.pipeline-step-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    border: 1.5px solid var(--foster-border);
    background: var(--foster-surface);
    color: var(--foster-text-secondary);
    transition: all 0.3s ease;
}

.pipeline-step-item .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    font-size: 0.625rem;
    font-weight: 700;
    background: var(--foster-border);
    color: var(--foster-text-secondary);
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.pipeline-step-item.step-done {
    border-color: var(--bs-success);
    background: rgba(25, 135, 84, 0.08);
    color: var(--bs-success);
}

.pipeline-step-item.step-done .step-num {
    background: var(--bs-success);
    color: #fff;
}

.pipeline-step-item.step-active {
    border-color: var(--bs-warning);
    background: rgba(255, 193, 7, 0.1);
    color: var(--bs-warning);
    animation: stepPulse 1.5s ease-in-out infinite;
}

.pipeline-step-item.step-active .step-num {
    background: var(--bs-warning);
    color: #000;
}

.pipeline-step-item.step-failed {
    border-color: var(--bs-danger);
    background: rgba(220, 53, 69, 0.08);
    color: var(--bs-danger);
}

.pipeline-step-item.step-failed .step-num {
    background: var(--bs-danger);
    color: #fff;
}

@keyframes stepPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.3); }
    50%      { box-shadow: 0 0 0 4px rgba(255, 193, 7, 0); }
}

.pipeline-step-connector {
    width: 1.25rem;
    height: 2px;
    flex-shrink: 0;
    background: var(--foster-border);
    transition: background 0.3s ease;
}

.pipeline-step-connector.connector-done {
    background: var(--bs-success);
}

button.pipeline-step-item.step-clickable {
    cursor: pointer;
    border-style: dashed;
    background: var(--foster-surface);
    color: var(--foster-text-secondary);
}

button.pipeline-step-item.step-clickable:hover {
    border-color: var(--foster-primary);
    background: var(--foster-primary-light);
    color: var(--foster-primary);
    border-style: solid;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

button.pipeline-step-item.step-clickable:hover .step-num {
    background: var(--foster-primary);
    color: #fff;
}

button.pipeline-step-item.step-clickable:active {
    transform: translateY(0);
    box-shadow: none;
}

button.pipeline-step-item.step-clickable.step-failed {
    border-style: dashed;
    border-color: var(--bs-danger);
}

button.pipeline-step-item.step-clickable.step-failed:hover {
    border-color: var(--foster-primary);
    background: var(--foster-primary-light);
    color: var(--foster-primary);
    border-style: solid;
}

button.pipeline-step-item.step-clickable.step-failed:hover .step-num {
    background: var(--foster-primary);
    color: #fff;
}

/* ── Row-level pipeline stepper (compact) ── */
.pipeline-stepper-row {
    padding: 0.25rem 0;
}

.pipeline-step-item-sm {
    padding: 0.1875rem 0.5rem;
    font-size: 0.6875rem;
}

.pipeline-step-item-sm .step-num {
    width: 1rem;
    height: 1rem;
    font-size: 0.5625rem;
}

.row-stepper-row {
    border-top: none !important;
}

.row-stepper-row > td {
    border-top: none !important;
}

.row-stepper-cell {
    padding-top: 0 !important;
    padding-bottom: 0.375rem !important;
}

/* Visually connect the data row and stepper row */
tr.row-has-stepper > td {
    border-bottom: none !important;
    padding-bottom: 0 !important;
}

/* Hover both rows together */
.table-hover > tbody > tr.row-has-stepper:hover,
.table-hover > tbody > tr.row-has-stepper:hover + tr.row-stepper-row {
    background-color: var(--foster-primary-light);
}

.table-hover > tbody > tr.row-stepper-row:hover {
    background-color: var(--foster-primary-light);
}

/* ── Batch pipeline stepper ── */
.batch-pipeline-stepper-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pipeline-stepper-batch {
    padding: 0.25rem 0;
}

.batch-step-item {
    gap: 0.25rem;
}

.batch-step-count {
    font-size: 0.625rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: rgba(0, 0, 0, 0.1);
    padding: 0.0625rem 0.375rem;
    border-radius: 10px;
    min-width: 1.25rem;
    text-align: center;
}

.batch-step-count-done {
    background: rgba(25, 135, 84, 0.15);
}

.batch-cancel-btn {
    flex-shrink: 0;
}

@media (max-width: 767.98px) {
    .pipeline-step-item {
        padding: 0.3125rem 0.5rem;
        font-size: 0.6875rem;
    }

    .pipeline-step-item .step-num {
        width: 1.125rem;
        height: 1.125rem;
        font-size: 0.5625rem;
    }

    .pipeline-step-connector {
        width: 0.75rem;
    }

    .pipeline-step-item-sm {
        padding: 0.1875rem 0.375rem;
        font-size: 0.625rem;
    }

    .pipeline-step-item-sm .step-num {
        width: 0.875rem;
        height: 0.875rem;
        font-size: 0.5rem;
    }
}

/* ── AcuCopilot Workspace ── */
.copilot-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    border-radius: 0.75rem;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.copilot-badge-denied {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

.copilot-card {
    margin: 0.6rem 0;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.12));
    border-radius: 0.5rem;
    overflow: hidden;
}

.copilot-card-head {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
}

.copilot-card-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.copilot-card-subtitle {
    font-size: 0.78rem;
    opacity: 0.7;
}

.copilot-card-scroll {
    overflow-x: auto;
}

.copilot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.copilot-table th,
.copilot-table td {
    padding: 0.4rem 0.75rem;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
}

.copilot-table th {
    font-weight: 600;
    opacity: 0.75;
}

.copilot-table tbody tr:last-child td {
    border-bottom: none;
}

.copilot-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.copilot-tool-chip {
    font-size: 0.72rem;
    padding: 0.15rem 0.55rem;
    border-radius: 0.75rem;
    background: rgba(13, 110, 253, 0.12);
    color: #0d6efd;
}

.copilot-tool-chip-error {
    background: rgba(220, 53, 69, 0.12);
    color: #dc3545;
}

/* ── AcuCopilot confirmation dialog ── */
.copilot-confirm {
    margin: 0.6rem 0;
    border: 1px solid rgba(255, 193, 7, 0.55);
    border-radius: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: rgba(255, 193, 7, 0.08);
}

.copilot-confirm-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}

.copilot-confirm .copilot-table th {
    width: 40%;
    opacity: 0.75;
}

.copilot-confirm-note {
    font-size: 0.78rem;
    opacity: 0.8;
    margin: 0.4rem 0 0.5rem;
}

.copilot-confirm-actions {
    display: flex;
    gap: 0.5rem;
}

.copilot-confirm-yes,
.copilot-confirm-no {
    border: none;
    border-radius: 0.4rem;
    padding: 0.35rem 0.9rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.copilot-confirm-yes {
    background: #198754;
    color: #fff;
}

.copilot-confirm-yes:disabled,
.copilot-confirm-no:disabled {
    opacity: 0.6;
    cursor: default;
}

.copilot-confirm-no {
    background: transparent;
    color: inherit;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.2));
}

/* AcuCopilot connect button — the chat empty-state chip, given a primary accent so it reads as the CTA. */
.copilot-connect-btn {
    background: #198754;
    color: #fff;
    border-color: #198754;
    font-weight: 600;
    padding: 0.5rem 1.1rem;
}

.copilot-connect-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

/* AcuCopilot mid-session reconnect bar (shown above the input when a turn reports the session expired). */
.copilot-reconnect-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 auto 0.5rem;
    max-width: 48rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid rgba(255, 193, 7, 0.55);
    background: rgba(255, 193, 7, 0.10);
    border-radius: 0.5rem;
    font-size: 0.85rem;
}
