/**
 * Sessions Styles
 * Patient-Centered Health Workspace
 */

/* ============================================
   Sessions Container
   ============================================ */

.sessions-container {
    width: 100%;
    margin: 0 auto;
    padding: 24px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.sessions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 16px;
}

.sessions-header h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.sessions-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0 0 24px 0;
}

.sessions-header-actions {
    display: flex;
    gap: 12px;
}

/* ============================================
   Sessions Buttons
   ============================================ */

.sessions-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    min-height: 44px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.sessions-btn-primary {
    background: var(--accent-primary);
    color: var(--text-on-accent);
}

.sessions-btn-primary:hover {
    background: var(--accent-primary-hover, #0d9488);
    transform: translateY(-1px);
}

.sessions-btn-secondary {
    background: var(--surface-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.sessions-btn-secondary:hover {
    background: var(--surface-secondary);
    border-color: var(--accent-primary);
}

.sessions-btn-danger {
    background: #dc2626;
    color: var(--text-on-accent);
}

.sessions-btn-danger:hover {
    background: #b91c1c;
}

/* ============================================
   Sessions Filter/Search
   ============================================ */

.sessions-filter {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.sessions-search {
    flex: 1;
    min-width: 200px;
    padding: 10px 16px;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    font-size: 14px;
    background: var(--surface-primary);
    color: var(--text-primary);
}

.sessions-search:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.sessions-status-filter {
    padding: 10px 16px;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    font-size: 14px;
    background: var(--surface-primary);
    color: var(--text-primary);
    cursor: pointer;
}

/* ============================================
   Sessions List
   ============================================ */

.sessions-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 16px;
}

@media (max-width: 768px) {
    .sessions-list {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Session Card
   ============================================ */

.session-card {
    background: var(--surface-primary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.session-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.session-card.status-archived {
    opacity: 0.7;
    background: var(--surface-secondary);
}

.session-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.session-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.session-card-status {
    font-size: 14px;
}

.session-card-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0 0 12px 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.session-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.session-card-meta-item {
    font-size: 13px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.session-card-actions {
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border-secondary);
    padding-top: 12px;
    margin-top: 4px;
}

.session-card-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-primary);
    background: var(--surface-primary);
    color: var(--text-primary);
}

.session-card-btn:hover {
    background: var(--surface-secondary);
    border-color: var(--accent-primary);
}

.session-open-btn {
    flex: 1;
    background: var(--accent-primary);
    color: var(--text-on-accent);
    border-color: var(--accent-primary);
}

.session-open-btn:hover {
    background: var(--accent-primary-hover, #0d9488);
}

.session-menu-btn {
    width: 36px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Session Dropdown Menu
   ============================================ */

.session-dropdown-menu {
    background: var(--surface-primary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    overflow: hidden;
}

.session-dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    font-size: 14px;
    color: var(--text-primary);
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.session-dropdown-item:hover {
    background: var(--surface-secondary);
}

.session-dropdown-danger {
    color: #dc2626;
}

.session-dropdown-danger:hover {
    background: #fef2f2;
}

/* ============================================
   Empty State
   ============================================ */

.sessions-empty {
    text-align: center;
    padding: 60px 20px;
    background: var(--surface-secondary);
    border-radius: 12px;
    border: 2px dashed var(--border-primary);
}

.sessions-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.sessions-empty-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.sessions-empty-text {
    color: var(--text-secondary);
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto 20px;
    line-height: 1.5;
}

/* ============================================
   Loading State
   ============================================ */

.sessions-loading {
    text-align: center;
    padding: 60px 20px;
}

.sessions-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-primary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Session Detail View
   ============================================ */

.session-detail-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.session-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--surface-primary);
    border-bottom: 1px solid var(--border-primary);
    flex-wrap: nowrap;
    flex-shrink: 0;
    min-height: 52px;
}

.session-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    font-size: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.session-back-btn:hover {
    background: var(--surface-secondary);
    color: var(--text-primary);
    border-color: var(--border-secondary);
}

.session-detail-info {
    flex: 1;
    min-width: 0;
}

.session-detail-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-detail-badges {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    margin-top: 2px;
}

.session-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.01em;
    opacity: 0.85;
}

.session-badge.status-active {
    background: #dcfce7;
    color: #166534;
}

.session-badge.status-archived {
    background: #f3f4f6;
    color: #6b7280;
}

.session-badge.emr-badge {
    background: #dbeafe;
    color: #1e40af;
}

/* Session title with dropdown for rename/delete */
.session-detail-title {
    display: flex;
    align-items: center;
    gap: 4px;
}

.session-title-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-title-dropdown {
    display: none;
    border: none;
    background: transparent;
    color: var(--text-tertiary, #9ca3af);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: inherit;
    flex-shrink: 0;
    transition: all .12s;
}

.session-title-dropdown:hover {
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-primary, #1f2937);
}

/* Always show dropdown on mobile, show on hover on desktop */
@media (max-width: 1024px) {
    .session-title-dropdown { display: inline-flex; }
}
@media (min-width: 1025px) {
    .session-detail-title:hover .session-title-dropdown { display: inline-flex; }
}

.session-detail-actions {
    display: flex;
    gap: 8px;
    position: relative;
}

/* "..." More menu dropdown */
.session-more-btn {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 2px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.session-more-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 50;
    background: #fff;
    border: 1px solid var(--g200, #e5e7eb);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    min-width: 180px;
    padding: 4px 0;
    margin-top: 4px;
}

.session-more-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 14px;
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--g700, #374151);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: background .12s;
}

.session-more-item:hover {
    background: var(--g50, #f9fafb);
}

.session-detail-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0 0 16px 0;
    padding: 12px;
    background: var(--surface-secondary);
    border-radius: 8px;
}

/* ============================================
   Chat Container
   ============================================ */

.session-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f7f8fa;
    border-radius: 0;
    overflow: hidden;
    min-height: 0;
}

.session-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.session-messages-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-align: center;
}

.session-messages-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.session-messages-empty-text {
    font-size: 14px;
}

/* ============================================
   Messages
   ============================================ */

.session-message {
    max-width: 78%;
    animation: msgIn 0.2s ease;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* User bubble — compact, right-aligned, subtle */
.session-message-user {
    align-self: flex-end;
    background: #1e293b;
    color: #f8fafc;
    border-radius: 18px 18px 4px 18px;
    padding: 10px 16px;
    font-size: 16px;
    line-height: 1.55;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    margin-bottom: 10px;
}

/* Assistant card — full-width-ish, white, clean */
.session-message-assistant {
    align-self: flex-start;
    max-width: 88%;
    background: #ffffff;
    color: var(--text-primary);
    border-radius: 4px 18px 18px 18px;
    padding: 14px 18px 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.04);
    margin-bottom: 16px;
}

.session-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 11px;
    letter-spacing: 0.01em;
}

.session-message-user .session-message-header {
    color: rgba(255, 255, 255, 0.55);
}

.session-message-assistant .session-message-header {
    color: var(--text-tertiary);
}

.session-message-role {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.75;
}

.session-message-content {
    font-size: 16px;
    line-height: 1.7;
    word-break: break-word;
}

/* User messages don't need a header at all */
.session-message-user .session-message-header {
    display: none;
}

.session-message-content code {
    background: #f1f5f9;
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
    border: 1px solid #e2e8f0;
}

.session-message-user .session-message-content code {
    background: rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
    border-color: rgba(255,255,255,0.15);
}

.session-message-tools {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
    font-size: 11.5px;
    color: var(--text-tertiary);
}

/* ============================================
   Input Container
   ============================================ */

/* ── Input area ─────────────────────────────────────────────────────────── */
.session-input-container {
    padding: 10px 14px 14px;
    background: #f7f8fa;
    flex-shrink: 0;
}

/* The pill — border lives here so it grows with the textarea */
.session-input-pill {
    display: flex;
    align-items: flex-end;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 26px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 6px 6px 6px 4px;
    transition: border-color 0.2s, box-shadow 0.2s;
    gap: 2px;
}

.session-input-pill:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 2px 14px rgba(13,148,136,0.13);
}

.session-attach-btn {
    flex-shrink: 0;
    align-self: flex-end;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    margin-bottom: 1px;
}

.session-attach-btn:hover {
    color: var(--accent-primary);
    background: rgba(13,148,136,0.07);
}

.session-input {
    flex: 1;
    padding: 8px 4px 8px 6px;
    border: none;
    border-radius: 0;
    font-size: 16px;
    line-height: 1.55;
    resize: none;
    font-family: inherit;
    background: transparent;
    color: var(--text-primary);
    /* Single line by default; JS sets height on input */
    height: 38px;
    min-height: 38px;
    max-height: 200px;
    overflow-y: auto;
    /* Hide scrollbar — content still scrollable */
    scrollbar-width: none;
}
.session-input::-webkit-scrollbar { display: none; }

.session-input:focus {
    outline: none;
    box-shadow: none;
}

.session-input::placeholder {
    color: #94a3b8;
}

.session-send-btn {
    flex-shrink: 0;
    align-self: flex-end;
    width: 34px;
    height: 34px;
    padding: 0;
    margin-bottom: 1px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-primary);
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.session-send-btn:hover:not(:disabled) {
    background: var(--accent-hover, #0f766e);
    transform: scale(1.05);
}

.session-send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.send-label { display: none; }
.send-icon  { display: block; font-size: 15px; }

/* Regenerate button — shown when response was interrupted */
.session-regen-container {
    display: flex; justify-content: center; padding: 12px 16px;
}
.session-regen-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: 24px;
    border: 1px solid rgba(13,148,136,0.3);
    background: linear-gradient(135deg, rgba(13,148,136,0.05), rgba(20,184,166,0.1));
    color: #0d7377; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all .2s ease;
    font-family: inherit;
}
.session-regen-btn:hover {
    background: linear-gradient(135deg, rgba(13,148,136,0.1), rgba(20,184,166,0.18));
    border-color: rgba(13,148,136,0.5);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(13,148,136,0.15);
}
.session-regen-btn:active { transform: translateY(0); }
.session-regen-btn svg { color: #14b8a6; flex-shrink: 0; }

/* Paperclip attach button — hidden on desktop, shown on mobile via media query */
.session-attach-btn {
    display: none;
}

/* ============================================
   Modal Form Styles
   ============================================ */

.session-modal-form {
    padding: 8px 0;
}

.session-form-group {
    margin-bottom: 16px;
}

.session-form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.session-form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--surface-primary);
    color: var(--text-primary);
    box-sizing: border-box;
}

.session-form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.session-form-divider {
    height: 1px;
    background: var(--border-primary);
    margin: 24px 0;
}

.session-danger-zone {
    padding: 16px;
    background: #fef2f2;
    border-radius: 8px;
    border: 1px solid #fecaca;
}

.session-danger-zone label {
    color: #dc2626;
    margin-bottom: 12px;
}

.session-warning-text {
    color: #dc2626;
    font-size: 14px;
    margin-top: 8px;
}

/* ============================================
   EMR Panel (Increment 2)
   ============================================ */

.session-emr-panel {
    margin-bottom: 16px;
    border-radius: 8px;
    overflow: hidden;
}

.emr-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.emr-panel-toggle-icon {
    font-size: 12px;
    opacity: 0.6;
}

.emr-disabled-panel {
    background: var(--surface-secondary);
    border: 1px solid var(--border-primary);
}

.emr-disabled-panel .emr-panel-header {
    color: var(--text-tertiary);
    cursor: default;
}

.emr-empty-panel {
    background: #fefce8;
    border: 1px solid #fef08a;
}

.emr-empty-panel .emr-panel-header {
    color: #a16207;
}

.emr-panel-message {
    padding: 0 16px 12px;
    margin: 0;
    font-size: 13px;
    color: #a16207;
}

.emr-active-panel {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.emr-active-panel .emr-panel-header {
    color: #166534;
}

.emr-panel-content {
    padding: 0 16px 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.emr-overview {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--text-tertiary);
    font-size: 12px;
}

.emr-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.emr-category-tag {
    display: inline-block;
    padding: 3px 8px;
    background: #dcfce7;
    color: #166534;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.emr-highlight {
    padding: 6px 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.emr-highlight strong {
    color: var(--text-primary);
}

.emr-allergy {
    color: #dc2626;
}

.emr-allergy strong {
    color: #dc2626;
}

.emr-enable-btn {
    padding: 4px 12px;
    background: var(--accent-primary);
    color: var(--text-on-accent);
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.emr-enable-btn:hover {
    background: var(--accent-primary-hover, #0d9488);
}

/* EMR Badge Variants */

.session-badge.emr-has-data {
    background: #dcfce7;
    color: #166534;
}

.session-badge.emr-no-data {
    background: #fef3c7;
    color: #92400e;
}

.session-badge.emr-disabled {
    background: #f3f4f6;
    color: #6b7280;
}

/* ============================================
   Session Main Layout (Chat + Sidebar)
   ============================================ */

.session-main-layout {
    display: flex;
    gap: 16px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative; /* anchor for floating session-info panel */
}

.session-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.session-main-content .session-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ============================================
   Session Resources Sidebar
   ============================================ */

.session-resources-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--bg-secondary, #f9fafb);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 12px 14px;
    background: var(--bg-tertiary, #f3f4f6);
    border-bottom: 1px solid var(--border-light, #e5e7eb);
}

.sidebar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
}

/* Simplified sidebar status line */
.sidebar-status {
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
    padding: 2px 0;
}

.sidebar-status-ok {
    color: var(--color-green-700, #065f46);
}

/* Document type labels in sidebar and attachment modal */
.sidebar-doc-type {
    font-size: 10px;
    color: var(--text-tertiary, #9ca3af);
    flex-shrink: 0;
}

.attachment-source-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 500;
    margin-right: 4px;
}

.attachment-source-emr {
    background: #dbeafe;
    color: #1e40af;
}

.attachment-source-lib {
    background: #f3e8ff;
    color: #6b21a8;
}

.sidebar-section {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
}

.sidebar-section:last-child {
    border-bottom: none;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.sidebar-section-icon {
    font-size: 14px;
}

.sidebar-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
    flex: 1;
}

.sidebar-section-count {
    font-size: 12px;
    background: var(--bg-tertiary, #e5e7eb);
    color: var(--text-secondary, #6b7280);
    padding: 1px 6px;
    border-radius: 8px;
}

.sidebar-add-btn {
    padding: 2px 8px;
    background: var(--primary-color, #0d9488);
    color: var(--text-on-accent);
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.sidebar-add-btn:hover {
    background: var(--primary-hover, #1d4ed8);
}

/* EMR Toggle Section */
.emr-toggle-section .sidebar-section-header {
    margin-bottom: 6px;
}

.emr-status-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 20px;
}

.emr-status-badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 8px;
}

.emr-status-badge.active {
    background: #dcfce7;
    color: #166534;
}

.emr-status-badge.empty {
    background: #fef3c7;
    color: #92400e;
}

.emr-status-count {
    font-size: 12px;
    color: var(--text-tertiary, #9ca3af);
}

.emr-disabled-hint {
    font-size: 12px;
    color: var(--text-tertiary, #9ca3af);
    font-style: italic;
}

/* EMR Categories List in Sidebar */
.emr-categories-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
    padding-left: 4px;
}

.emr-category-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background: #dcfce7;
    border-radius: 4px;
    font-size: 12px;
}

.emr-category-label {
    color: #166534;
    font-weight: 500;
}

.emr-category-value {
    color: #166534;
    opacity: 0.7;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 20px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: var(--surface-primary);
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #22c55e;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

/* Documents List */
.sidebar-section-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    flex: 1;
}

.sidebar-doc-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--surface-primary);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 4px;
    font-size: 12px;
}

.sidebar-doc-item:hover {
    border-color: var(--primary-color, #0d9488);
}

.sidebar-doc-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary, #1f2937);
}

.sidebar-doc-remove {
    padding: 2px 4px;
    background: transparent;
    color: var(--text-tertiary, #9ca3af);
    border: none;
    font-size: 12px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s, color 0.2s;
}

.sidebar-doc-remove:hover {
    opacity: 1;
    color: #dc2626;
}

/* Sidebar Empty State */
.sidebar-empty {
    padding: 16px 8px;
    text-align: center;
    color: var(--text-tertiary, #9ca3af);
    font-size: 12px;
}

.sidebar-empty p {
    margin: 0 0 8px 0;
}

.sidebar-add-link {
    background: none;
    border: none;
    color: var(--primary-color, #0d9488);
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
}

.sidebar-add-link:hover {
    color: var(--primary-hover, #1d4ed8);
}

/* ═══════════════════════════════════════════════════════════════
   Agents & Tools section in Session Info sidebar
   ═══════════════════════════════════════════════════════════════ */

.sidebar-agents-toggle {
    cursor: pointer;
    user-select: none;
}
.sidebar-agents-toggle:hover {
    background: var(--surface-secondary, #f9fafb);
}
.sidebar-chevron {
    margin-left: auto;
    font-size: 12px;
    color: var(--color-gray-400, #9ca3af);
    transition: transform .15s;
}
.sidebar-section-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-gray-500, #6b7280);
    background: var(--surface-secondary, #f3f4f6);
    border-radius: 10px;
    padding: 1px 7px;
    margin-left: 6px;
}
.sidebar-agents-content {
    padding: 4px 0 4px 4px;
}
.sidebar-agent-item {
    padding: 6px 8px;
    border-radius: 6px;
    margin-bottom: 4px;
}
.sidebar-agent-item:hover {
    background: var(--surface-secondary, #f9fafb);
}
.sidebar-agent-lead {
    border-left: 2px solid var(--primary-color, #0d9488);
    background: var(--surface-secondary, #f9fafb);
}
.sidebar-agent-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary, #111827);
}
.sidebar-agent-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-agent-lead-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--primary-color, #0d9488);
    background: rgba(13, 148, 136, 0.1);
    border-radius: 4px;
    padding: 1px 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.sidebar-agent-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 0 0 24px;
}
.sidebar-tool-chip {
    font-size: 11px;
    font-family: 'SF Mono', 'Menlo', monospace;
    color: var(--color-gray-600, #4b5563);
    background: var(--surface-primary, #fff);
    border: 1px solid var(--color-gray-200, #e5e7eb);
    border-radius: 4px;
    padding: 1px 6px;
}

/* ── Session Info button (ⓘ) — shown only at narrow widths ─────────────── */
.session-info-btn {
    display: none; /* hidden above 1333px */
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    font-size: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.session-info-btn:hover {
    background: var(--surface-secondary);
    color: var(--text-primary);
    border-color: var(--border-secondary);
}

/* At ≤1333px: hide inline sidebar, show info button */
@media (max-width: 1333px) {
    .session-info-btn { display: flex; }

    .session-resources-sidebar {
        display: none;
        /* When opened via ⓘ button, float over canvas */
        position: absolute;
        top: 52px; /* below session header */
        right: 12px;
        width: 272px;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        z-index: 200;
        border-radius: 10px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.14);
        background: var(--surface-primary, #fff);
    }

    .session-resources-sidebar.session-info-floating-open {
        display: flex;
    }
}

/* Responsive: stack on very small screens */
@media (max-width: 900px) {
    .session-main-layout {
        flex-direction: column;
        height: auto;
    }
}

/* ============================================
   Toggle Switch
   ============================================ */

.session-emr-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--surface-primary);
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.session-form-help {
    font-size: 12px;
    color: var(--text-tertiary);
    margin: 8px 0 0;
}

/* ============================================
   Agent Badge & Notice (Increment 3)
   ============================================ */

.session-badge.agent-badge {
    background: #e0e7ff;
    color: #3730a3;
}

.session-badge.agent-none {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px dashed #d1d5db;
}

/* Orchestration Mode Toggle (Increment 4.5) */
.orchestration-toggle {
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: inherit;
}

.orchestration-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.orchestration-toggle:active {
    transform: translateY(0);
}

.orchestration-toggle.orchestration-auto {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-on-accent);
}

.orchestration-toggle.orchestration-manual {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.orchestration-toggle.orchestration-auto:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

.orchestration-toggle.orchestration-manual:hover {
    background: #e5e7eb;
}

.session-no-agent-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #92400e;
}

/* ============================================
   Thinking Indicator (Loading State)
   ============================================ */

.session-message-thinking {
    background: var(--surface-primary);
    border: 1px solid var(--border-primary);
}

.session-message-thinking .session-message-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: thinking-bounce 1.4s infinite ease-in-out;
}

.thinking-dots span:nth-child(1) {
    animation-delay: 0s;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinking-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.thinking-text {
    color: var(--text-tertiary);
    font-size: 13px;
    font-style: italic;
}

/* ============================================
   Message Tools Display
   ============================================ */

.session-message-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border-secondary);
    font-size: 12px;
}

.session-message-tools .tools-icon {
    font-size: 14px;
}

.session-message-tools .tools-label {
    color: var(--text-tertiary);
}

.session-message-tools .tools-list {
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================================
   Message Sources/Citations
   ============================================ */

.session-message-sources {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-secondary);
    font-size: 13px;
}

.sources-header {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.15s;
    user-select: none;
}

.sources-header:hover {
    background: var(--surface-secondary);
}

.sources-icon {
    font-size: 14px;
}

.sources-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.sources-toggle {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-left: auto;
    transition: transform 0.2s;
}

.session-message-sources.expanded .sources-toggle {
    transform: rotate(90deg);
}

.sources-list {
    display: none;
    margin: 8px 0 0 0;
    padding-left: 24px;
    font-size: 12px;
    line-height: 1.6;
}

.session-message-sources.expanded .sources-list,
.session-message-sources.sources-expanded .sources-list {
    display: block;
}

.session-message-sources.sources-expanded .sources-toggle {
    transform: rotate(90deg);
}

.sources-list li {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.sources-list li:last-child {
    margin-bottom: 0;
}

.sources-list a {
    color: var(--accent-primary);
    text-decoration: none;
    word-break: break-word;
}

.sources-list a:hover {
    text-decoration: underline;
}

/* ============================================
   Deeper Dive Section (Increment 3.6)
   Hierarchical memory detailed content
   ============================================ */

.session-message-deeper-dive {
    margin-top: 12px;
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-primary);
}

.deeper-dive-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--surface-secondary);
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.deeper-dive-header:hover {
    background: var(--surface-tertiary, rgba(0, 0, 0, 0.05));
}

.deeper-dive-icon {
    font-size: 16px;
}

.deeper-dive-label {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
}

.deeper-dive-stats {
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 400;
}

.deeper-dive-toggle {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-left: auto;
    transition: transform 0.2s;
}

.session-message-deeper-dive.expanded .deeper-dive-toggle {
    transform: rotate(90deg);
}

.deeper-dive-content {
    display: none;
    padding: 16px;
    border-top: 1px solid var(--border-secondary);
    max-height: 500px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.7;
}

.session-message-deeper-dive.expanded .deeper-dive-content {
    display: block;
}

/* Deeper Dive content formatting */
.deeper-dive-content h1,
.deeper-dive-content h2,
.deeper-dive-content h3 {
    margin-top: 16px;
    margin-bottom: 8px;
}

.deeper-dive-content h1:first-child,
.deeper-dive-content h2:first-child,
.deeper-dive-content h3:first-child {
    margin-top: 0;
}

.deeper-dive-content ul,
.deeper-dive-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.deeper-dive-content p {
    margin: 8px 0;
}

.deeper-dive-content code {
    background: var(--surface-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.deeper-dive-content blockquote {
    margin: 12px 0;
    padding: 12px 16px;
    border-left: 3px solid var(--accent-primary);
    background: var(--surface-secondary);
    font-style: italic;
}

/* ============================================
   V2 Pipeline: Detailed View (Phase 4)
   ============================================ */

.session-message-detailed-view {
    margin-top: 12px;
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-primary);
}

.detailed-view-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--surface-secondary);
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.detailed-view-header:hover {
    background: var(--surface-tertiary, rgba(0, 0, 0, 0.05));
}

.detailed-view-icon {
    font-size: 16px;
}

.detailed-view-label {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
}

.detailed-view-toggle {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-left: auto;
    transition: transform 0.2s;
}

.session-message-detailed-view.expanded .detailed-view-toggle {
    transform: rotate(90deg);
}

.detailed-view-content {
    display: none;
    padding: 16px;
    border-top: 1px solid var(--border-secondary);
    max-height: 600px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.7;
}

.session-message-detailed-view.expanded .detailed-view-content {
    display: block;
}

.detailed-view-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-secondary);
}

.detailed-view-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.detailed-view-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.detailed-view-source {
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 400;
}

.detailed-view-section-content {
    font-size: 13px;
    line-height: 1.6;
}

.detailed-view-section-content h1,
.detailed-view-section-content h2,
.detailed-view-section-content h3 {
    margin-top: 12px;
    margin-bottom: 6px;
}

.detailed-view-section-content h1:first-child,
.detailed-view-section-content h2:first-child,
.detailed-view-section-content h3:first-child {
    margin-top: 0;
}

.detailed-view-section-content ul,
.detailed-view-section-content ol {
    margin: 6px 0;
    padding-left: 24px;
}

.detailed-view-section-content p {
    margin: 6px 0;
}

/* V2 Pipeline: Enrichment Section (Parallel Routing - Deeper Analysis) */
.session-message-enrichment {
    margin-top: 12px;
    border: 1px solid rgba(124, 77, 255, 0.25);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-primary);
}

.enrichment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(124, 77, 255, 0.06);
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.enrichment-header:hover {
    background: rgba(124, 77, 255, 0.12);
}

.enrichment-icon {
    font-size: 16px;
}

.enrichment-label {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
}

.enrichment-toggle {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-left: auto;
    transition: transform 0.2s;
}

.session-message-enrichment.expanded .enrichment-toggle {
    transform: rotate(90deg);
}

.enrichment-content {
    display: none;
    padding: 16px;
    border-top: 1px solid rgba(124, 77, 255, 0.15);
    max-height: 600px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.7;
}

.session-message-enrichment.expanded .enrichment-content {
    display: block;
}

.enrichment-response {
    margin-bottom: 12px;
}

/* DEBUG: routing strip — hidden, preserved for future diagnostics */
.dbg-routing-strip { display: none; }
.dbg-model { font-weight: 700; color: #6366f1; }
.dbg-path  { color: #0891b2; }
.dbg-sep   { color: var(--text-tertiary); opacity: 0.5; }
.dbg-reason { color: var(--text-tertiary); font-style: italic; }

/* Enrichment pending indicator — shows while Sonnet processes in background */
.enrichment-pending-indicator {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.enrichment-pending-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #818cf8;
    flex-shrink: 0;
    animation: enrichment-pulse 1.4s ease-in-out infinite;
}

@keyframes enrichment-pulse {
    0%, 100% { opacity: 0.35; transform: scale(1); }
    50%       { opacity: 1;    transform: scale(1.25); }
}

/* Full analysis block appended when Sonnet enrichment arrives */
.enrichment-full-analysis {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color, rgba(0,0,0,0.08));
}

.enrichment-full-analysis-divider {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin-bottom: 10px;
}

.enrichment-full-analysis-content {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
}

.enrichment-tools {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-secondary);
}

.enrichment-tools-header {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.enrichment-tool-section {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-secondary);
}

.enrichment-tool-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.enrichment-tool-content {
    font-size: 13px;
    line-height: 1.6;
    margin-top: 4px;
}

/* V2 Pipeline: Validation Notes (Phase 3) */
.session-message-validation-note {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
}

.session-message-validation-note.validation-info {
    background: rgba(13, 148, 136, 0.08);
    border: 1px solid rgba(13, 148, 136, 0.2);
    color: var(--text-secondary);
}

.session-message-validation-note.validation-warning {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: var(--text-secondary);
}

.validation-icon {
    font-size: 14px;
    flex-shrink: 0;
}

/* ============================================
   Helper Selector Modal (was Agent Selector)
   ============================================ */

.agent-selector-modal {
    max-height: 60vh;
    overflow-y: auto;
}

/* Helper Search (Increment 1b) */
.helper-search-container {
    position: sticky;
    top: 0;
    background: var(--bg-primary, #fff);
    padding: 0 0 12px 0;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
}

.helper-search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-primary, #d1d5db);
    border-radius: 8px;
    font-size: 14px;
    background: var(--surface-primary, #fff);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.helper-search-input:focus {
    outline: none;
    border-color: var(--accent-primary, #4f46e5);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.helper-search-input::placeholder {
    color: var(--text-tertiary, #9ca3af);
}

.helper-search-icon {
    font-size: 16px;
    color: var(--text-tertiary, #9ca3af);
}

.helper-search-count {
    font-size: 12px;
    color: var(--text-tertiary, #9ca3af);
    margin-left: auto;
}

.helper-search-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-secondary);
}

.helper-search-empty p {
    margin: 0 0 8px 0;
}

.helper-search-empty-hint {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* Helpers Sections (Library & Marketplace) */
.helpers-section {
    margin-bottom: 20px;
}

.helpers-section:last-child {
    margin-bottom: 0;
}

.helpers-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--bg-secondary, #f9fafb);
    border-radius: 8px;
}

.helpers-section-icon {
    font-size: 18px;
}

.helpers-section-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary, #1f2937);
}

.helpers-section-count {
    font-size: 12px;
    color: var(--text-tertiary, #9ca3af);
    margin-left: auto;
    background: var(--bg-tertiary, #e5e7eb);
    padding: 2px 8px;
    border-radius: 10px;
}

.helpers-section-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Library Section */
.helpers-library-section .helpers-section-header {
    background: var(--primary-light, #eff6ff);
}

.helpers-library-empty {
    text-align: center;
    padding: 20px 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

.helpers-library-empty p {
    margin: 0 0 8px 0;
}

/* Marketplace Section */
.helpers-marketplace-section .helpers-section-header {
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
}

.helpers-marketplace-prompt,
.helpers-marketplace-loading,
.helpers-marketplace-empty,
.helpers-marketplace-error {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

.helpers-marketplace-prompt p,
.helpers-marketplace-loading p,
.helpers-marketplace-empty p,
.helpers-marketplace-error p {
    margin: 0;
}

.helpers-marketplace-note {
    font-size: 12px;
    color: var(--text-tertiary, #9ca3af);
    text-align: center;
    margin: 12px 0 0 0;
    font-style: italic;
}

/* Marketplace helper cards */
.agent-option-marketplace {
    background: var(--bg-secondary, #f9fafb);
    border: 1px dashed var(--border-light, #e5e7eb);
}

.agent-option-marketplace:hover {
    border-color: var(--primary-color, #0d9488);
    background: var(--bg-hover, #f3f4f6);
}

.agent-option-marketplace.agent-option-selected {
    border-style: solid;
    border-color: var(--primary-color, #0d9488);
    background: var(--primary-light, #eff6ff);
}

/* Agent option meta row (creator badge, tools, match reasons) */
.agent-option-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.agent-creator-badge {
    font-size: 12px;
    padding: 2px 8px;
    background: var(--bg-tertiary, #e5e7eb);
    border-radius: 10px;
    color: var(--text-secondary, #6b7280);
}

.agent-option-rating {
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
    margin-left: auto;
}

.match-reason {
    font-size: 12px;
    padding: 2px 8px;
    background: var(--bg-tertiary, #f3f4f6);
    border-radius: 10px;
    color: var(--text-secondary, #6b7280);
}

.marketplace-add-note {
    font-size: 12px;
    font-weight: 400;
    color: var(--primary-color, #0d9488);
}

/* ============================================
   Session Upload Modal
   ============================================ */

.session-upload-modal {
    max-width: 500px;
}

.upload-intro {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.upload-section-label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.upload-destination-section {
    margin-bottom: 20px;
}

.upload-destination-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.upload-destination-option {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border: 2px solid var(--border-primary, #e5e7eb);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--surface-primary, #fff);
}

.upload-destination-option:hover {
    border-color: var(--accent-primary, #4f46e5);
    background: var(--surface-secondary, #f9fafb);
}

.upload-destination-option:has(input:checked) {
    border-color: var(--accent-primary, #4f46e5);
    background: #eef2ff;
}

.upload-destination-option input[type="radio"] {
    margin-right: 12px;
    accent-color: var(--accent-primary, #4f46e5);
}

.destination-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.destination-icon {
    font-size: 24px;
}

.destination-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.destination-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.destination-desc {
    font-size: 12px;
    color: var(--text-tertiary);
}

.upload-file-section {
    margin-bottom: 16px;
}

.upload-dropzone {
    border: 2px dashed var(--border-primary, #d1d5db);
    border-radius: 10px;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--surface-secondary, #f9fafb);
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--accent-primary, #4f46e5);
    background: #eef2ff;
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.dropzone-icon {
    font-size: 32px;
    opacity: 0.6;
}

.dropzone-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.dropzone-hint {
    font-size: 12px;
    color: var(--text-tertiary);
}

.upload-file-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface-secondary, #f0f9ff);
    border: 1px solid var(--accent-primary, #4f46e5);
    border-radius: 8px;
}

.upload-file-preview .file-icon {
    font-size: 24px;
}

.upload-file-preview .file-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-file-preview .file-size {
    font-size: 12px;
    color: var(--text-tertiary);
}

.upload-file-preview .file-remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-tertiary);
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.upload-file-preview .file-remove-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.upload-progress-section {
    margin-top: 16px;
}

.upload-progress-bar {
    height: 8px;
    background: var(--border-light, #e5e7eb);
    border-radius: 4px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: var(--accent-primary, #4f46e5);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.upload-progress-text {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
}

.agent-selector-intro {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0 0 16px 0;
}

.agent-selector-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.agent-option {
    padding: 16px;
    border: 2px solid var(--border-primary);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--surface-primary);
}

.agent-option:hover {
    border-color: var(--accent-primary);
    background: var(--surface-secondary);
}

.agent-option-selected {
    border-color: var(--accent-primary);
    background: #eff6ff;
}

.agent-option-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.agent-option-icon {
    font-size: 20px;
}

.agent-option-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.agent-option-current {
    padding: 2px 8px;
    background: var(--accent-primary);
    color: var(--text-on-accent);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}

.agent-option-description {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.agent-option-tools {
    font-size: 12px;
    color: var(--text-tertiary);
}

.agent-selector-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.agent-selector-empty p {
    margin: 0 0 8px 0;
}

.agent-remove-btn {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}


/* ============================================
   Responsive
   ============================================ */

@media (max-width: 1024px) {
    .sessions-container {
        padding: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .sessions-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .session-detail-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .session-detail-actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* Messages: no individual scroll — only .session-messages scrolls */
    .session-message {
        max-width: 80%;
        box-sizing: border-box;
    }
    .session-message-user {
        margin-right: 4px; /* prevent clipping at right edge */
    }
    .session-messages {
        overflow-x: hidden; /* prevent horizontal scroll on the messages container */
        overflow-y: auto;
    }
    .session-message-content {
        word-break: break-word;
        overflow-wrap: anywhere;
    }
    /* Detailed Data / tool results: constrain long JSON and code.
       Tables excluded — scroll wrapper handles overflow, word-break:break-all
       would shatter cell text at character boundaries. */
    .session-message-content pre,
    .session-message-content code {
        max-width: 100%;
        overflow-x: auto;
        word-break: break-all;
    }
    .session-message-tools details > div,
    .session-message-tools pre,
    .session-message-content details > div {
        max-width: 100%;
        overflow-x: auto;
        word-break: break-all;
        font-size: 12px;
    }

    /* Mobile chat: every ancestor uses flex + min-height:0 so .session-messages is the sole scroll container */
    .sessions-container.session-detail-view { display: flex; flex-direction: column; }
    .session-main-layout { flex: 1; min-height: 0; overflow: hidden; height: auto !important; }
    .session-main-content { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
    .session-chat-container { flex: 1; min-height: 0; max-height: 100%; display: flex; flex-direction: column; overflow: hidden; border-radius: 0; }
    .session-messages { flex: 1; min-height: 0; max-height: 100%; overflow-y: auto; overflow-x: hidden; padding: 8px; gap: 10px; -webkit-overflow-scrolling: touch; }

    .session-input-container {
        padding: 8px 10px 10px;
        background: var(--surface-primary);
    }

    .session-input-pill {
        border-radius: 22px;
        padding: 5px 5px 5px 2px;
    }

    .session-input {
        font-size: 16px; /* hard floor — prevents iOS Safari auto-zoom on focus */
    }

    /* Compact send button — circle with arrow icon */
    .session-send-btn {
        width: 34px;
        height: 34px;
        min-width: 34px;
    }
    .send-label { display: none; }
    .send-icon { display: inline; font-size: 16px; }

    /* Paperclip attach button */
    .session-attach-btn {
        display: flex !important;
        width: 34px;
        height: 34px;
        min-width: 34px;
        padding: 0;
        border-radius: 50%;
        border: none;
        background: transparent;
        color: var(--text-secondary);
        cursor: pointer;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        flex-shrink: 0;
    }

    /* Hide session header buttons that don't fit mobile */
    #session-upload-btn { display: none; }
    .session-detail-actions { flex-wrap: wrap; gap: 4px; }
    .session-detail-actions .sessions-btn { padding: 6px 10px; font-size: 12px; }

    /* Session detail view: fill available space instead of fixed calc */
    .session-detail-view {
        height: 100% !important;
        min-height: 0 !important;
        flex: 1;
    }

    /* Collapse session header — title is in topbar, hide redundant elements */
    .session-detail-header { display: none; } /* title + badges shown in mobile topbar */
    .session-detail-description { display: none; }
    .session-health-assistant-notice { display: none; }

    /* Hide resources sidebar on mobile — accessible via Data tab instead */
    .session-resources-sidebar { display: none !important; }

    /* Back button: compact, always visible */
    #session-back-btn { padding: 4px 10px; font-size: 12px; margin: 4px 8px; display: inline-block !important; }
}

/* ============================================
   Real-Time Timeline (Increment 3.5)
   ============================================ */

.session-message-thinking .session-message-content {
    flex-direction: column;
    align-items: stretch;
}

.thinking-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

/* Elapsed-time counter shown in the message header */
.thinking-elapsed-wrapper {
    margin-left: auto;
}
.thinking-elapsed {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: var(--text-tertiary);
    background: var(--surface-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: 10px;
    padding: 1px 7px;
    min-width: 36px;
    text-align: center;
    display: inline-block;
}
/* Hide until timer has a value */
.thinking-elapsed:empty { display: none; }

/* Timeline Wrapper */
.agent-timeline-wrapper {
    background: var(--surface-secondary);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-primary);
}

.timeline-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--surface-primary);
    cursor: pointer;
    user-select: none;
}

.timeline-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timeline-toggle-icon {
    font-size: 12px;
    color: var(--text-tertiary);
    transition: transform 0.2s;
}

/* Timeline Events Container */
.agent-timeline {
    max-height: 260px;
    overflow-y: auto;
    padding: 12px;
}

/* Scope all agent-timeline child classes to avoid colliding with vizRenderer.css
   which also uses generic names like .timeline-event, .timeline-icon, etc. */
.agent-timeline .timeline-empty {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
    font-style: italic;
    padding: 16px;
}

/* Individual Timeline Event */
.agent-timeline .timeline-event {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-secondary);
}

.agent-timeline .timeline-event:last-child {
    border-bottom: none;
}

.agent-timeline .timeline-event-active {
    background: rgba(13, 148, 136, 0.05);
    margin: 0 -12px;
    padding: 8px 12px;
    border-radius: 6px;
}

.agent-timeline .timeline-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.agent-timeline .timeline-content {
    flex: 1;
    min-width: 0;
}

.agent-timeline .timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.agent-timeline .timeline-event-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.agent-timeline .timeline-time {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.agent-timeline .timeline-details {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.4;
}

/* Timeline Event Status Colors */
.agent-timeline .timeline-event.success .timeline-event-name {
    color: #166534;
}

.agent-timeline .timeline-event.error .timeline-event-name {
    color: #dc2626;
}

.agent-timeline .timeline-event.warning .timeline-event-name {
    color: #b45309;
}

.agent-timeline .timeline-event.in_progress .timeline-event-name {
    color: var(--accent-primary);
}

/* Timeline Summary (Collapsed View) */
.timeline-summary {
    margin-top: 12px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-secondary);
    border: 1px solid var(--border-primary);
}

.timeline-summary-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.timeline-summary-header:hover {
    background: var(--surface-primary);
}

.timeline-summary-icon {
    font-size: 14px;
}

.timeline-summary-text {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

.timeline-expand-icon {
    font-size: 12px;
    color: var(--text-tertiary);
    transition: transform 0.2s;
}

.timeline-summary:not(.collapsed) .timeline-expand-icon {
    transform: rotate(90deg);
}

.timeline-summary-details {
    padding: 0 14px 12px;
}

.timeline-summary-event {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 12px;
    border-bottom: 1px solid var(--border-secondary);
}

.timeline-summary-event:last-child {
    border-bottom: none;
}

.timeline-summary-event-icon {
    font-size: 12px;
    width: 18px;
    text-align: center;
}

.timeline-summary-event-text {
    flex: 1;
    color: var(--text-primary);
}

.timeline-summary-event-details {
    color: var(--text-tertiary);
    font-size: 12px;
}

/* Collapsed message state (after thinking completes) */
.session-message-collapsed {
    background: var(--surface-secondary);
    border-color: var(--border-secondary);
}

.session-message-collapsed .session-message-content {
    padding: 0;
}

.session-message-collapsed .timeline-summary {
    margin-top: 0;
    border: none;
    background: transparent;
}

/* Scrollbar for timeline */
.agent-timeline::-webkit-scrollbar {
    width: 6px;
}

.agent-timeline::-webkit-scrollbar-track {
    background: transparent;
}

.agent-timeline::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 3px;
}

.agent-timeline::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ============================================
   Multi-Agent Support (Increment 4)
   ============================================ */

/* Agent selector in chat input */
.session-agent-selector {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--surface-secondary);
    border-bottom: 1px solid var(--border-secondary);
    border-radius: 12px 12px 0 0;
}

.session-agent-select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    background: var(--surface-primary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.session-agent-select:hover {
    border-color: var(--primary-color);
}

.session-agent-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Agent color indicator in messages */
.agent-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--agent-color, var(--primary-color));
    color: var(--text-on-accent);
    font-size: 14px;
    margin-right: 4px;
}

/* Agent message with color accent */
.session-message-assistant[data-agent-id] {
    border-left: 3px solid var(--agent-color, var(--border-primary));
}

.session-message-assistant[data-agent-id] .session-message-role {
    color: var(--agent-color, var(--text-primary));
}

/* Agent option checkbox layout (multi-select modal) */
.agent-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.agent-option:hover {
    background: var(--surface-secondary);
    border-color: var(--primary-color);
}

.agent-option-selected {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.agent-option-checkbox {
    padding-top: 2px;
}

.agent-option-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.agent-option-content {
    flex: 1;
    min-width: 0;
}

.agent-option-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.agent-option-icon {
    font-size: 18px;
}

.agent-option-name {
    font-weight: 600;
    color: var(--text-primary);
}

.agent-option-description {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.agent-option-tools {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Agent source badge */
.agent-source-badge {
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-left: 8px;
}

.agent-source-badge.user {
    background: var(--primary-color-light, #e0f2fe);
    color: var(--primary-color, #0284c7);
}

.agent-source-badge.collection {
    background: #f0fdf4;
    color: #15803d;
}

/* Agent selector modal footer */
.agent-selector-footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.agent-count {
    font-size: 14px;
    color: var(--text-secondary);
}

.agent-count strong {
    color: var(--primary-color);
}

/* Input container adjustments for agent selector */
.session-input-container:has(.session-agent-selector) .session-input-pill {
    border-radius: 0 0 22px 22px;
}

/* ============================================
   Orchestration Timeline (Increment 4.5)
   ============================================ */

/* Orchestration Timeline Wrapper */
.orchestration-timeline-wrapper {
    background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 100%);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e0e7ff;
    margin-top: 12px;
}

.orchestration-timeline-wrapper.orchestration-complete {
    border-color: #86efac;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

.orchestration-timeline-wrapper.orchestration-error {
    border-color: #fca5a5;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

/* Orchestration Timeline Header */
.orchestration-timeline-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.orchestration-timeline-header:hover {
    background: rgba(255, 255, 255, 0.9);
}

.orchestration-timeline-icon {
    font-size: 16px;
}

.orchestration-timeline-label {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: #4338ca;
}

.orchestration-timeline-toggle-icon {
    font-size: 12px;
    color: #6366f1;
    transition: transform 0.2s;
}

/* Orchestration Timeline Content */
.orchestration-timeline {
    padding: 12px 16px;
}

/* Orchestration Phase */
.orchestration-phase {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.orchestration-phase:last-child {
    border-bottom: none;
}

.orchestration-phase-icon {
    width: 20px;
    text-align: center;
    font-size: 14px;
}

.orchestration-phase-text {
    flex: 1;
}

/* Phase Status Styles */
.orchestration-phase.status-in_progress {
    color: #4338ca;
    font-weight: 500;
}

.orchestration-phase.status-in_progress .orchestration-phase-icon {
    animation: pulse 1.5s ease-in-out infinite;
}

.orchestration-phase.status-complete {
    color: #16a34a;
}

.orchestration-phase.status-complete .orchestration-phase-icon {
    color: #16a34a;
}

.orchestration-phase.status-error {
    color: #dc2626;
}

.orchestration-phase.status-error .orchestration-phase-icon {
    color: #dc2626;
}

/* Orchestration Agent Event */
.orchestration-agent-event {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin: 4px 0;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    font-size: 12px;
}

.orchestration-agent-icon {
    width: 20px;
    text-align: center;
}

.orchestration-agent-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.orchestration-agent-status {
    color: var(--text-tertiary);
    font-size: 12px;
}

.orchestration-agent-event.status-in_progress {
    border-left: 3px solid #6366f1;
}

.orchestration-agent-event.status-in_progress .orchestration-agent-icon {
    animation: pulse 1.5s ease-in-out infinite;
}

.orchestration-agent-event.status-complete {
    border-left: 3px solid #16a34a;
}

.orchestration-agent-event.status-complete .orchestration-agent-icon {
    color: #16a34a;
}

.orchestration-agent-event.status-error {
    border-left: 3px solid #dc2626;
}

.orchestration-agent-event.status-error .orchestration-agent-icon {
    color: #dc2626;
}

/* Orchestration Complete Summary */
.orchestration-complete-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin-top: 8px;
    background: rgba(22, 163, 74, 0.1);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #16a34a;
}

/* Orchestration Error Message */
.orchestration-error-message {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin-top: 8px;
    background: rgba(220, 38, 38, 0.1);
    border-radius: 6px;
    font-size: 12px;
    color: #dc2626;
}

.orchestration-error-icon {
    font-size: 16px;
}

/* Orchestration Summary (collapsed state) */
.orchestration-summary {
    margin-top: 12px;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 100%);
    border: 1px solid #e0e7ff;
}

.orchestration-summary-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.orchestration-summary-header:hover {
    background: rgba(255, 255, 255, 0.5);
}

.orchestration-summary-icon {
    font-size: 14px;
}

.orchestration-summary-text {
    flex: 1;
    font-size: 13px;
    color: #4338ca;
    font-weight: 500;
}

.orchestration-expand-icon {
    font-size: 12px;
    color: #6366f1;
    transition: transform 0.2s;
}

.orchestration-summary:not(.collapsed) .orchestration-expand-icon {
    transform: rotate(90deg);
}

.orchestration-summary-details {
    padding: 0 14px 12px;
}

.orchestration-summary-agent {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 12px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.orchestration-summary-agent:last-child {
    border-bottom: none;
}

.orchestration-summary-agent-icon {
    color: #16a34a;
    font-size: 12px;
    width: 18px;
    text-align: center;
}

.orchestration-summary-agent-name {
    color: var(--text-primary);
}

/* Pulse animation for in-progress items */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ORCHESTRATION INSIGHTS PANEL (Dev Mode)
   ═══════════════════════════════════════════════════════════════════════════ */

.orchestration-insights-panel {
    margin-top: 12px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.05));
    overflow: visible;
    font-size: 12px;
}

.insights-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(99, 102, 241, 0.1);
    cursor: pointer;
    user-select: none;
}

.insights-panel-header:hover {
    background: rgba(99, 102, 241, 0.15);
}

.insights-panel-icon {
    font-size: 14px;
}

.insights-panel-title {
    flex: 1;
    font-weight: 600;
    color: #6366f1;
}

.insights-panel-status {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(148, 163, 184, 0.2);
    color: #64748b;
}

.insights-panel-status.status-running {
    background: rgba(234, 179, 8, 0.2);
    color: #ca8a04;
    animation: pulse 1.5s infinite;
}

.insights-panel-status.status-complete {
    background: rgba(34, 197, 94, 0.2);
    color: #16a34a;
}

.insights-panel-status.status-error {
    background: rgba(239, 68, 68, 0.2);
    color: #dc2626;
}

.insights-panel-expand {
    color: #6366f1;
    font-size: 12px;
    transition: transform 0.2s;
}

.orchestration-insights-panel:not(.collapsed) .insights-panel-expand {
    transform: rotate(180deg);
}

.insights-panel-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Removed max-height to allow full content display including Prompt Editor */
    overflow-y: visible;
}

.orchestration-insights-panel.collapsed .insights-panel-content {
    display: none;
}

/* Insights Sections */
.insights-section {
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 6px;
    background: var(--card-background);
    overflow: hidden;
}

.insights-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(148, 163, 184, 0.05);
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.section-icon {
    font-size: 12px;
}

.section-title {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.section-status {
    font-size: 12px;
    color: #4b5563;
}

.section-status[data-status="in_progress"] {
    color: #ca8a04;
    animation: pulse 1s infinite;
}

.section-status[data-status="complete"] {
    color: #16a34a;
}

.section-status[data-status="error"] {
    color: #dc2626;
}

.section-duration {
    font-size: 12px;
    color: #64748b;
    font-family: monospace;
}

.insights-section-body {
    padding: 10px 12px;
}

.insights-placeholder {
    color: #4b5563;
    font-style: italic;
    text-align: center;
    padding: 8px;
}

.insights-message {
    color: #64748b;
}

/* Detail Grid */
.insights-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-label {
    font-size: 12px;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-weight: 500;
    color: var(--text-primary);
}

.detail-value.pattern-parallel {
    color: #22c55e;
}

.detail-value.pattern-sequential {
    color: #f59e0b;
}

/* Reasoning Text */
.insights-reasoning {
    margin-top: 8px;
    padding: 8px;
    background: rgba(148, 163, 184, 0.05);
    border-radius: 4px;
    font-size: 12px;
    color: #64748b;
    line-height: 1.4;
}

/* Sub-Tasks List */
.insights-subtasks {
    margin-top: 8px;
}

.subtasks-header {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 6px;
}

.subtask-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(148, 163, 184, 0.05);
    border-radius: 4px;
    margin-bottom: 4px;
}

.subtask-id {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #6366f1;
    color: var(--text-on-accent);
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    flex-shrink: 0;
}

.subtask-desc {
    flex: 1;
    color: var(--text-primary);
    line-height: 1.4;
}

.subtask-keywords {
    font-size: 12px;
    color: #4b5563;
    font-family: monospace;
}

/* Full Subtask Item (expanded view) */
.subtask-item-full {
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 6px;
    margin-bottom: 10px;
    overflow: hidden;
    background: rgba(148, 163, 184, 0.03);
}

.subtask-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(99, 102, 241, 0.1);
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.subtask-agent {
    font-weight: 600;
    color: var(--primary-color);
}

.subtask-content {
    padding: 12px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 300px;
    overflow-y: auto;
    background: var(--card-background);
}

/* Triage Scope Badges */
.scope-none {
    color: #22c55e;
    font-weight: 600;
}

.scope-partial {
    color: #f59e0b;
    font-weight: 600;
}

.scope-full {
    color: #6366f1;
    font-weight: 600;
}

/* Triage Direct Response */
.triage-direct-response {
    margin-top: 12px;
    padding: 10px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 6px;
}

.direct-response-label {
    font-size: 12px;
    text-transform: uppercase;
    color: #22c55e;
    font-weight: 600;
    margin-bottom: 6px;
}

.direct-response-content {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* Match Table */
.insights-match-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.insights-match-table th,
.insights-match-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.insights-match-table th {
    font-weight: 500;
    color: #64748b;
    background: rgba(148, 163, 184, 0.05);
}

.insights-match-table tr.fallback-row {
    background: rgba(234, 179, 8, 0.05);
}

.score-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}

.score-badge.score-high {
    background: rgba(34, 197, 94, 0.2);
    color: #16a34a;
}

.score-badge.score-medium {
    background: rgba(234, 179, 8, 0.2);
    color: #ca8a04;
}

.score-badge.score-low {
    background: rgba(239, 68, 68, 0.2);
    color: #dc2626;
}

.unmatched-warning {
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(234, 179, 8, 0.1);
    border-radius: 4px;
    color: #ca8a04;
    font-size: 12px;
}

/* Execution Plan */
.execution-pattern {
    margin-bottom: 8px;
    color: #64748b;
}

.execution-levels {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.execution-level {
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 4px;
    overflow: hidden;
}

.level-header {
    padding: 6px 10px;
    background: rgba(148, 163, 184, 0.05);
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.level-tasks {
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.level-task {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 4px;
}

.level-task[data-status="in_progress"] {
    border-color: #ca8a04;
    background: rgba(234, 179, 8, 0.05);
}

.level-task[data-status="complete"] {
    border-color: #16a34a;
    background: rgba(34, 197, 94, 0.05);
}

.task-status-icon {
    font-size: 12px;
}

.task-agent {
    font-weight: 500;
    color: var(--text-primary);
}

.task-duration {
    font-size: 12px;
    color: #64748b;
    font-family: monospace;
}

/* Quality Score Display */
.quality-score-display {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.quality-score {
    font-size: 28px;
    font-weight: 700;
    font-family: monospace;
}

.quality-score.score-high {
    color: #16a34a;
}

.quality-score.score-medium {
    color: #ca8a04;
}

.quality-score.score-low {
    color: #dc2626;
}

.quality-label {
    font-size: 12px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.quality-gaps {
    margin-top: 10px;
    padding: 8px;
    background: rgba(239, 68, 68, 0.05);
    border-radius: 4px;
}

.gaps-header {
    font-size: 12px;
    font-weight: 500;
    color: #dc2626;
    margin-bottom: 6px;
}

.gap-item {
    font-size: 12px;
    color: #64748b;
    padding: 2px 0;
}

/* Timing Summary */
.insights-timing-summary {
    padding: 10px 12px;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 6px;
}

.timing-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timing-bar-container {
    display: flex;
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(148, 163, 184, 0.1);
}

.timing-bar-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 0 4px;
    cursor: help;
}

.timing-bar-label {
    font-size: 12px;
    color: var(--text-on-accent);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timing-total {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    font-size: 12px;
}

.timing-total .timing-label {
    color: #64748b;
}

.timing-total .timing-value {
    font-weight: 600;
    color: var(--text-primary);
    font-family: monospace;
}

/* ============================================
   Prompt Editor (Experimental)
   ============================================ */

.insights-prompt-editor {
    border-top: 1px solid rgba(148, 163, 184, 0.15);
    margin-top: 12px;
    padding-top: 12px;
}

.prompt-editor-toggle-btn {
    padding: 2px 8px;
    font-size: 12px;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(99, 102, 241, 0.3);
    cursor: pointer;
    margin-left: auto;
}

.prompt-editor-toggle-btn:hover {
    background: rgba(99, 102, 241, 0.2);
}

.prompt-editor-body {
    padding: 12px 0;
}

.prompt-editor-group {
    margin-bottom: 16px;
}

.prompt-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.prompt-textarea {
    width: 100%;
    padding: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
    resize: vertical;
    min-height: 150px;
}

.prompt-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.prompt-editor-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.prompt-editor-actions .btn {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.prompt-editor-actions .btn-secondary {
    background: rgba(148, 163, 184, 0.25);
    color: var(--text-primary);
    border: 1px solid rgba(148, 163, 184, 0.4);
}

.prompt-editor-actions .btn-secondary:hover {
    background: rgba(148, 163, 184, 0.4);
    border-color: rgba(148, 163, 184, 0.6);
}

.prompt-editor-actions .btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: var(--text-on-accent);
    border: 1px solid #059669;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.prompt-editor-actions .btn-primary:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.prompt-editor-actions .btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(16, 185, 129, 0.3);
}

.prompt-editor-note {
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.3);
    border-radius: 4px;
    font-size: 12px;
    color: #ca8a04;
    line-height: 1.4;
}

.prompt-editor-note code {
    background: rgba(0, 0, 0, 0.2);
    padding: 1px 4px;
    border-radius: 2px;
    font-family: monospace;
}

/* =====================================================================
   COLLAPSIBLE SECTIONS (HTML details/summary)
   Used for More Details, Limitations & Assumptions, Sources
   ===================================================================== */

.session-message-content details {
    margin: 10px 0;
    border: 1px solid #99f6e4;
    border-left: 3px solid var(--color-primary, #0d9488);
    border-radius: 6px;
    background: var(--color-white, #fff);
    overflow: hidden;
}

.session-message-content details[open] {
    background: var(--color-white, #fff);
}

.session-message-content details summary {
    padding: 7px 11px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-primary-dark, #0f766e);
    background: var(--color-primary-subtle, #f0fdfa);
    border-bottom: 1px solid transparent;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: background 0.15s ease;
    user-select: none;
}

.session-message-content details summary::-webkit-details-marker {
    display: none;
}

.session-message-content details summary::before {
    content: '▶';
    font-size: 10px;
    transition: transform 0.15s ease;
    color: var(--color-primary, #0d9488);
    flex-shrink: 0;
}

.session-message-content details[open] summary::before {
    transform: rotate(90deg);
}

.session-message-content details summary:hover {
    background: #ccfbf1;
}

.session-message-content details[open] summary {
    border-bottom: 1px solid #99f6e4;
}

.session-message-content details > *:not(summary) {
    padding: 10px 14px;
    font-size: 12px;
    line-height: 1.7;
    color: var(--color-gray-700, #374151);
}

.session-message-content details p:first-of-type {
    margin-top: 0;
}

.session-message-content details p:last-of-type {
    margin-bottom: 0;
}

/* Markdown content styling within messages */
.session-message-content h1,
.session-message-content h2,
.session-message-content h3,
.session-message-content h4 {
    margin-top: 16px;
    margin-bottom: 8px;
}

/* User messages have dark background - use light headings */
.session-message-user .session-message-content h1,
.session-message-user .session-message-content h2,
.session-message-user .session-message-content h3,
.session-message-user .session-message-content h4 {
    color: #fff;
}

/* Assistant messages have light background - use dark headings */
.session-message-assistant .session-message-content h1,
.session-message-assistant .session-message-content h2,
.session-message-assistant .session-message-content h3,
.session-message-assistant .session-message-content h4 {
    color: var(--text-primary, #1f2937);
}

.session-message-content h1 { font-size: 1.4em; }
.session-message-content h2 { font-size: 1.2em; }
.session-message-content h3 { font-size: 1.1em; }
.session-message-content h4 { font-size: 1em; }

.session-message-content ul,
.session-message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.session-message-content li {
    margin: 4px 0;
}

.session-message-content blockquote {
    margin: 12px 0;
    padding: 8px 16px;
    border-left: 3px solid var(--color-primary, #4a9eff);
    background: rgba(0, 0, 0, 0.1);
    font-style: italic;
}

.session-message-content pre {
    margin: 12px 0;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    overflow-x: auto;
}

.session-message-content code {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9em;
}

.session-message-content pre code {
    background: none;
    padding: 0;
}

/* Scroll wrapper injected by _wrapTables() — block container that scrolls,
   keeps the table itself as display:table with natural column widths */
.session-table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* smooth momentum scroll on iOS */
    margin: 12px 0;
}

.session-message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0; /* margin lives on the wrapper now */
}

/* Minimum cell width so multi-column tables exceed narrow screens and
   trigger scroll rather than collapsing columns to illegible widths */
.session-table-scroll-wrapper th,
.session-table-scroll-wrapper td {
    min-width: 120px;
}

.session-message-content th,
.session-message-content td {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

.session-message-content th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
}

.session-message-content a {
    color: #0f766e;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: rgba(15, 118, 110, 0.35);
    text-underline-offset: 2px;
}

.session-message-content a:hover {
    color: #0b5f59;
    text-decoration-color: rgba(11, 95, 89, 0.55);
}

.session-message-user .session-message-content a {
    color: #93c5fd;
    text-decoration-color: rgba(147, 197, 253, 0.4);
}

.session-message-content hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 16px 0;
}

/* ============================================
   Session Templates (Increment 8)
   ============================================ */

.session-template-picker {
    padding: 8px 0;
}

.template-picker-intro {
    color: var(--text-secondary);
    margin: 0 0 20px 0;
    font-size: 14px;
}

.session-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.session-template-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
    background: var(--surface-secondary, #1a1a2e);
    border: 2px solid var(--border-primary, #2d2d4a);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.session-template-card:hover {
    border-color: var(--accent-primary, #3b82f6);
    background: var(--surface-tertiary, #232340);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.session-template-card.template-blank {
    border-style: dashed;
}

.session-template-card.template-blank:hover {
    border-style: solid;
}

.template-icon {
    font-size: 32px;
    line-height: 1;
    flex-shrink: 0;
}

.template-info {
    flex: 1;
    min-width: 0;
}

.template-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 6px 0;
}

.template-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.template-agents {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.template-agent-label {
    font-size: 12px;
    color: var(--text-tertiary, #4b5563);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.template-agent-tag {
    display: inline-block;
    padding: 3px 8px;
    background: var(--accent-primary-muted, rgba(13, 148, 136, 0.15));
    color: var(--accent-primary, #3b82f6);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Agent Permission Modal */
.agent-permission-modal {
    padding: 8px 0;
}

.permission-intro {
    color: var(--text-primary);
    margin: 0 0 16px 0;
    font-size: 14px;
    line-height: 1.5;
}

.missing-agents-list {
    background: var(--surface-secondary, #1a1a2e);
    border: 1px solid var(--border-primary, #2d2d4a);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.missing-agent-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.missing-agent-item:not(:last-child) {
    border-bottom: 1px solid var(--border-primary, #2d2d4a);
}

.missing-agent-name {
    font-weight: 500;
    color: var(--text-primary);
}

.missing-agent-source {
    font-size: 12px;
    color: var(--text-tertiary, #4b5563);
}

.permission-question {
    color: var(--text-secondary);
    margin: 0;
    font-size: 14px;
}

/* ============================================
   Sidebar Subsections (for Attachments)
   ============================================ */

.sidebar-subsection {
    margin-top: 12px;
    padding-left: 8px;
}

.sidebar-subsection:first-child {
    margin-top: 8px;
}

.sidebar-subsection-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar-subsection-icon {
    font-size: 12px;
}

.sidebar-subsection-title {
    flex: 1;
    font-weight: 500;
}

.sidebar-subsection-count {
    font-size: 12px;
    background: var(--surface-secondary, #f0f0f0);
    padding: 2px 6px;
    border-radius: 10px;
    color: var(--text-tertiary, #4b5563);
}

.sidebar-empty-hint {
    font-size: 12px;
    color: var(--text-tertiary, #4b5563);
    padding: 4px 0;
    font-style: italic;
}

/* ============================================
   Attachment Modal
   ============================================ */

.attachment-modal {
    min-width: 400px;
}

.attachment-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-primary, #e0e0e0);
    margin-bottom: 16px;
}

.attachment-tab {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.attachment-tab:hover {
    color: var(--text-primary);
    background: var(--surface-hover, #f5f5f5);
}

.attachment-tab.active {
    color: var(--accent-primary, #2196F3);
    border-bottom-color: var(--accent-primary, #2196F3);
}

.attachment-tab-content {
    display: none;
}

.attachment-tab-content.active {
    display: block;
}

.attachment-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-primary, #e0e0e0);
    border-radius: 8px;
    margin-bottom: 12px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-secondary, #f0f0f0);
    transition: background 0.2s ease;
}

.attachment-item:last-child {
    border-bottom: none;
}

.attachment-item:hover {
    background: var(--surface-hover, #f5f5f5);
}

.attachment-item.already-attached {
    background: var(--surface-secondary, #f8f8f8);
    opacity: 0.7;
    cursor: default;
}

.attachment-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.attachment-item-info {
    flex: 1;
    min-width: 0;
}

.attachment-item-name {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-item-meta {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary, #4b5563);
    margin-top: 2px;
}

.attachment-badge {
    font-size: 12px;
    padding: 3px 8px;
    background: var(--accent-primary, #2196F3);
    color: var(--text-on-accent);
    border-radius: 12px;
    flex-shrink: 0;
}

.attachment-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-tertiary, #4b5563);
}

.attachment-empty p {
    margin: 0;
}

.attachment-upload-section {
    text-align: center;
}

.attachment-upload-btn {
    padding: 10px 20px;
    background: var(--surface-secondary, #f0f0f0);
    border: 1px dashed var(--border-primary, #ccc);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    width: 100%;
}

.attachment-upload-btn:hover {
    background: var(--surface-hover, #e8e8e8);
    border-color: var(--accent-primary, #2196F3);
    color: var(--accent-primary, #2196F3);
}

/* ============================================
   Health Assistant Styling (Increment 4.6)
   Workspace Intelligence / General Agent
   ============================================ */

/* Health Assistant badge in session header */
.health-assistant-badge {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
    color: white !important;
    font-weight: 500;
}

.health-assistant-badge:hover {
    filter: brightness(1.1);
}

/* Health Assistant message styling */
.session-message-health-assistant {
    border-left: 3px solid #6366f1;
}

.session-message-health-assistant .session-message-header {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.1) 0%, transparent 100%);
}

.session-message-health-assistant .agent-indicator {
    color: #6366f1;
}

/* Direct Knowledge response styling */
.session-message-direct-knowledge {
    border-left: 3px solid #f59e0b;
}

.session-message-direct-knowledge .session-message-header {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.1) 0%, transparent 100%);
}

.session-message-direct-knowledge .agent-indicator {
    color: #f59e0b;
}

/* Document Match response styling */
.session-message-document-match {
    border-left: 3px solid #10b981;
}

.session-message-document-match .session-message-header {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.1) 0%, transparent 100%);
}

.session-message-document-match .agent-indicator {
    color: #10b981;
}

/* Health Assistant notice when no agents assigned */
.session-health-assistant-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.08) 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.session-health-assistant-notice span:first-child {
    font-size: 20px;
}

/* Response path indicator (optional) */
.session-message[data-response-path="WORKSPACE_AGENT"]::before {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: -3px;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, #6366f1, #8b5cf6);
    border-radius: 3px 0 0 3px;
}

/* Health Assistant indicator in header (when always available) */
.health-assistant-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #6366f1;
    opacity: 0.8;
}

.health-assistant-indicator .badge {
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
}

/* Triage confidence indicator (optional enhancement) */
.triage-confidence {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-left: auto;
}

.triage-confidence.high {
    color: #10b981;
}

.triage-confidence.medium {
    color: #f59e0b;
}

.triage-confidence.low {
    color: #ef4444;
}

/* ---------------------------------------------------------------
   ON-DEMAND DIAGRAM ACTION BUTTONS
   Appear below assistant messages; disappear once generated
   --------------------------------------------------------------- */

.session-diagram-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--color-gray-100);
    flex-wrap: wrap;
}

.session-diagram-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border: 1.5px solid var(--color-gray-200);
    border-radius: 14px;
    background: var(--surface-primary);
    color: var(--color-gray-700);
    font-family: var(--font-family-base);
    cursor: pointer;
    text-align: left;
    transition: border-color .18s, box-shadow .18s, background .18s, transform .12s;
    position: relative;
    overflow: hidden;
}

.session-diagram-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity .18s;
    pointer-events: none;
}

.session-diagram-btn[data-action="gen-diagrams"]::before {
    background: linear-gradient(135deg, rgba(8,145,178,.06) 0%, rgba(13,148,136,.04) 100%);
}

.session-diagram-btn[data-action="gen-visual"]::before {
    background: linear-gradient(135deg, rgba(139,92,246,.06) 0%, rgba(236,72,153,.04) 100%);
}

.session-diagram-btn:hover:not(:disabled)::before {
    opacity: 1;
}

.session-diagram-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

.session-diagram-btn[data-action="gen-diagrams"]:hover:not(:disabled) {
    border-color: var(--color-accent, #0891b2);
}

.session-diagram-btn[data-action="gen-visual"]:hover:not(:disabled) {
    border-color: #a855f7;
}

.session-diagram-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.session-diagram-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Icon badge */
.session-diagram-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 18px;
    flex-shrink: 0;
    transition: transform .18s;
}

.session-diagram-btn:hover:not(:disabled) .session-diagram-btn-icon {
    transform: scale(1.1);
}

.session-diagram-btn[data-action="gen-diagrams"] .session-diagram-btn-icon {
    background: linear-gradient(135deg, #e0f2fe, #cffafe);
}

.session-diagram-btn[data-action="gen-visual"] .session-diagram-btn-icon {
    background: linear-gradient(135deg, #f3e8ff, #fce7f3);
}

/* Text stack */
.session-diagram-btn-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.session-diagram-btn-label {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--color-gray-800);
}

.session-diagram-btn-sub {
    font-size: 11px;
    font-weight: 400;
    color: var(--color-gray-500);
    line-height: 1.3;
}

/* Dark mode adjustments */
:root[data-theme="dark"] .session-diagram-btn[data-action="gen-diagrams"] .session-diagram-btn-icon {
    background: linear-gradient(135deg, rgba(8,145,178,.25), rgba(6,182,212,.15));
}

:root[data-theme="dark"] .session-diagram-btn[data-action="gen-visual"] .session-diagram-btn-icon {
    background: linear-gradient(135deg, rgba(139,92,246,.25), rgba(236,72,153,.15));
}

:root[data-theme="dark"] .session-diagram-btn-label {
    color: var(--color-gray-200);
}

/* ============================================
   Responsive typography — Claude.ai scale
   Mobile <640px: 16px | Tablet 640px+: 17px | Desktop 1024px+: 18px
   Input stays at 16px everywhere (iOS Safari auto-zoom floor)
   ============================================ */

@media (min-width: 640px) {
    .session-message-content,
    .session-message-user {
        font-size: 17px;
    }
}

@media (min-width: 1024px) {
    .session-message-content,
    .session-message-user {
        font-size: 18px;
    }
}

/* Space response discussions share a durable context snapshot. */
.space-discussion-actions { padding:6px 16px 12px; }
.space-discussion-actions button { display:flex; align-items:center; gap:12px; width:min(100%, 390px); padding:14px 16px; border:1px solid #b9dfda; border-radius:14px; background:#f2fbf9; color:#165e57; text-align:left; font:inherit; cursor:pointer; transition:background .15s, border-color .15s; }
.space-discussion-actions button:hover:not(:disabled) { background:#e5f6f2; border-color:#75bdb1; }
.space-discussion-actions button:focus-visible, .space-context-indicator:focus-visible { outline:2px solid #0d9488; outline-offset:3px; }
.space-discuss-icon { display:flex; align-items:center; justify-content:center; width:38px; height:38px; flex-shrink:0; border-radius:11px; background:#d9f2eb; color:#0b8278; }
.space-discuss-copy { display:flex; flex-direction:column; gap:4px; min-width:0; }
.space-discuss-copy strong { font-size:14px; font-weight:600; }
.space-discuss-copy small { font-size:12px; color:#527570; }
.space-discuss-arrow { margin-left:auto; font-size:18px; }
.space-context-indicator { display:flex; align-items:center; gap:9px; width:100%; margin:0 0 8px; padding:9px 12px; border:1px solid #d6e8e3; border-radius:12px; background:#f5faf8; color:#315f57; text-align:left; cursor:pointer; }
.space-context-indicator > .material-icons { font-size:19px; flex-shrink:0; }
.space-context-indicator strong, .space-context-indicator small { display:block; }
.space-context-indicator strong { font-size:12px; font-weight:600; }
.space-context-indicator small { margin-top:3px; font-size:11px; color:#647b76; }
.space-context-view { margin-left:auto; font-size:12px; font-weight:600; }
.space-discussion-actions button:disabled { opacity:.65; cursor:wait; }
#sps-destination { flex:0 1 132px; min-width:0; max-width:132px; font:inherit; font-size:12px; padding:6px 3px; border:0; border-radius:6px; background:transparent; color:var(--color-gray-600, #52606d); cursor:pointer; }
#sps-input { min-width:0; }
.space-discussion-feedback { font-size:12px; margin:6px 12px; color:var(--color-gray-600, #52606d); }
.space-discussion-feedback:empty { display:none; }
.space-discussion-feedback.is-error { color:var(--color-danger, #b42318); }
@media (max-width:480px) { #sps-destination { max-width:105px; font-size:11px; } }
.space-source-context { margin:12px; padding:14px; border:1px solid var(--color-gray-300, #ccc); border-radius:12px; }
.space-source-context summary { cursor:pointer; font-weight:600; padding:6px 0; }
.space-source-context pre { white-space:pre-wrap; overflow-wrap:anywhere; font:inherit; max-height:420px; overflow:auto; }

/* Full source viewer and destination choice. */
.discussion-destination-dialog { position:fixed; inset:0; margin:auto; width:min(520px,calc(100vw - 32px)); max-height:calc(100vh - 32px); max-height:calc(100dvh - 32px); overflow:auto; box-sizing:border-box; border:1px solid #d6e8e3; border-radius:18px; padding:24px; color:#243a36; background:#fff; box-shadow:0 18px 70px #163c3630; }
.discussion-destination-dialog::backdrop { background:#152b3655; }
.discussion-destination-dialog h3 { margin:0 0 10px; font-size:19px; }
.discussion-destination-dialog p { font-size:14px; line-height:1.5; color:#5d716c; }
.discussion-destination-dialog label { display:block; font-size:13px; font-weight:600; }
.discussion-destination-dialog select { display:block; width:100%; margin-top:8px; border:1px solid #bdcec9; padding:10px; border-radius:8px; background:#fff; color:inherit; }
.discussion-dialog-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:20px; }
.discussion-dialog-actions button, .source-context-tabs button, .source-context-heading button, #space-source-content > button, .discussion-draft-status button { font:inherit; font-size:12px; padding:7px 10px; border:1px solid #bdcec9; border-radius:8px; background:#f5faf8; color:#24695e; cursor:pointer; }
.discussion-dialog-actions [data-confirm] { background:#0d9488; color:white; border-color:#0d9488; }
.discussion-dialog-actions button:disabled { opacity:.45; cursor:not-allowed; }
.source-context-tabs { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0; }
.source-context-heading { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:8px; padding:10px 0; border-bottom:1px solid #e1ece8; }
.source-context-section { padding:14px 0; border-bottom:1px solid #e1ece8; overflow-wrap:anywhere; }
.source-context-section h4 { margin:0 0 10px; color:#235b51; font-size:14px; }
.source-context-section > div { max-height:520px; overflow:auto; line-height:1.6; font-size:14px; }
.source-context-section table { border-collapse:collapse; max-width:100%; }
.source-context-section td, .source-context-section th { padding:7px; border:1px solid #dbe6e2; }
.source-context-note, .discussion-draft-status { font-size:12px; color:#657a74; line-height:1.5; }
.discussion-draft-status { padding:0 10px 7px; }
.space-source-highlight { outline:3px solid #64bba9; outline-offset:5px; border-radius:16px; }
.space-discussion-destination[hidden] { display:none; }
.space-prompt-card { width:100%; padding:14px; border:1px solid #b9dfda; border-radius:12px; background:var(--color-white,#fff); }
.space-prompt-card > p { margin:0 0 12px; line-height:1.5; }
.space-prompt-actions { display:flex; flex-wrap:wrap; gap:12px; }
.space-prompt-action { position:relative; display:inline-flex; align-items:center; gap:6px; }
.space-prompt-action > button { font:inherit; font-size:13px; padding:9px 12px; border-radius:8px; cursor:pointer; }
.space-prompt-conversation { border:1px solid #0d9488; background:#0d9488; color:white; }
.space-prompt-action > .aw-prompt-chip { margin:0; border:1px solid #b9dfda; background:transparent; color:inherit; }
.space-prompt-help > summary { cursor:pointer; list-style:none; padding:5px; border-radius:5px; }
.space-prompt-help > summary::-webkit-details-marker { display:none; }
.space-prompt-action > [role=tooltip] { display:none; position:absolute; z-index:20; bottom:calc(100% + 8px); left:0; width:260px; max-width:calc(100vw - 64px); padding:10px 12px; border-radius:8px; background:#203d37; color:white; box-shadow:0 4px 16px #0003; font-size:12px; line-height:1.5; }
.space-prompt-action:hover [role=tooltip], .space-prompt-action:focus-within [role=tooltip], .space-prompt-help[open] + [role=tooltip] { display:block; }
.space-prompt-action > button:focus-visible, .space-prompt-help > summary:focus-visible { outline:2px solid #0d9488; outline-offset:3px; }
@media (max-width:600px) {
    .space-prompt-actions { flex-direction:column; align-items:flex-start; }
    .space-prompt-action { max-width:100%; }
}
