:root {
    /* Message styling */
    --message-border-radius: 12px;
    --message-padding: 1.25rem;
    --message-spacing: 1.25rem;

    /* Shadows for depth */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);

    /* Status colors */
    --success: #22c55e;
    --warning: #fbbf24;
    --error: #ef4444;
    --confession-accent: #6366f1;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    min-height: 400px;
}

/* ========================================
   Grid Layout for Chat Main + Sidebars
   ======================================== */

.chat-main {
    display: grid;
    grid-template-columns: 52px 1fr 280px;
    gap: 1rem;
    flex: 1;
    min-height: 0;
    position: relative;
}

/* Sessions expanded */
.chat-main[data-sessions-expanded="true"] {
    grid-template-columns: 280px 1fr 280px;
}

/* Settings collapsed */
.chat-main[data-sidebar-collapsed="true"] {
    grid-template-columns: 52px 1fr 52px;
}

/* Both expanded */
.chat-main[data-sessions-expanded="true"][data-sidebar-collapsed="false"] {
    grid-template-columns: 280px 1fr 280px;
}

/* Sessions expanded, settings collapsed */
.chat-main[data-sessions-expanded="true"][data-sidebar-collapsed="true"] {
    grid-template-columns: 280px 1fr 52px;
}

.chat-content {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ========================================
   Sessions Sidebar Styles (Left)
   ======================================== */

.sessions-sidebar {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: width 0.3s ease;
    position: relative;
}

/* Toggle button */
.sessions-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
}

.sessions-toggle:hover {
    background-color: rgba(196, 154, 108, 0.1);
}

.sessions-icon {
    font-size: 1.1rem;
}

.sessions-label {
    flex: 1;
    font-weight: 500;
}

.sessions-chevron {
    transition: transform 0.3s;
    color: var(--text-secondary);
}

.sessions-sidebar[data-expanded="true"] .sessions-chevron {
    transform: rotate(180deg);
}

/* Collapsed state */
.sessions-sidebar[data-expanded="false"] .sessions-label,
.sessions-sidebar[data-expanded="false"] .sessions-chevron {
    display: none;
}

.sessions-sidebar[data-expanded="false"] .sessions-content {
    display: none;
}

.sessions-sidebar[data-expanded="false"] .sessions-toggle {
    justify-content: center;
    flex-direction: column;
    padding: 0.5rem;
    gap: 0.5rem;
}

/* Sessions content */
.sessions-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sessions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-tertiary);
}

.sessions-title {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.6rem;
    background-color: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.new-chat-btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.new-chat-btn:active {
    transform: translateY(0);
}

.new-chat-icon {
    font-size: 0.9rem;
    font-weight: bold;
}

/* Sessions list */
.sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.sessions-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-tertiary);
}

.sessions-empty p {
    margin: 0 0 0.5rem 0;
    font-size: 0.85rem;
}

.sessions-empty-hint {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Session not found (404) message */
.session-not-found {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 400px;
    margin: 2rem auto;
}

.not-found-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.session-not-found h2 {
    margin: 0 0 0.75rem 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.session-not-found p {
    margin: 0 0 0.75rem 0;
    color: var(--text-secondary);
    line-height: 1.5;
}

.not-found-id {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.not-found-id code {
    background-color: var(--bg-tertiary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.75rem;
    word-break: break-all;
}

.not-found-btn {
    margin-top: 1.5rem;
    padding: 0.75rem 1.5rem;
    background-color: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.not-found-btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.not-found-btn:active {
    transform: translateY(0);
}

/* Session item */
.session-item {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background-color: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    position: relative;
}

.session-item:hover {
    background-color: rgba(196, 154, 108, 0.1);
    border-color: var(--border-color);
}

.session-item.active {
    background-color: rgba(196, 154, 108, 0.15);
    border-color: var(--accent);
}

.session-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.session-item-actions {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    flex-shrink: 0;
}

.session-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.session-delete-btn {
    padding: 0.2rem;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    font-size: 0.9rem;
    line-height: 1;
    border-radius: 4px;
}

.session-item:hover .session-delete-btn {
    opacity: 1;
}

.session-delete-btn:hover {
    color: var(--error);
    background-color: rgba(239, 68, 68, 0.1);
}

.session-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.35rem;
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

.session-time {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.session-message-count {
    opacity: 0.7;
}

/* Delete confirmation dialog */
.delete-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.delete-dialog-overlay:not([hidden]) {
    opacity: 1;
    visibility: visible;
}

.delete-dialog {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 360px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.delete-dialog-title {
    margin: 0 0 0.75rem 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.delete-dialog-message {
    margin: 0 0 1.25rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.delete-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.delete-dialog-cancel {
    padding: 0.5rem 1rem;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s;
}

.delete-dialog-cancel:hover {
    background-color: var(--bg-tertiary);
}

.delete-dialog-confirm {
    padding: 0.5rem 1rem;
    background-color: var(--error);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.delete-dialog-confirm:hover {
    background-color: #dc2626;
}

/* Share button in session item */
.session-share-btn {
    padding: 0.2rem;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    font-size: 0.75rem;
    line-height: 1;
    border-radius: 4px;
    margin-right: 0.25rem;
}

.session-item:hover .session-share-btn {
    opacity: 1;
}

.session-share-btn:hover {
    color: var(--primary);
    background-color: rgba(59, 130, 246, 0.1);
}

/* Shared indicator badge */
.session-shared-badge {
    font-size: 0.65rem;
    color: var(--primary);
    margin-left: 0.25rem;
    opacity: 0.8;
}

/* Share modal overlay */
.share-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.share-modal-overlay:not([hidden]) {
    opacity: 1;
    visibility: visible;
}

.share-modal {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.share-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.share-modal-title {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.share-modal-close {
    padding: 0.25rem 0.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.share-modal-close:hover {
    background-color: var(--bg-tertiary);
}

.share-modal-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.share-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.share-toggle-label {
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* Toggle switch */
.share-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.share-toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.share-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 26px;
    transition: 0.3s;
}

.share-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    transition: 0.3s;
}

.share-toggle-input:checked + .share-toggle-slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

.share-toggle-input:checked + .share-toggle-slider:before {
    transform: translateX(22px);
    background-color: white;
}

.share-link-section {
    padding: 1rem;
    background-color: var(--bg-tertiary);
    border-radius: 6px;
}

.share-link-description {
    margin: 0 0 0.75rem 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.share-link-row {
    display: flex;
    gap: 0.5rem;
}

.share-link-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: monospace;
}

.share-copy-btn {
    padding: 0.5rem 1rem;
    background-color: var(--primary);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.share-copy-btn:hover {
    background-color: #2563eb;
}

.share-copy-btn.copied {
    background-color: #10b981;
}

.share-preview-row {
    margin-top: 0.75rem;
    text-align: center;
}

.share-preview-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    transition: color 0.2s, background-color 0.2s;
}

.share-preview-link:hover {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

.share-preview-icon {
    font-size: 1rem;
}

/* Unshare confirmation dialog */
.unshare-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.unshare-dialog-overlay:not([hidden]) {
    opacity: 1;
    visibility: visible;
}

.unshare-dialog {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 360px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.unshare-dialog-title {
    margin: 0 0 0.75rem 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.unshare-dialog-message {
    margin: 0 0 1.25rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.unshare-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.unshare-dialog-cancel {
    padding: 0.5rem 1rem;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s;
}

.unshare-dialog-cancel:hover {
    background-color: var(--bg-tertiary);
}

.unshare-dialog-confirm {
    padding: 0.5rem 1rem;
    background-color: var(--warning, #f59e0b);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.unshare-dialog-confirm:hover {
    background-color: #d97706;
}

/* Mobile sessions toggle */
.mobile-sessions-toggle {
    display: none;
    position: fixed;
    bottom: 80px;
    left: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    z-index: 100;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.mobile-sessions-toggle:hover {
    background-color: var(--bg-tertiary);
}

/* ========================================
   Settings Sidebar Styles
   ======================================== */

.settings-sidebar {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: width 0.3s ease;
    position: relative;
}

/* Toggle button - always visible */
.sidebar-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
}

.sidebar-toggle:hover {
    background-color: rgba(196, 154, 108, 0.1);
}

.sidebar-icon {
    font-size: 1.1rem;
}

.sidebar-label {
    flex: 1;
    font-weight: 500;
}

.sidebar-chevron {
    transition: transform 0.3s;
    color: var(--text-secondary);
}

/* Collapsed state */
.settings-sidebar[data-expanded="false"] .sidebar-label,
.settings-sidebar[data-expanded="false"] .sidebar-chevron {
    display: none;
}

.settings-sidebar[data-expanded="false"] .sidebar-badges {
    display: flex;
}

.settings-sidebar[data-expanded="true"] .sidebar-badges {
    display: none;
}

.settings-sidebar[data-expanded="false"] .sidebar-content {
    display: none;
}

.settings-sidebar[data-expanded="false"] .sidebar-toggle {
    justify-content: center;
    flex-direction: column;
    padding: 0.5rem;
    gap: 0.5rem;
}

/* Badges */
.sidebar-badges {
    flex-direction: column;
    gap: 0.25rem;
    align-items: center;
}

.sidebar-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-badge.sources {
    background-color: var(--accent);
    color: var(--bg-primary);
}

.sidebar-badge.confessions {
    background-color: var(--confession-accent);
    color: white;
}

.sidebar-badge:empty {
    display: none;
}

/* Scrollable content */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

/* Sidebar section styles - more distinct collapsible sections */
.sidebar-content .persona-selector,
.sidebar-content .source-selector,
.sidebar-content .confession-selector {
    margin-bottom: 0;
    padding: 0;
    background-color: transparent;
    border: none;
    border-radius: 0;
}

.sidebar-content .source-selector {
    border-bottom: 1px solid var(--border-color);
}

.sidebar-content .source-selector-header,
.sidebar-content .confession-selector-header {
    padding: 0.75rem;
    margin-bottom: 0;
    background-color: var(--bg-tertiary);
    border-radius: 0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.sidebar-content .source-selector-header:hover,
.sidebar-content .confession-selector-header:hover {
    background-color: rgba(196, 154, 108, 0.15);
}

.sidebar-content .source-selector-title,
.sidebar-content .confession-selector-title {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-content .source-selector-content,
.sidebar-content .confession-selector-content {
    padding: 0.75rem;
    background-color: var(--bg-secondary);
}

.sidebar-content .source-selector-toggle,
.sidebar-content .confession-selector-toggle {
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
}

/* Tooltip on hover when collapsed */
.sidebar-tooltip {
    position: absolute;
    right: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    padding: 0.75rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    font-size: 0.85rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
}

.settings-sidebar[data-expanded="false"]:hover .sidebar-tooltip {
    opacity: 1;
}

.sidebar-tooltip div {
    margin-bottom: 0.5rem;
}

.sidebar-tooltip div:last-child {
    margin-bottom: 0;
}

.sidebar-tooltip strong {
    color: var(--text-primary);
}

.sidebar-tooltip span {
    color: var(--text-secondary);
}

/* Mobile floating toggle button - hidden on desktop */
.mobile-sidebar-toggle {
    display: none;
}

/* Mobile backdrop - hidden by default */
.sidebar-backdrop {
    display: none;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 0;
    border: 1px solid var(--border-color);
}

.chat-content .chat-form {
    flex-shrink: 0;
    margin-top: 1rem;
}

.message {
    padding: var(--message-padding);
    margin-bottom: var(--message-spacing);
    border-radius: var(--message-border-radius);
    animation: messageAppear 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-sm);
}

/* Enhanced message appear animation */
@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.user-message {
    background-color: var(--user-bg);
    margin-left: 2rem;
    border-left: 4px solid var(--accent);
    box-shadow: var(--shadow-md);
}

.assistant-message {
    background-color: var(--assistant-bg);
    margin-right: 2rem;
    border-left: 4px solid var(--text-secondary);
    box-shadow: var(--shadow-sm);
}

.message strong {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.message strong::before {
    content: '●';
    margin-right: 0.5rem;
    font-size: 0.5rem;
    vertical-align: middle;
}

/* Don't show bullet for strong elements inside text evaluation results */
.text-eval-container strong::before {
    content: none;
}

.user-message strong {
    color: var(--accent);
}

.user-message strong::before {
    color: var(--accent);
}

.chat-form {
    display: flex;
    gap: 0.75rem;
}

.chat-input {
    flex: 1;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--accent);
}

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

.send-button {
    padding: 1rem 2rem;
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.send-button:hover {
    background-color: var(--accent-hover);
}

.send-button:active {
    transform: scale(0.98);
}

.send-button:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

.error {
    color: var(--accent);
    padding: 1rem;
    background-color: rgba(233, 69, 96, 0.1);
    border-radius: 8px;
    border: 1px solid var(--accent);
}

.streaming-indicator {
    display: inline-block;
    width: 8px;
    height: 16px;
    background-color: var(--accent);
    animation: cursorBlink 1s ease-in-out infinite;
    margin-left: 2px;
    border-radius: 1px;
    vertical-align: middle;
}

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

/* Enhanced cursor blink for streaming */
@keyframes cursorBlink {
    0%, 45% { opacity: 1; }
    50%, 95% { opacity: 0.3; }
    100% { opacity: 1; }
}

/* Status indicator container - stays at bottom of message */
.status-indicator-container {
    display: block;
    min-height: 1.5rem;
    margin-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
}

.status-indicator-container:empty,
.status-indicator-container:has(.status-indicator[style*="display: none"]) {
    display: none;
    margin-top: 0;
    border-top: none;
    padding-top: 0;
}

/* Status indicator for processing progress */
.status-indicator {
    display: none;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    padding: 0.25rem 0;
    animation: statusPulse 2s ease-in-out infinite;
}

.status-indicator::before {
    content: "";
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    margin-right: 0.5rem;
    border: 2px solid var(--text-secondary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    vertical-align: middle;
}

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

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

/* Follow-up questions */
.follow-up-questions {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.follow-up-header {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-style: italic;
}

.follow-up-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.375rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.follow-up-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--accent-color);
}

.follow-up-btn:last-child {
    margin-bottom: 0;
}

.welcome-message {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    max-width: 650px;
    margin: 0 auto;
}

.welcome-message h2 {
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.welcome-message > p {
    margin-bottom: 1.25rem;
}

.welcome-instructions {
    text-align: left;
    background-color: var(--bg-tertiary);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-top: 1rem;
}

.welcome-instructions p {
    margin-bottom: 0.5rem;
}

.welcome-instructions ul {
    margin: 0.5rem 0 1rem 1.25rem;
    padding: 0;
}

.welcome-instructions li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.welcome-instructions li:last-child {
    margin-bottom: 0;
}

.welcome-example {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.welcome-example code {
    display: block;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-secondary);
    border-radius: 4px;
    font-size: 0.8rem;
    word-break: break-all;
    color: var(--accent);
}

/* Connection warning - shown only when SSE is unavailable */
.connection-warning {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
    background-color: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 6px;
    font-size: 0.8rem;
    color: #fbbf24;
}

.connection-warning .warning-icon {
    font-size: 1rem;
}

.connection-warning .warning-text {
    flex: 1;
}

/* Guest banner - shown for unauthenticated users */
.guest-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.guest-banner-text {
    flex: 1;
    font-size: 0.85rem;
    color: var(--bg-primary);
}

.guest-banner-text a {
    color: var(--bg-primary);
    text-decoration: underline;
    font-weight: 600;
}

.guest-banner-text a:hover {
    opacity: 0.9;
}

.guest-banner-close {
    background: transparent;
    border: none;
    color: var(--bg-primary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.guest-banner-close:hover {
    opacity: 1;
}

/* Source selector styles */
/* ========================================
   Persona Selector
   ======================================== */

.persona-selector {
    margin-bottom: 0;
    padding: 0;
    background-color: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
}

.persona-selector-header {
    padding: 0.75rem;
    background-color: var(--bg-tertiary);
    cursor: default;
}

.persona-selector-title {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.persona-selector-content {
    padding: 0.75rem;
    background-color: var(--bg-secondary);
}

.persona-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.persona-select:hover,
.persona-select:focus {
    border-color: var(--accent);
    outline: none;
}

.persona-select option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* Unrestricted Mode Toggle */
.unrestricted-mode-toggle {
    padding: 0.5rem 0.75rem 0.75rem;
    background-color: var(--bg-secondary);
}

.unrestricted-mode-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.unrestricted-mode-checkbox {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.unrestricted-mode-text {
    flex: 1;
}

/* Info tooltip button and popup */
.info-tooltip-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background-color: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s;
}

.info-tooltip-btn:hover,
.info-tooltip-btn:focus {
    color: var(--accent);
    background-color: rgba(196, 154, 108, 0.15);
    outline: none;
}

.info-tooltip-popup {
    position: fixed;
    width: 280px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
}

.info-tooltip-popup[hidden] {
    display: none;
}

.info-tooltip-popup.visible {
    animation: popupFadeIn 0.2s ease;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.info-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-tertiary);
    border-radius: 8px 8px 0 0;
}

.info-tooltip-header strong {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.info-tooltip-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.info-tooltip-close:hover {
    color: var(--accent);
}

.info-tooltip-content {
    padding: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.info-tooltip-content p {
    margin-bottom: 0.5rem;
}

.info-tooltip-content p:last-child {
    margin-bottom: 0;
}


/* Unrestricted mode active state */
.unrestricted-mode-label:has(.unrestricted-mode-checkbox:checked) .unrestricted-mode-text {
    color: var(--accent);
}

/* Save preferences button */
.save-preferences-container {
    padding: 0.5rem 0.75rem 0.75rem;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.save-preferences-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.save-preferences-btn:hover {
    background-color: rgba(196, 154, 108, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.save-preferences-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.save-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.save-status.success {
    color: var(--success);
}

.save-status.error {
    color: var(--error);
}

.source-selector {
    margin-bottom: 1rem;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.source-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.source-selector-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.source-selector-toggle {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.source-selector-toggle:hover {
    background-color: rgba(196, 154, 108, 0.15);
}

.source-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Compact source item */
.source-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.4rem 0.6rem;
    background-color: var(--bg-tertiary);
    border-radius: 6px;
    transition: background-color 0.2s, border-color 0.2s;
    border: 1px solid transparent;
    position: relative;
    box-sizing: border-box;
}

.source-item:hover {
    background-color: var(--bg-primary);
}

.source-item:has(.source-checkbox:checked) {
    border-color: var(--accent);
    background-color: rgba(196, 154, 108, 0.15);
}

.source-checkbox {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.source-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.source-name {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-info-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    font-size: 0.85rem;
    border-radius: 4px;
    transition: color 0.2s, background-color 0.2s;
    flex-shrink: 0;
}

.source-info-btn:hover,
.source-info-btn:focus {
    color: var(--accent);
    background-color: rgba(196, 154, 108, 0.15);
    outline: none;
}

.source-info-btn[aria-expanded="true"] {
    color: var(--accent);
}

/* Source info popup - uses fixed positioning to escape container overflow */
.source-popup {
    position: fixed;
    z-index: 1000;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 220px;
    max-width: 300px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    /* Animation triggered via class after positioning */
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.source-popup.visible {
    opacity: 1;
    transform: scale(1);
}

.source-popup[hidden] {
    display: none;
    opacity: 0;
    transform: scale(0.95);
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.popup-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.popup-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.1rem 0.3rem;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.2s, background-color 0.2s;
}

.popup-close:hover,
.popup-close:focus {
    color: var(--accent);
    background-color: rgba(196, 154, 108, 0.15);
    outline: none;
}

.popup-description {
    margin: 0;
    padding: 0.6rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.popup-stats {
    padding: 0.5rem 0.75rem;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.popup-stat {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-value {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

.stat-value.stat-user {
    color: var(--accent);
}

/* Source popup integrity section */
.popup-integrity {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.integrity-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.integrity-icon {
    font-size: 0.9rem;
    width: 1.2em;
    text-align: center;
}

.integrity-label {
    color: var(--text-secondary);
}

/* Integrity icon color classes */
.integrity-item .verification-verified { color: #22c55e; }
.integrity-item .verification-unverified { color: #a1a1aa; }
.integrity-item .timestamp-confirmed { color: #f7931a; }
.integrity-item .timestamp-pending { color: #fbbf24; }
.integrity-item .publisher-verified { color: #3b82f6; }

/* Diogenes badge (issue #77) — additive surface, no existing-layout changes. */
.integrity-item.diogenes-item .diogenes-logo {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}
.integrity-item.diogenes-verified .diogenes-logo,
.integrity-item.diogenes-verified .integrity-label {
    color: #2563eb;
}
.integrity-item.diogenes-unverified .integrity-label {
    color: #a1a1aa;
}
.integrity-item.diogenes-unreachable .integrity-label {
    color: #f59e0b;
    font-style: italic;
}
.integrity-item .diogenes-link {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--accent);
    text-decoration: none;
}
.integrity-item .diogenes-link:hover {
    text-decoration: underline;
}

.integrity-learn-more {
    font-size: 0.75rem;
    color: var(--accent);
    text-decoration: none;
    margin-top: 0.25rem;
    cursor: pointer;
}

.integrity-learn-more:hover {
    text-decoration: underline;
}

/* Timestamp item with details toggle */
.integrity-item.timestamp-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.details-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.6rem;
    padding: 0 0.25rem;
    margin-left: 0.25rem;
    transition: transform 0.2s;
}

.details-toggle:hover {
    color: var(--accent);
}

.details-toggle.expanded {
    transform: rotate(180deg);
}

/* Expandable integrity details */
.integrity-details {
    width: 100%;
    margin-top: 0.4rem;
    padding: 0.4rem 0.5rem;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 0.7rem;
}

.integrity-details[hidden] {
    display: none;
}

.integrity-detail-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.integrity-detail-row:last-child {
    margin-bottom: 0;
}

.detail-label {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.detail-value {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.detail-value code {
    font-family: monospace;
    font-size: 0.65rem;
    color: var(--text-primary);
}

.hash-value .copy-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.65rem;
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
    transition: color 0.2s, background-color 0.2s;
}

.hash-value .copy-btn:hover {
    color: var(--accent);
    background-color: rgba(196, 154, 108, 0.15);
}

.explorer-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.7rem;
}

.explorer-link:hover {
    text-decoration: underline;
}

/* Publisher item with expand button */
.publisher-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.publisher-expand-btn {
    background: none;
    border: none;
    color: #71717a;
    cursor: pointer;
    font-size: 0.65rem;
    padding: 0.15rem 0.3rem;
    margin-left: auto;
    border-radius: 3px;
    transition: background-color 0.2s, color 0.2s;
}

.publisher-expand-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #a1a1aa;
}

/* Publisher details container (expandable) */
.publisher-details-container {
    margin-top: 0.4rem;
    margin-left: 1.5rem;
    padding: 0.5rem;
    background-color: var(--bg-tertiary);
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.publisher-details-container .loading,
.publisher-details-container .error {
    padding: 0.5rem;
    font-size: 0.75rem;
    color: #71717a;
    text-align: center;
}

.publisher-details-container .error {
    color: #ef4444;
}

/* Source logo in popup header */
.source-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    gap: 0.5rem;
}

.popup-header-text {
    flex: 1;
    min-width: 0;
}

/* Metadata section (edition, license) */
.popup-metadata {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.source-edition {
    font-weight: 500;
}

.source-license {
    font-style: italic;
}

/* External link button */
.popup-external-link {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border-color);
}

.external-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.external-link-btn:hover {
    background-color: rgba(196, 154, 108, 0.15);
    text-decoration: none;
}

/* Publisher popup styles */
.publisher-popup-content {
    padding: 0.5rem;
    font-size: 0.8rem;
}

.publisher-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.publisher-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 4px;
}

.publisher-info {
    flex: 1;
}

.publisher-name {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.publisher-type {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.publisher-description {
    margin: 0.4rem 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.publisher-contact {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.publisher-website,
.publisher-email {
    font-size: 0.7rem;
    color: var(--accent);
    text-decoration: none;
}

.publisher-website:hover,
.publisher-email:hover {
    text-decoration: underline;
}

.publisher-sources {
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}

.publisher-sources-title {
    margin: 0 0 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.publisher-sources-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.publisher-source-item {
    padding: 0.2rem 0;
    font-size: 0.75rem;
    color: var(--text-primary);
}

.no-sources {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
}

.source-selector-content {
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.source-selector-content.collapsed {
    max-height: 0;
    padding: 0;
    overflow: hidden;
}

.selected-sources-badge {
    background-color: var(--accent);
    color: white;
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    margin-left: 0.5rem;
}

/* Source attribution styles */
.message-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

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

/* Persona badge - shows which persona generated the response */
.persona-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.message-text {
    flex: 1;
}

.source-attribution {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.source-attribution-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.source-attribution-icon:hover {
    background-color: var(--accent);
    border-color: var(--accent);
}

.source-attribution-icon svg {
    width: 14px;
    height: 14px;
    fill: var(--text-secondary);
}

.source-attribution-icon:hover svg {
    fill: white;
}

.source-attribution-popup {
    position: fixed;
    min-width: 300px;
    max-width: 400px;
    max-height: 300px;
    overflow-y: auto;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    padding: 0.75rem;
    display: none;
}

.source-attribution-popup.visible {
    display: block;
    animation: fadeIn 0.2s ease-in;
}

.source-attribution-popup-header {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.source-attribution-item {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background-color: var(--bg-tertiary);
    border-radius: 6px;
    border-left: 3px solid var(--accent);
}

.source-attribution-item:last-child {
    margin-bottom: 0;
}

.source-attribution-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.source-attribution-name {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--accent);
}

.source-attribution-location {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.source-attribution-content {
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.4;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-attribution-learn-more {
    display: block;
    font-size: 0.75rem;
    color: var(--accent);
    text-decoration: none;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    cursor: pointer;
}

.source-attribution-learn-more:hover {
    text-decoration: underline;
}

/* Markdown rendering styles */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    line-height: 1.3;
}

.message-text h1 { font-size: 1.4rem; }
.message-text h2 { font-size: 1.2rem; }
.message-text h3 { font-size: 1.1rem; }
.message-text h4 { font-size: 1rem; }

.message-text p {
    margin-bottom: 0.75rem;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text ul,
.message-text ol {
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.message-text li {
    margin-bottom: 0.25rem;
}

.message-text code {
    background-color: var(--bg-tertiary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.9em;
}

.message-text pre {
    background-color: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 0.75rem;
}

.message-text pre code {
    background-color: transparent;
    padding: 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.message-text blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    margin: 0.75rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-text strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message-text em {
    font-style: italic;
}

.message-text a {
    color: var(--accent);
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

.message-text hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1rem 0;
}

.message-text table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 0.75rem;
}

.message-text th,
.message-text td {
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    text-align: left;
}

.message-text th {
    background-color: var(--bg-tertiary);
    font-weight: 600;
}

/* Citation wrapper - inline container for button + popup */
.citation-wrapper {
    position: relative;
    display: inline-block;
    vertical-align: baseline;
}

/* Inline citation button styles */
.citation-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    margin: 0 1px;
    cursor: pointer;
    vertical-align: baseline;
}

.citation-btn:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

.citation-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background-color: var(--accent);
    color: var(--bg-primary);
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 9px;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: var(--shadow-sm);
}

.citation-btn:hover .citation-number {
    background-color: var(--accent-hover);
    transform: scale(1.1);
}

.citation-btn[aria-expanded="true"] .citation-number {
    background-color: var(--accent-hover);
}

/* Citation popup styles - positioned relative to wrapper */
.citation-popup {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 10px;
    min-width: 300px;
    max-width: 420px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--message-border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow: hidden;
}

/* Arrow pointing to citation */
.citation-popup::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 12px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid var(--border-color);
}

.citation-popup::after {
    content: '';
    position: absolute;
    top: -6px;
    left: 13px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 7px solid var(--bg-tertiary);
}

.citation-popup.visible {
    display: block;
    animation: fadeIn 0.15s ease-out;
}

.citation-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.citation-source {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent);
}

.citation-location {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

.citation-popup-content {
    display: block;
    padding: 1rem;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
    max-height: 200px;
    overflow-y: auto;
    font-family: Georgia, 'Times New Roman', serif;
    border-left: 3px solid var(--accent);
    margin: 0.5rem;
    background-color: rgba(196, 154, 108, 0.05);
    border-radius: 0 6px 6px 0;
}

/* Loading state for citation buttons during streaming */
.citation-btn-loading .citation-number {
    opacity: 0.7;
}

/* Buffering indicator shown when partial citation is detected */
.citation-buffering {
    color: var(--text-secondary);
    font-style: italic;
}

/* Verification status icons for source integrity */
.verification-icon {
    font-size: 0.65rem;
    margin-left: 2px;
    vertical-align: baseline;
}

.verification-verified {
    color: #22c55e; /* green */
}

.verification-tampered {
    color: #ef4444; /* red */
}

.verification-unverified {
    color: #a1a1aa; /* gray */
}

.citation-popup-verification {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    padding: 4px 0.75rem;
    background-color: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.citation-popup-verification.verified {
    color: #22c55e;
}

.citation-popup-verification.tampered {
    color: #ef4444;
}

.citation-popup-verification.unverified {
    color: #a1a1aa;
}

/* Phase 2: Bitcoin timestamp styles */
.timestamp-bitcoin {
    color: #f7931a; /* Bitcoin orange */
}

.timestamp-pending {
    color: #fbbf24; /* Amber for pending */
}

.citation-popup-timestamp {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    padding: 4px 0.75rem;
    background-color: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.citation-popup-timestamp.confirmed,
.citation-popup-timestamp.upgraded {
    color: #f7931a; /* Bitcoin orange */
}

.citation-popup-timestamp.pending {
    color: #fbbf24; /* Amber */
}

.citation-popup-timestamp.none {
    color: #a1a1aa; /* Gray */
}

.timestamp-icon {
    font-size: 0.8rem;
}

.bitcoin-block-link {
    color: #f7931a;
    text-decoration: none;
}

.bitcoin-block-link:hover {
    text-decoration: underline;
}

/* Phase 3: Publisher signature styles */
.publisher-badge {
    font-size: 0.65rem;
    margin-left: 2px;
    vertical-align: baseline;
}

.publisher-verified {
    color: #3b82f6; /* Blue for verified publisher */
}

.publisher-signed {
    color: #6366f1; /* Indigo for signed but not verified */
}

.publisher-invalid {
    color: #ef4444; /* Red for invalid signature */
}

.publisher-revoked {
    color: #f97316; /* Orange for revoked publisher */
}

.publisher-unsigned {
    color: #a1a1aa; /* Gray for unsigned */
}

.citation-popup-publisher {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    padding: 4px 0.75rem;
    background-color: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.citation-popup-publisher.verified {
    color: #3b82f6;
}

.citation-popup-publisher.signed {
    color: #6366f1;
}

.citation-popup-publisher.invalid {
    color: #ef4444;
}

.citation-popup-publisher.revoked {
    color: #f97316;
}

.citation-popup-publisher.unsigned {
    color: #a1a1aa;
}

.publisher-icon {
    font-size: 0.8rem;
}

.publisher-name-link {
    color: inherit;
    text-decoration: none;
}

.publisher-name-link:hover {
    text-decoration: underline;
}

.citation-popup-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 4px 0.75rem;
    background-color: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.citation-popup-footer .citation-popup-verification,
.citation-popup-footer .citation-popup-timestamp,
.citation-popup-footer .citation-popup-publisher {
    border-top: none;
    padding: 0;
}

.citation-popup-learn-more {
    font-size: 0.7rem;
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
    margin-left: auto;
}

.citation-popup-learn-more:hover {
    text-decoration: underline;
}

/* ========================================
   Phase 3: UI Polish
   ======================================== */

/* Typography improvements */
.message-text {
    line-height: 1.75;
    letter-spacing: 0.01em;
}

.message-text p {
    margin-bottom: 1rem;
}

.message-text h1:first-child,
.message-text h2:first-child,
.message-text h3:first-child,
.message-text h4:first-child {
    margin-top: 0;
}

.message-text h1 + p,
.message-text h2 + p,
.message-text h3 + p,
.message-text h4 + p {
    margin-top: 0.5rem;
}

/* Enhanced blockquote styling for quoted text */
.message-text blockquote {
    background-color: rgba(196, 154, 108, 0.1);
    border-left: 4px solid var(--accent);
    border-radius: 0 6px 6px 0;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    color: var(--text-primary);
    font-style: normal;
    font-family: Georgia, 'Times New Roman', serif;
}

.message-text blockquote p {
    margin-bottom: 0.5rem;
}

.message-text blockquote p:last-child {
    margin-bottom: 0;
}

.message-text blockquote em {
    color: var(--text-secondary);
}

/* Nested blockquotes */
.message-text blockquote blockquote {
    margin-left: 0.5rem;
    background-color: rgba(196, 154, 108, 0.05);
}

/* Improved popup animations */
@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.citation-popup.visible {
    display: block;
    animation: popupSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.source-attribution-popup.visible {
    display: block;
    animation: popupSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Loading state animations */
@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.citation-btn-loading .citation-number {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Skeleton loading for popup content */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.citation-popup-content.loading {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 25%,
        var(--bg-secondary) 50%,
        var(--bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    color: transparent;
    border-radius: 4px;
    min-height: 60px;
}

/* Citation button hover preview hint */
.citation-btn {
    position: relative;
}

.citation-btn::after {
    content: attr(data-source-preview);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 999;
}

.citation-btn:hover::after {
    opacity: 1;
}

/* Improved color contrast - using themed secondary color */
.source-selector-title,
.source-attribution-popup-header,
.citation-location,
.source-attribution-location {
    color: var(--text-secondary);
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .chat-container {
        height: calc(100vh - 150px);
    }

    .messages {
        padding: 0.75rem;
    }

    .message {
        padding: 1rem;
        margin-left: 0;
        margin-right: 0;
        border-radius: 8px;
    }

    .user-message {
        margin-left: 0.5rem;
    }

    .assistant-message {
        margin-right: 0.5rem;
    }

    .message-text {
        font-size: 0.95rem;
        line-height: 1.65;
    }

    /* Stack message actions vertically on mobile */
    .message-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .feedback-buttons {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
    }

    .consistency-badge {
        margin-left: 0;
    }

    /* Full-width popups on mobile - appear at bottom of screen */
    .citation-wrapper {
        position: static;
    }

    .citation-popup {
        position: fixed;
        left: 1rem;
        right: 1rem;
        bottom: 5rem;
        top: auto;
        max-width: none;
        width: auto;
        margin-top: 0;
        transform: none;
        max-height: 50vh;
        overflow-y: auto;
    }

    /* Hide popup arrows on mobile */
    .citation-popup::before,
    .citation-popup::after {
        display: none;
    }

    .citation-popup.visible {
        animation: mobilePopupSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes mobilePopupSlideUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .citation-popup-content {
        max-height: 35vh;
    }

    /* Hide hover preview on touch devices */
    .citation-btn::after {
        display: none;
    }

    .source-selector-content {
        max-height: none;
    }

    .source-list {
        flex-direction: column;
    }

    .source-item {
        width: 100%;
    }

    .chat-form {
        flex-direction: column;
        gap: 0.5rem;
    }

    .send-button {
        padding: 0.75rem;
    }
}

/* Small mobile adjustments */
@media (max-width: 480px) {
    .message-text h1 { font-size: 1.2rem; }
    .message-text h2 { font-size: 1.1rem; }
    .message-text h3 { font-size: 1rem; }
    .message-text h4 { font-size: 0.95rem; }

    .citation-number {
        min-width: 18px;
        height: 18px;
        font-size: 0.75rem;
    }
}

/* Smooth scrolling for popup content */
.citation-popup-content {
    scroll-behavior: smooth;
}

/* Focus visible for better keyboard navigation */
.citation-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .citation-popup.visible,
    .source-attribution-popup.visible {
        animation: none;
    }

    .citation-btn-loading .citation-number {
        animation: none;
        opacity: 0.7;
    }

    .citation-popup-content.loading {
        animation: none;
    }

    .streaming-indicator {
        animation: none;
        opacity: 0.7;
    }
}

/* ========================================
   Confessional Consistency Styles
   ======================================== */

/* Confession selector (mirrors source selector) */
.confession-selector {
    margin-bottom: 1rem;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.confession-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.confession-selector-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.confession-selector-toggle {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.confession-selector-toggle:hover {
    background-color: rgba(196, 154, 108, 0.15);
}

.confession-selector-content {
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.confession-selector-content.collapsed {
    max-height: 0;
    padding: 0;
    overflow: hidden;
}

.selected-confessions-badge {
    background-color: #6366f1;
    color: white;
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    margin-left: 0.5rem;
}

/* Confession mode icon */
.confession-mode-icon {
    margin-left: 0.5rem;
    font-size: 0.9rem;
    cursor: help;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.confession-mode-icon:hover {
    opacity: 1;
}

.confession-mode-icon.mode-informational {
    color: #60a5fa; /* Blue - info */
}

.confession-mode-icon.mode-advisory {
    color: #fbbf24; /* Amber - warning */
}

.confession-mode-icon.mode-restrictive {
    color: #f87171; /* Red - restrictive */
}

/* Evaluation mode selector */
.evaluation-mode-selector {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.mode-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.mode-select {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
}

.mode-select:focus {
    border-color: var(--accent);
    outline: none;
}

/* Confession groups */
.confession-group {
    margin-bottom: 0.75rem;
}

.confession-group:last-child {
    margin-bottom: 0;
}

.confession-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.group-icon {
    font-size: 1rem;
}

.confession-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Confession item (mirrors source-item) */
.confession-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.4rem 0.6rem;
    background-color: var(--bg-tertiary);
    border-radius: 6px;
    transition: background-color 0.2s, border-color 0.2s;
    border: 1px solid transparent;
    position: relative;
    box-sizing: border-box;
}

.confession-item:hover {
    background-color: var(--bg-primary);
}

.confession-item:has(.confession-checkbox:checked) {
    border-color: #6366f1;
    background-color: rgba(99, 102, 241, 0.1);
}

.confession-checkbox {
    accent-color: #6366f1;
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.confession-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.confession-name {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.confession-info-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    font-size: 0.85rem;
    border-radius: 4px;
    transition: color 0.2s, background-color 0.2s;
    flex-shrink: 0;
}

.confession-info-btn:hover,
.confession-info-btn:focus {
    color: #6366f1;
    background-color: rgba(99, 102, 241, 0.1);
    outline: none;
}

.confession-popup {
    position: fixed;
    z-index: 1000;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 220px;
    max-width: 300px;
    /* Animation triggered via class after positioning */
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.confession-popup.visible {
    opacity: 1;
    transform: scale(1);
}

.confession-popup[hidden] {
    display: none;
    opacity: 0;
    transform: scale(0.95);
}

.no-confessions {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
}

/* Consistency badge */
.consistency-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-left: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid;
}

.consistency-badge:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.consistency-badge.entailed {
    background-color: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.4);
}

.consistency-badge.compatible {
    background-color: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.4);
}

.consistency-badge.tension {
    background-color: rgba(251, 191, 36, 0.15);
    color: #fcd34d;
    border-color: rgba(251, 191, 36, 0.4);
}

.consistency-badge.contradicted {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.4);
}

/* Evaluation popup */
.evaluation-popup {
    position: fixed;
    min-width: 350px;
    max-width: 450px;
    max-height: 400px;
    overflow-y: auto;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    display: none;
}

.evaluation-popup.visible {
    display: block;
    animation: popupSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.evaluation-popup-header {
    position: sticky;
    top: 0;
    background-color: var(--bg-secondary);
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
    font-size: 0.9rem;
}

.evaluation-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.evaluation-item:last-child {
    border-bottom: none;
}

.evaluation-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.evaluation-claim {
    font-size: 0.85rem;
    color: var(--text-primary);
    flex: 1;
    margin-right: 0.5rem;
}

.evaluation-score {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.evaluation-score.entailed {
    background-color: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.evaluation-score.compatible {
    background-color: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.evaluation-score.tension {
    background-color: rgba(251, 191, 36, 0.15);
    color: #fcd34d;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.evaluation-score.contradicted {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.evaluation-confession {
    font-size: 0.75rem;
    color: #6366f1;
    margin-bottom: 0.25rem;
}

.evaluation-explanation {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.evaluation-location {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 0.25rem;
}

/* Link evaluation badge */
.link-evaluation-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-left: 0.5rem;
    border: 1px solid;
    background-color: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border-color: rgba(139, 92, 246, 0.4);
}

.link-evaluation-badge:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.link-evaluation-badge.entailed {
    background-color: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.4);
}

.link-evaluation-badge.compatible {
    background-color: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.4);
}

.link-evaluation-badge.tension {
    background-color: rgba(251, 191, 36, 0.15);
    color: #fcd34d;
    border-color: rgba(251, 191, 36, 0.4);
}

.link-evaluation-badge.contradicted {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.4);
}

/* Link evaluation popup */
.link-evaluation-popup {
    position: fixed;
    min-width: 380px;
    max-width: 500px;
    max-height: 450px;
    overflow-y: auto;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    display: none;
}

.link-evaluation-popup.visible {
    display: block;
    animation: popupSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.link-evaluation-popup-header {
    position: sticky;
    top: 0;
    background-color: var(--bg-secondary);
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
    font-size: 0.9rem;
}

.link-evaluation-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.link-evaluation-item:last-child {
    border-bottom: none;
}

.link-evaluation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.link-evaluation-url {
    font-size: 0.85rem;
    color: #a78bfa;
    text-decoration: none;
    flex: 1;
    word-break: break-all;
}

.link-evaluation-url:hover {
    text-decoration: underline;
}

.link-evaluation-score {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    white-space: nowrap;
}

.link-evaluation-score.entailed {
    background-color: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.link-evaluation-score.compatible {
    background-color: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.link-evaluation-score.tension {
    background-color: rgba(251, 191, 36, 0.15);
    color: #fcd34d;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.link-evaluation-score.contradicted {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.link-evaluation-summary {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.link-evaluation-no-claims {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

.link-evaluation-error-message {
    font-size: 0.8rem;
    color: #f87171;
    font-style: italic;
}

.link-claim-evaluation {
    padding: 0.5rem;
    margin-top: 0.5rem;
    background-color: var(--bg-tertiary);
    border-radius: 6px;
}

.link-claim-text {
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.link-claim-result {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.link-claim-score {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

.link-claim-score.entailed {
    background-color: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.link-claim-score.compatible {
    background-color: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.link-claim-score.tension {
    background-color: rgba(251, 191, 36, 0.15);
    color: #fcd34d;
}

.link-claim-score.contradicted {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.link-claim-confession {
    font-size: 0.75rem;
    color: #6366f1;
}

.link-claim-explanation {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Text evaluation badge (for pasted text) */
.text-evaluation-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    vertical-align: middle;
    margin-left: 0.5rem;
}

.text-evaluation-badge:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.text-evaluation-badge.entailed {
    background-color: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.4);
}

.text-evaluation-badge.compatible {
    background-color: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.4);
}

.text-evaluation-badge.tension {
    background-color: rgba(251, 191, 36, 0.15);
    color: #fcd34d;
    border-color: rgba(251, 191, 36, 0.4);
}

.text-evaluation-badge.contradicted {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.4);
}

.text-evaluation-popup {
    position: fixed;
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    display: none;
}

.text-evaluation-popup.visible {
    display: block;
    animation: popupFadeIn 0.2s ease;
}

.text-evaluation-popup-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
    position: sticky;
    top: 0;
}

.text-evaluation-item {
    padding: 0.75rem 1rem;
}

.text-evaluation-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.text-evaluation-no-claims {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Text Evaluation Results Container (inline in chat response) */
.text-eval-container {
    margin: 1rem 0;
    padding: 0;
}

.text-eval-header {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
}

.text-eval-summary {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    border: 2px solid;
}

.text-eval-summary.entailed {
    background-color: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.4);
}

.text-eval-summary.compatible {
    background-color: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.3);
}

.text-eval-summary.tension {
    background-color: rgba(234, 179, 8, 0.1);
    border-color: rgba(234, 179, 8, 0.4);
}

.text-eval-summary.contradicted {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.4);
}

.text-eval-overall {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.text-eval-overall strong {
    font-weight: 700;
}

.text-eval-counts {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Loading indicator for text evaluation */
.text-eval-loading {
    padding: 1rem;
    color: var(--text-secondary);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.text-eval-loading::before {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.text-eval-loading-inline {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.85rem;
}

/* Collapse arrow for details sections */
.collapse-arrow {
    font-size: 0.65rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
    display: inline-block;
    flex-shrink: 0;
}

details[open] > summary .collapse-arrow {
    transform: rotate(90deg);
}

/* Collapsible claim sections */
.text-eval-claim {
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.text-eval-claim[open] {
    border-color: var(--accent);
}

.text-eval-claim summary {
    padding: 0.75rem 1rem;
    cursor: pointer;
    background-color: var(--bg-tertiary);
    font-size: 0.95rem;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    list-style: none;
    transition: background-color 0.2s;
}

.text-eval-claim summary::-webkit-details-marker {
    display: none;
}

.text-eval-claim summary::marker {
    display: none;
    content: "";
}

.text-eval-claim summary:hover {
    background-color: var(--bg-secondary);
}

.text-eval-claim.entailed summary {
    border-left: 3px solid #22c55e;
}

.text-eval-claim.compatible summary {
    border-left: 3px solid #22c55e;
}

.text-eval-claim.tension summary {
    border-left: 3px solid #eab308;
}

.text-eval-claim.contradicted summary {
    border-left: 3px solid #ef4444;
}

.claim-number {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.claim-details {
    padding: 0.75rem;
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

/* Inner collapsible: Source/confession evaluation */
.text-eval-source {
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.text-eval-source:last-child {
    margin-bottom: 0;
}

.text-eval-source summary {
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    background-color: var(--bg-secondary);
    font-size: 0.9rem;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.text-eval-source summary::-webkit-details-marker {
    display: none;
}

.text-eval-source summary::marker {
    display: none;
    content: "";
}

.text-eval-source summary:hover {
    background-color: var(--bg-tertiary);
}

.text-eval-source.entailed {
    border-left: 3px solid #22c55e;
}

.text-eval-source.compatible {
    border-left: 3px solid #22c55e;
}

.text-eval-source.tension {
    border-left: 3px solid #eab308;
}

.text-eval-source.contradicted {
    border-left: 3px solid #ef4444;
}

.source-details {
    padding: 0.75rem;
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.source-location {
    margin: 0 0 0.5rem 0;
    color: var(--text-secondary);
}

.source-analysis {
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.source-text blockquote {
    margin: 0;
    padding: 0.6rem;
    background-color: var(--bg-tertiary);
    border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0;
    font-style: italic;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Blocked response styling */
.evaluation-blocked-message {
    padding: 1rem;
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    margin-top: 0.5rem;
}

.evaluation-blocked-message strong {
    color: #ef4444;
}

/* Feedback buttons */
.feedback-buttons {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.75rem;
    vertical-align: middle;
    padding: 0.35rem 0.5rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.feedback-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background-color: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.feedback-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background-color: rgba(196, 154, 108, 0.15);
    transform: scale(1.05);
}

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

.feedback-btn.selected {
    border-color: var(--accent);
    background-color: var(--accent);
    color: var(--bg-primary);
}

.feedback-btn.selected.positive {
    background-color: var(--success);
    border-color: var(--success);
}

.feedback-btn.selected.negative {
    background-color: var(--error);
    border-color: var(--error);
    color: white;
}

.feedback-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.feedback-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.feedback-thanks {
    font-size: 0.8rem;
    color: var(--success);
    margin-left: 0.5rem;
    font-weight: 500;
}

/* Mobile responsive for confession selector */
@media (max-width: 768px) {
    .confession-selector-content {
        max-height: none;
    }

    .confession-list {
        flex-direction: column;
    }

    .confession-item {
        width: 100%;
    }

    .evaluation-mode-selector {
        flex-direction: column;
        align-items: flex-start;
    }

    .mode-select {
        max-width: none;
        width: 100%;
    }

    .evaluation-popup {
        position: fixed;
        left: 1rem;
        right: 1rem;
        bottom: 5rem;
        top: auto;
        max-width: none;
        width: auto;
        margin-top: 0;
    }
}

/* ========================================
   Scroll to Bottom Button
   ======================================== */

.scroll-to-bottom-btn {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--accent);
    color: var(--bg-primary);
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    font-weight: bold;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, transform 0.3s, visibility 0.3s, background-color 0.2s;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.scroll-to-bottom-btn:hover {
    background-color: var(--accent-hover);
}

.scroll-to-bottom-btn:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.scroll-to-bottom-btn:active {
    transform: translateX(-50%) scale(0.95);
}

/* Container needs relative positioning for the button */
.chat-container {
    position: relative;
}

/* ========================================
   Theme Toggle
   ======================================== */

.theme-toggle-section {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s, border-color 0.2s;
}

.theme-toggle-btn:hover {
    background-color: var(--accent);
    border-color: var(--accent);
}

.theme-toggle-btn:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.theme-icon {
    font-size: 1.1rem;
    line-height: 1;
}

/* Show/hide appropriate icon based on theme */
.theme-icon-light {
    display: none;
}

.theme-icon-dark {
    display: inline;
}

[data-theme="light"] .theme-icon-light {
    display: inline;
}

[data-theme="light"] .theme-icon-dark {
    display: none;
}

/* Handle system preference when no explicit theme */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .theme-icon-light {
        display: inline;
    }
    :root:not([data-theme]) .theme-icon-dark {
        display: none;
    }
}

.theme-label {
    flex: 1;
    text-align: left;
}

/* ========================================
   Sidebar Responsive Styles
   ======================================== */

/* Tablet: sidebar overlays when expanded */
@media (max-width: 1024px) {
    .chat-main {
        grid-template-columns: 52px 1fr 52px;
    }

    .chat-main[data-sessions-expanded="true"] {
        grid-template-columns: 52px 1fr 52px;
    }

    .sessions-sidebar[data-expanded="true"] {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 100;
        box-shadow: var(--shadow-lg);
    }

    .settings-sidebar[data-expanded="true"] {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 100;
        box-shadow: var(--shadow-lg);
    }

    .sidebar-tooltip {
        display: none;
    }
}

/* Mobile: drawer pattern */
@media (max-width: 768px) {
    .chat-main {
        display: flex;
        flex-direction: column;
        grid-template-columns: none;
    }

    .settings-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 85vw;
        max-width: 320px;
        border-radius: 0;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 200;
        display: flex;
        flex-direction: column;
    }

    .settings-sidebar[data-expanded="true"] {
        transform: translateX(0);
        position: fixed;
        width: 85vw;
        max-width: 320px;
        z-index: 200; /* Override tablet z-index: 100 to stay above backdrop (199) */
    }

    .settings-sidebar[data-expanded="false"] {
        transform: translateX(100%);
    }

    .settings-sidebar .sidebar-toggle {
        flex-shrink: 0;
        border-bottom: 1px solid var(--border-color);
    }

    .settings-sidebar .sidebar-content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-tooltip {
        display: none;
    }

    /* Mobile floating toggle button */
    .mobile-sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 100px;
        right: 1rem;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background-color: var(--accent);
        color: var(--bg-primary);
        border: none;
        box-shadow: var(--shadow-lg);
        cursor: pointer;
        z-index: 100;
        font-size: 1.2rem;
    }

    .mobile-sidebar-toggle:hover {
        background-color: var(--accent-hover);
    }

    .mobile-toggle-badge {
        position: absolute;
        top: -4px;
        right: -4px;
        min-width: 18px;
        height: 18px;
        padding: 0 4px;
        background-color: var(--confession-accent);
        color: white;
        font-size: 0.7rem;
        font-weight: 600;
        border-radius: 9px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-toggle-badge:empty {
        display: none;
    }

    /* Sessions sidebar - mobile drawer pattern (slides from left) */
    .sessions-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 85vw;
        max-width: 320px;
        border-radius: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 200;
        display: flex;
        flex-direction: column;
    }

    .sessions-sidebar[data-expanded="true"] {
        transform: translateX(0);
    }

    .sessions-sidebar[data-expanded="false"] {
        transform: translateX(-100%);
    }

    .sessions-sidebar .sessions-toggle {
        display: none;
    }

    /* Mobile sessions toggle button */
    .mobile-sessions-toggle {
        display: flex;
    }

    /* Backdrop */
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 199;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }

    .sidebar-backdrop.visible {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ========================================
   Loading Skeleton States
   ======================================== */

/* Base skeleton styles */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 0%,
        var(--bg-secondary) 50%,
        var(--bg-tertiary) 100%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Skeleton text line */
.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.skeleton-text:last-child {
    margin-bottom: 0;
    width: 70%;
}

/* Skeleton checkbox row */
.skeleton-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.skeleton-checkbox {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    flex-shrink: 0;
}

.skeleton-label {
    flex: 1;
    height: 1rem;
    border-radius: 4px;
}

.skeleton-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Sessions sidebar skeleton */
.sessions-skeleton {
    padding: 0.5rem;
}

.skeleton-session-item {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.skeleton-session-item:last-child {
    border-bottom: none;
}

/* Source selector skeleton */
.source-skeleton {
    padding: 0.5rem 0;
}

.source-skeleton .skeleton-row {
    padding: 0.4rem 0;
}

/* Confession selector skeleton */
.confession-skeleton {
    padding: 0.5rem 0;
}

.confession-skeleton .skeleton-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    margin-top: 0.5rem;
}

.confession-skeleton .skeleton-group-header:first-child {
    margin-top: 0;
}

.skeleton-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.skeleton-group-title {
    width: 80px;
    height: 0.9rem;
}

/* User selector skeleton */
.user-skeleton {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.skeleton-select {
    height: 36px;
    width: 150px;
    border-radius: 6px;
}

.skeleton-button {
    height: 36px;
    width: 90px;
    border-radius: 6px;
}

/* Message skeleton for loading responses */
.message-skeleton {
    padding: var(--message-padding);
    margin-bottom: var(--message-spacing);
    border-radius: var(--message-border-radius);
    background-color: var(--assistant-bg);
    border-left: 4px solid var(--border-color);
}

.message-skeleton .skeleton-header {
    width: 80px;
    height: 1rem;
    margin-bottom: 1rem;
}

.message-skeleton .skeleton-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message-skeleton .skeleton-line {
    height: 1rem;
    border-radius: 4px;
}

.message-skeleton .skeleton-line:nth-child(1) { width: 100%; }
.message-skeleton .skeleton-line:nth-child(2) { width: 95%; }
.message-skeleton .skeleton-line:nth-child(3) { width: 85%; }
.message-skeleton .skeleton-line:nth-child(4) { width: 60%; }

/* ========================================
   Animation Improvements
   ======================================== */

/* Sidebar expand/collapse animation */
.settings-sidebar {
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-content {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.settings-sidebar[data-expanded="false"] .sidebar-content {
    opacity: 0;
    transform: translateX(10px);
}

.settings-sidebar[data-expanded="true"] .sidebar-content {
    opacity: 1;
    /* Don't use transform here - it creates a containing block that breaks fixed-position popups */
    transform: none;
}

/* Button press feedback */
button:active:not(:disabled) {
    transform: scale(0.97);
}

/* Checkbox and input transitions */
input[type="checkbox"] {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

input[type="checkbox"]:checked {
    transform: scale(1.05);
}

input[type="checkbox"]:focus {
    box-shadow: 0 0 0 2px var(--accent);
}

/* Select dropdown transitions */
select {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(196, 154, 108, 0.2);
}

/* Badge pulse animation for new items */
@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.selected-sources-badge,
.selected-confessions-badge {
    transition: transform 0.2s ease, background-color 0.2s ease;
}

/* Error message animation */
.error {
    animation: errorShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

/* ========================================
   Reduced Motion Support
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .message {
        animation: none;
    }

    .source-popup,
    .confession-popup,
    .citation-popup {
        animation: none;
    }

    .streaming-indicator {
        animation: none;
        opacity: 1;
    }

    .scroll-to-bottom-btn {
        transition: none;
    }

    .settings-sidebar {
        transition: none;
    }

    .sidebar-content {
        transition: none;
    }

    .error {
        animation: none;
    }
}

/* =============================================================== */
/* AG-UI generative-UI cards (issue #92)                           */
/* -------------------------------------------------------------- */
/* Server-rendered cards populated by the AG-UI HTMX bridge.       */
/* Answer-prominent redesign: retrieved_context sources ride the   */
/* answer footer (.msg-sources-cards) and confessional_evaluations */
/* render as a per-answer summary (.msg-eval-cards); only          */
/* #suggestions-row remains a standalone panel. Decision 5: reuse  */
/* existing badge color tokens                                     */
/* (.consistency-badge.{entailed,compatible,tension,contradicted}, */
/* etc.) — only layout-level rules are new.                        */
/* =============================================================== */

/* Source card — layout only; reuses existing tokens. */
.source-card {
    background: var(--surface-1, #fff);
    border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.1));
    border-radius: 8px;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.source-card-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.source-card-name {
    font-weight: 600;
}

.source-card-location {
    color: var(--text-secondary, #555);
    font-size: 0.85rem;
}

.source-card-content {
    margin: 0.25rem 0;
    line-height: 1.45;
    color: var(--text-primary, #222);
}

.source-card-footer {
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Verification badge — reuse the same hues as .consistency-badge so the */
/* visual language is consistent between confessional and source signals. */
.verification-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.verification-badge.verified {
    background-color: rgba(34, 197, 94, 0.15);
    color: rgb(21, 128, 61);
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.verification-badge.tampered {
    background-color: rgba(239, 68, 68, 0.15);
    color: rgb(153, 27, 27);
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.verification-badge.unverified {
    background-color: rgba(156, 163, 175, 0.15);
    color: rgb(75, 85, 99);
    border: 1px solid rgba(156, 163, 175, 0.4);
}

/* Evaluation card — same layout family as .source-card. */
.evaluation-card {
    background: var(--surface-1, #fff);
    border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.1));
    border-radius: 8px;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.evaluation-card-header {
    margin-bottom: 0.4rem;
}

.evaluation-card-claim {
    margin: 0 0 0.25rem 0;
    font-weight: 500;
    line-height: 1.4;
}

.evaluation-card-confession {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary, #555);
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.evaluation-card-confession-location {
    font-style: italic;
}

.evaluation-card-scores {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
}

.confidence-meter {
    flex: 0 0 8rem;
    height: 0.6rem;
}

.evaluation-card-explanation {
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.evaluation-card-explanation > summary {
    cursor: pointer;
    color: var(--text-secondary, #555);
    font-weight: 500;
    list-style: revert;
}

.evaluation-card-explanation > p {
    margin: 0.4rem 0 0 0;
    line-height: 1.45;
}

/* Suggestion chips — render as a horizontally-scrolling row above */
/* the chat input. Each chip is a real <button> so it is keyboard-  */
/* activatable; the hx-post handler is JS-driven (AC-4).            */
.suggestions-row {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.4rem 0;
    margin: 0.25rem 0;
}

.suggestions-row-empty {
    display: none;
}

.suggestion-chip {
    flex: 0 0 auto;
    background: var(--surface-2, #f3f4f6);
    border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.1));
    border-radius: 999px;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    color: var(--text-primary, #222);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.suggestion-chip:hover {
    background: var(--surface-3, #e5e7eb);
    border-color: var(--border-medium, rgba(0, 0, 0, 0.2));
}

.suggestion-chip:focus-visible {
    outline: 2px solid var(--focus-ring, #2563eb);
    outline-offset: 2px;
}

/* ============================================================
   Answer-prominent redesign — sources popup + inline pill hover
   ============================================================ */

/* "Sources (N)" trigger that sits below the answer. */
.sources-bar {
    margin: 0.5rem 0 0;
}
.sources-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    background: rgba(99, 102, 241, 0.12);
    color: var(--confession-accent, #6366f1);
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
}
.sources-trigger:hover {
    border-color: var(--confession-accent, #6366f1);
}
.sources-trigger.hidden {
    display: none;
}
.sources-trigger-count {
    background: var(--confession-accent, #6366f1);
    color: #fff;
    border-radius: 999px;
    min-width: 1.1rem;
    height: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    padding: 0 0.3rem;
}

/* Sources popup — fixed modal overlay. */
.sources-popup {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(20, 30, 45, 0.4);
}
.sources-popup[hidden] {
    display: none;
}
.sources-popup-sheet {
    width: min(560px, 100%);
    max-height: 80vh;
    overflow: auto;
    background: var(--bg-primary, #fff);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}
.sources-popup-header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary, #fff);
}
.sources-popup-header h3 {
    margin: 0;
    font-size: 1rem;
}
.sources-popup-close {
    border: none;
    background: none;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--text-secondary, #555);
    cursor: pointer;
}
.sources-popup-body {
    padding: 1rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.sources-popup-body:empty::after {
    content: "No sources cited for this answer.";
    color: var(--text-secondary, #777);
    font-size: 0.85rem;
}

/* Inline citation pills reveal their source on hover (answer redesign).
   The popup is click-toggled (.visible) for touch/pinning AND shown on
   hover here; the more-specific selector beats the [hidden] attribute. */
.citation-wrapper:hover .citation-popup {
    display: block;
}

/* Per-answer sources footer (answer-prominent redesign): each assistant
   bubble carries its own "Sources (N)" trigger + a hidden card store. */
/* Per-answer action row: "Sources (N)" + "Confessional check" pills sit
   side by side beneath the answer. The eval slot is OOB-filled later, so
   the row owns the spacing and each pill drops its own top margin. */
.message-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.6rem;
}
.message-actions .message-sources,
.message-actions .message-evaluation {
    margin-top: 0;
}
.message-sources {
    margin-top: 0.6rem;
}
.msg-sources-cards[hidden] {
    display: none;
}
/* A clicked citation pins its popup open with the retrieved chunk, which
   can be long — cap the body and let it scroll. */
.citation-popup-content {
    max-height: 14rem;
    overflow-y: auto;
}

/* Citation popup: flip ABOVE the pill when there isn't room below, so the
   chunk isn't cut off at the bottom of the pane. The flip class is toggled
   by positionCitationPopup() in chat.html (hover + click). */
.citation-popup.citation-popup--up {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 10px;
}
.citation-popup.citation-popup--up::before {
    top: auto;
    bottom: -8px;
    border-bottom: none;
    border-top: 8px solid var(--border-color);
}
.citation-popup.citation-popup--up::after {
    top: auto;
    bottom: -6px;
    border-bottom: none;
    border-top: 7px solid var(--bg-tertiary);
}
/* Header now carries source + location + a verification badge: let it wrap
   and pin the badge to the right edge. */
.citation-popup-header {
    flex-wrap: wrap;
    gap: 0.4rem;
}
.citation-popup-header .verification-badge {
    margin-left: auto;
}

/* ============================================================
   AG-UI status pill (issue #91): live run/tool progress. The bridge
   OOB-swaps status.html / tool-call-*.html into #agui-status-pill. It had
   no styles, so progress was invisible — add a small pill with a pulsing
   dot, shown only while running (idle/empty collapses).
   ============================================================ */
.agui-status-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: fit-content;
    max-width: 100%;
    margin: 0 0 0.5rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--confession-accent, #6366f1);
    font-size: 0.85rem;
    font-weight: 500;
}
/* Idle (run finished / no message) collapses so it takes no space. */
.agui-status-pill.agui-status-idle {
    display: none;
}
.agui-status-icon {
    font-size: 0.55rem;
    line-height: 1;
    animation: aguiStatusPulse 1.1s ease-in-out infinite;
}
@keyframes aguiStatusPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}
.agui-status-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Per-answer confessional evaluation summary (AG-UI): a compact "Confessional
   check" trigger with the overall consistency badge; clicking opens the
   shared #evaluation-popup with the full evaluation cards. */
.message-evaluation {
    margin-top: 0.5rem;
}
.message-evaluation:empty {
    display: none;
}
.evaluation-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    cursor: pointer;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary, #1d2530);
}
.evaluation-trigger:hover {
    border-color: var(--confession-accent, #6366f1);
}
.evaluation-trigger-count {
    background: var(--confession-accent, #6366f1);
    color: #fff;
    border-radius: 999px;
    min-width: 1.1rem;
    height: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    padding: 0 0.3rem;
}
.msg-eval-cards[hidden] {
    display: none;
}
