/* Medical Healthcare Dashboard - Light Theme */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    background-color: #f8f9fc !important;
    color: #1a1a2e !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
    background: #f8f9fc !important;
    color: #1a1a2e !important;
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app {
    display: flex;
    height: 100vh;
    background: #f8f9fc !important;
}

.app > .sidebar {
    width: 280px;
    flex-shrink: 0;
}

.app > .chat-main {
    flex: 1;
    min-width: 0;
}

.app > .context-panel {
    width: 360px;
    flex-shrink: 0;
}

/* ===== LEFT SIDEBAR ===== */
.sidebar {
    background: #ffffff !important;
    border-right: 1px solid #e8ecf4 !important;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px 20px;
    background: #ffffff !important;
}

.brand {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-bottom: 20px;
    flex-wrap: nowrap;
}

.brand-logo {
    width: 80px;
    height: auto;
    max-height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}

.brand-text {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.brand-winnergy {
    color: #8b95a8;
}

.brand-ai {
    color: #667eea;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 10px;
    color: white !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 4px 16px 16px;
    background: #ffffff !important;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8b95a8;
    margin-bottom: 8px;
    padding: 0 8px;
}

.session-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.session-item {
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    color: #5a6270;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.session-item:hover {
    background: #f4f6f9;
    color: #1a1a2e;
}

.session-item.active {
    background: #e0f2fe;
    color: #0284c7;
    font-weight: 600;
}

.session-icon {
    width: 32px;
    height: 32px;
    background: #f4f6f9;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.session-item.active .session-icon {
    background: white;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.2);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid #e8ecf4;
    background: #f8f9fc !important;
}

.db-stats {
    font-size: 12px;
    color: #5a6270;
    line-height: 1.6;
}

.db-stats strong {
    color: #1a1a2e;
    font-weight: 600;
}

/* ===== MAIN CONTENT ===== */
.chat-main {
    display: flex;
    flex-direction: column;
    background: #f8f9fc !important;
    overflow: hidden;
}

/* Top Navigation */
.top-nav {
    height: 55px;
    background: #ffffff !important;
    border-bottom: 1px solid #e8ecf4;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 8px;
}

.nav-tabs {
    display: none;
}

.nav-tab {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #5a6270;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    background: transparent;
}

.nav-tab:hover {
    color: #1a1a2e;
    background: #f4f6f9;
}

.nav-tab.active {
    color: #667eea;
    background: #e0f2fe;
    font-weight: 600;
}

.nav-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid #e8ecf4;
    background: white;
    color: #5a6270;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.icon-btn:hover {
    border-color: #667eea;
    color: #667eea;
    background: #e0f2fe;
}

.export-btn {
    padding: 10px 18px;
    background: white;
    border: 1px solid #e8ecf4;
    border-radius: 10px;
    color: #5a6270;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s;
}

.export-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 24px;
    gap: 20px;
    background: #f8f9fc !important;
    position: relative;
}

/* Welcome Screen */
.welcome-card {
    background: transparent !important;
    border-radius: 0 !important;
    padding: 40px 24px !important;
    text-align: center !important;
    box-shadow: none !important;
    border: none !important;
    max-width: 600px;
    margin: auto;
}

.welcome-icon {
    width: 56px;
    height: 56px;
    background: none;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
    color: #c0c7d3;
    color: #757575;
}

.welcome-card h1 {
    font-size: 16px !important;
    font-weight: 500 !important;
    color: #b0b8c4 !important;
    margin-bottom: 6px !important;
}

.welcome-card p {
    color: #c0c7d3 !important;
    font-size: 13px !important;
    margin-bottom: 20px !important;
    line-height: 1.5 !important;
}

.quick-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    justify-content: center !important;
}

.quick-action-btn {
    padding: 6px 14px !important;
    background: transparent !important;
    border: none !important;
    border-radius: 20px !important;
    color: #b0b8c4 !important;
    cursor: pointer !important;
    font-size: 13px !important;
    transition: all 0.15s !important;
    text-align: center !important;
    box-shadow: none !important;
}

.quick-action-btn:hover {
    background: #f0f2ff !important;
    color: #667eea !important;
}

.quick-action-btn strong {
    display: inline;
    font-weight: 500;
    font-size: 13px;
}

.quick-action-btn span {
    display: none;
}

/* Welcome message (app.js getWelcomeHtml) */
.welcome-message {
    background: transparent;
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    box-shadow: none;
    max-width: 520px;
    margin: 40px auto;
}
.welcome-message h1 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0 0 8px;
}
.welcome-message p {
    color: #8b95a8;
    font-size: 14px;
    margin: 0 0 24px;
    line-height: 1.5;
}
.welcome-message .suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.welcome-message .suggestions button {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #e8ecf4;
    border-radius: 20px;
    color: #667eea;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.15s;
}
.welcome-message .suggestions button:hover {
    background: #f0f2ff;
    border-color: #667eea;
}

/* Messages */
.messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 15px;
    max-width: 800px;
    min-width: 300px;
    margin: 0 auto;
    width: 100%;
}

.app.panel-closed .messages {
    max-width: calc(70%);
    margin: 0 auto;
}

.message {
    display: flex;
    align-items: flex-start;
    animation: fadeIn 0.3s ease;
    width: 100%;
}

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

.message-avatar { display: none; }

.message-content {
    line-height: 1.7;
    font-size: 15px;
    color: #1a1a2e;
    overflow-x: auto;
}
.message-content::-webkit-scrollbar {
    height: 6px;
}
.message-content::-webkit-scrollbar-track {
    background: transparent;
}
.message-content::-webkit-scrollbar-thumb {
    background: #d0d5dd;
    border-radius: 3px;
}
.message-content::-webkit-scrollbar-thumb:hover {
    background: #8b95a8;
}

/* Reply quote block inside user bubble */
.reply-quote {
    background: rgba(102, 126, 234, 0.1);
    border-left: 3px solid #667eea;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #4a5568;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Reply selection floating button */
.reply-selection-btn {
    position: fixed;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 5px;
    background: #fff;
    border: 1px solid #e8ecf4;
    border-radius: 20px;
    padding: 6px 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: #667eea;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
}
.reply-selection-btn:hover {
    background: #f0f2ff;
    border-color: #667eea;
}
.reply-selection-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* User messages: bubble right-aligned, edit button far right bottom */
.message.user {
    justify-content: flex-end;
    align-items: flex-end;
    gap: 8px;
}

.message.user .user-bubble {
    background: #e8effa;
    padding: 15px 16px;
    border-radius: 18px 18px 4px 18px;
    width: fit-content;
    max-width: min(80%, calc(100% - 50px));
    color: #1a1a2e;
}

.message.user .edit-message-btn {
    opacity: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #8b95a8;
    padding: 4px;
    flex-shrink: 0;
    transition: opacity 0.15s;
    order: 99;
}
.message.user:hover .edit-message-btn { opacity: 0.7; }

/* Assistant messages: no background, full width matching input area */
.message.assistant {
    justify-content: flex-start;
}
.message.assistant .message-content {
    background: transparent;
    padding: 4px 0;
    border: none;
    box-shadow: none;
    width: 100%;
    max-width: 100%;
}

.message-content p {
    margin-bottom: 12px;
    color: #1a1a2e;
}

.message-content strong {
    color: #1a1a2e;
    font-weight: 600;
}

.message-content code {
    background: #f4f6f9;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'SF Mono', monospace;
    font-size: 13px;
    color: #667eea;
}

.message-content pre {
    background: #f8f9fc;
    padding: 16px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 12px 0;
}

/* Markdown Tables */
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 0 1px #e8ecf4;
}

.message-content th {
    background: #f8f9fc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #1a1a2e;
    border-bottom: 2px solid #e8ecf4;
}

.message-content td {
    padding: 12px 16px;
    border-bottom: 1px solid #e8ecf4;
    color: #4a5568;
}

.message-content tr:last-child td {
    border-bottom: none;
}

.message-content tr:nth-child(even) {
    background: #fafbfc;
    border: 1px solid #e8ecf4;
}

.message-content hr {
    margin: 20px 0 8px 0;
}

/* Sources */
.sources {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e8ecf4;
}

.sources-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8b95a8;
    margin-bottom: 10px;
}

.source-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.source-tag {
    font-size: 12px;
    padding: 6px 12px;
    background: #f0f2f5;
    border-radius: 20px;
    color: #4a5568;
    font-weight: 500;
}

a.source-tag.web-source {
    background: #eff6ff;
    color: #2563eb;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
}

a.source-tag.web-source:hover {
    background: #dbeafe;
    text-decoration: underline;
}

.globe-icon {
    display: inline-block;
    transform: rotate(-23.5deg);
}

/* Input Area */
.input-area {
    background: white;
    border-radius: 28px;
    padding: 14px;
    border: 1px solid #e8ecf4;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    max-width: 800px;
    min-width: 300px;
    width: 100%;
    margin: 8px auto;
}

.input-area-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.mode-toggles {
    display: flex;
    gap: 8px;
}

.mode-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: white;
    border: 1px solid #e8ecf4;
    border-radius: 20px;
    color: #5a6270;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s;
}

.mode-toggle-btn:hover {
    background: #f4f6f9;
}

.mode-toggle-btn.previsit-toggle.active {
    background: #d1fae5;
    border-color: #10b981;
    color: #059669;
}

.mode-toggle-btn.realtime-toggle.active {
    background: #e0f2fe;
    border-color: #667eea;
    color: #0284c7;
}

.mode-toggle-btn.competitor-toggle.active {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #d97706;
}

.competitor-label {
    line-height: 1.1;
    text-align: left;
    font-size: 11px;
}

.state-mode-badge.competitor {
    background: #fef3c7;
    color: #d97706;
}

/* Scroll to Bottom Button */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 160px;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    color: #5a6270;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    z-index: 10;
    transition: opacity 0.2s, transform 0.2s;
    opacity: 0;
    outline: none;
}

.scroll-to-bottom-btn.visible {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.scroll-to-bottom-btn:hover {
    background: rgba(255, 255, 255, 1);
    color: #667eea;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.16);
}

/* Web Search Toggle Button */
button.web-search-btn {
    width: 28px;
    height: 28px;
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 0 4px 0 !important;
    color: #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    transition: color 0.2s;
    flex-shrink: 0;
    -webkit-appearance: none;
    appearance: none;
}

button.web-search-btn .globe-icon {
    font-size: 18px;
}

button.web-search-btn .globe-svg {
    width: 18px;
    height: 18px;
}

button.web-search-btn:hover,
button.web-search-btn:focus,
button.web-search-btn:focus-visible,
button.web-search-btn:active {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    background: none !important;
}

.web-search-btn:hover {
    color: #bfc5cf;
}

.web-search-btn.active {
    color: #3b82f6;
}

.input-container {
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid #e8ecf4;
    border-radius: 20px;
    padding: 8px 12px;
    gap: 4px;
    transition: all 0.15s;
}

.input-container .input-row-top {
    display: flex;
    width: 100%;
}

.input-container .input-row-bottom {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.input-container:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#messageInput {
    width: 100%;
    background: transparent;
    border: none;
    color: #1a1a2e;
    font-size: 15px;
    resize: none;
    max-height: 150px;
    min-height: 24px;
    line-height: 1.4;
    padding: 8px 8px 4px;
    outline: none;
    font-family: inherit;
    text-align: left;
}

#messageInput::placeholder {
    color: #8b95a8;
}

.send-btn {
    width: 36px;
    height: 36px;
    margin-bottom: 0;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #8b95a8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.send-btn:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.08);
}

.input-footer {
    display: none;
}

.state-mode-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.state-mode-badge.previsit {
    background: #d1fae5;
    color: #059669;
}

.state-mode-badge.realtime {
    background: #e0f2fe;
    color: #0284c7;
}

/* ===== RIGHT PANEL ===== */
.context-panel {
    background: #ffffff !important;
    border-left: 1px solid #e8ecf4;
    display: flex;
    flex-direction: column;
    width: 360px;
    flex-shrink: 0;
    transition: width 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
    overflow: hidden;
}

.context-panel.closed {
    width: 0;
    opacity: 0;
    border-left: none;
    margin: 0;
    padding: 0;
}

.context-panel.closed .panel-content,
.context-panel.closed .panel-header {
    display: none;
}

/* Memory State is toggled via header button only */

.panel-header {
    height: 55px;
    padding: 0 24px;
    border-bottom: 1px solid #e8ecf4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
}

.panel-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a2e;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-title-icon {
    width: 32px;
    height: 32px;
    background: #e0f2fe;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667eea;
}

.panel-close {
    width: 28px;
    height: 28px;
    border: none;
    background: #f4f6f9;
    color: #5a6270;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.15s;
}

.panel-close:hover {
    background: #e8ecf4;
    color: #1a1a2e;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fc !important;
}

/* Info Cards */
.info-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #e8ecf4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.info-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #1a1a2e;
}

.info-card-icon {
    width: 24px;
    height: 24px;
    background: #f4f6f9;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.info-field {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #f4f6f9;
    font-size: 13px;
}

.info-field:last-child {
    border-bottom: none;
}

.info-label {
    color: #5a6270;
    min-width: 90px;
    flex-shrink: 0;
}

.info-value {
    color: #1a1a2e;
    font-weight: 600;
    text-align: left;
}

.info-value.highlight {
    color: #667eea;
}

/* Loading */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.thinking-status {
    padding: 8px 0;
}

/* Thinking content - no background/border during processing */
.message.assistant .message-content.thinking-content {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 8px 16px;
}

.thinking-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
    color: #b0b8c4;
    font-size: 14px;
    line-height: 1.3;
    opacity: 0.45;
    filter: grayscale(50%);
    transition: opacity 0.3s, filter 0.3s;
}

.thinking-step.current {
    color: #9e9e9e;
    font-weight: 600;
    opacity: 0.7;
    filter: grayscale(50%);
}

/* Thinking Dots Animation */
.thinking-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
    margin-left: 4px;
}

.thinking-dots span {
    width: 4px;
    height: 4px;
    background: currentColor;
    border-radius: 50%;
    animation: thinkingDots 1.4s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }
.thinking-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes thinkingDots {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Collapsible thinking summary */
.thinking-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: #9e9e9e;
    font-size: 13px;
    padding: 4px 0;
    user-select: none;
    opacity: 0.7;
    filter: grayscale(100%);
}
.thinking-summary:hover { opacity: 1; }

.thinking-summary-arrow {
    transition: transform 0.2s;
    font-size: 12px;
}
.thinking-summary.expanded .thinking-summary-arrow {
    transform: rotate(90deg);
}

/* Steps log - hidden by default, shown when expanded */
.thinking-steps-log {
    display: none;
    padding-left: 20px;
}
.thinking-summary.expanded + .thinking-steps-log {
    display: block;
}
.thinking-log-item {
    color: #b0b8c4;
    font-size: 13px;
    padding: 2px 0;
    opacity: 0.6;
    filter: grayscale(100%);
}

/* Error & Info */
.error-message {
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    color: #dc2626;
    font-size: 14px;
}

.info-message {
    padding: 12px 16px;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    color: #0284c7;
    font-size: 14px;
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 20px;
    background: white;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid #e8ecf4;
    color: #1a1a2e;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}

.notification.success {
    border-left: 4px solid #10b981;
}

.notification.error {
    border-left: 4px solid #dc2626;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d0d5dd;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #8b95a8;
}

/* Responsive */
@media (max-width: 1200px) {
    .app > .sidebar {
        width: 260px;
    }
    .app > .context-panel {
        position: fixed;
        right: 0;
        top: 0;
        height: 100vh;
        width: 360px;
        z-index: 100;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    .app > .context-panel.open {
        transform: translateX(0);
    }
    .app > .context-panel.closed {
        width: 0;
        transform: translateX(100%);
    }
}

@media (max-width: 768px) {
    .app > .sidebar {
        display: none;
    }
    .quick-actions {
        flex-direction: column;
        align-items: center;
    }
}

/* Streaming Content Styles - use .message-content prefix for higher specificity */
.message-content .streaming-content {
    font-size: 15px;
    line-height: 1.4;
    color: #1a1a2e;
    word-break: break-word;
    min-height: 1.5em;
}

/* Override .message-content p with higher specificity */
.message-content .streaming-content p {
    margin: 0 0 2px 0 !important;
    line-height: 1.4;
}

.message-content .streaming-content p:last-child {
    margin-bottom: 0 !important;
}

.message-content .streaming-content br {
    display: block;
    content: "";
    margin: 0;
    line-height: 0.5;
}

.message-content .streaming-content h1,
.message-content .streaming-content h2,
.message-content .streaming-content h3,
.message-content .streaming-content h4 {
    margin: 18px 0 0 0 !important;
    line-height: 1.3;
}

.message-content .streaming-content h1:first-child,
.message-content .streaming-content h2:first-child,
.message-content .streaming-content h3:first-child {
    margin-top: 0 !important;
}

.message-content .streaming-content hr {
    margin: 20px 0 8px 0 !important;
}

.message-content .streaming-content ul,
.message-content .streaming-content ol {
    margin: 2px 0 !important;
    padding-left: 1.5em;
}

.message-content .streaming-content li {
    margin: 0 !important;
    line-height: 1.4;
}

.message-content .streaming-content li p {
    margin: 0 !important;
}

.message-content .streaming-content blockquote {
    margin: 2px 0 !important;
}

.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: #667eea;
    margin-left: 2px;
    animation: blink 1s infinite;
    vertical-align: middle;
}

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

/* Sources and Model Badge Styles */
.sources {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

.sources-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.sources-title {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.model-badge {
    font-size: 11px;
    font-weight: 500;
    color: #6366f1;
    background: #eef2ff;
    padding: 2px 8px;
    border-radius: 12px;
}

.source-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Memory State Dropdown Styles */
.info-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 8px;
    margin: -12px -16px 12px -16px;
    font-weight: 600;
    color: #374151;
    transition: background 0.2s;
}

.info-card-header:hover {
    background: #f3f4f6;
}

.dropdown-arrow {
    font-size: 12px;
    color: #6b7280;
    transition: transform 0.2s;
}

.info-card-header.collapsed .dropdown-arrow {
    transform: rotate(-90deg);
}

.info-card-content {
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    max-height: 1000px;
}

.info-card-content.collapsed {
    max-height: 0;
}

/* Memory Sources Styles */
.memory-source-tag {
    display: inline-block;
    font-size: 11px;
    color: #374151;
    background: #e0e7ff;
    padding: 4px 10px;
    border-radius: 6px;
    margin: 2px;
}

a.memory-source-tag.web-source {
    background: #eff6ff;
    color: #2563eb;
    text-decoration: none;
    cursor: pointer;
}

a.memory-source-tag.web-source:hover {
    background: #dbeafe;
    text-decoration: underline;
}

.memory-sources-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 0;
}

/* Model Selector Styles */
.model-selector {
    margin-left: auto;
}

.model-selector select {
    padding: 6px 24px 6px 10px;
    border: none;
    background: transparent;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23374151' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    text-align: right;
}

/* ============================================
   EDIT MESSAGE BUTTON - INLINE WITH TEXT
   ============================================ */

/* Edit button styling */
.edit-message-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    height: auto !important;
    min-width: 20px !important;
    min-height: 20px !important;
    background: transparent !important;
    border: none !important;
    color: #9ca3af !important;
    font-size: 16px !important;
    cursor: pointer !important;
    padding: 0 !important;
    border-radius: 4px !important;
    margin: 0 !important;
    line-height: 1 !important;
    opacity: 0.5 !important;
    transition: all 0.2s !important;
    transform: scaleX(-1) !important; /* Flip horizontally so pencil tip points left */
    flex-shrink: 0 !important;
    vertical-align: middle !important;
    position: static !important;
}

.edit-message-btn:hover {
    background: #f3f4f6 !important;
    color: #6b7280 !important;
    opacity: 1 !important;
}

/* User message container layout */
.message.user {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-end !important;
    justify-content: flex-end !important;
    gap: 8px !important;
}

/* Message content with edit button - flex column to push edit btn to bottom */
.message.user .message-content.user-message-with-edit {
    display: flex !important;
    flex-direction: column !important;
    padding: 12px 16px !important;
    background: white !important;
    border-radius: 16px 16px 4px 16px !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06) !important;
    border: 1px solid #e8ecf4 !important;
    max-width: 50% !important;
    order: 1 !important;
    width: auto !important;
}

/* Message text */
.message.user .message-content.user-message-with-edit .message-text {
    display: block !important;
    line-height: 1.5 !important;
    width: auto !important;
    white-space: normal !important;
}

/* Edit button pinned to bottom-right */
.message.user .message-content.user-message-with-edit .edit-message-btn {
    display: inline-flex !important;
    align-self: flex-end !important;
    margin-top: 4px !important;
    margin-left: 0 !important;
}

/* Remove default margins from paragraphs inside message text */
.message-content.user-message-with-edit .message-text p {
    display: block !important;
    margin: 0 !important;
}

/* Show edit button on hover */
.message-content.user-message-with-edit:hover .edit-message-btn {
    opacity: 0.7 !important;
}

/* User avatar */
.message.user .message-avatar {
    order: 2 !important;
    margin-left: 0 !important;
    flex-shrink: 0 !important;
    align-self: flex-end !important;
}

/* ============================================================
   PAGE SYSTEM - Sessions List & Work-Board
   ============================================================ */

.page {
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* ===== Sessions Page ===== */
#page-sessions {
    display: flex;
    flex-direction: column;
    background: #f8f9fc;
}

.sessions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: #fff;
    border-bottom: 1px solid #e8ecf4;
    flex-shrink: 0;
}

.sessions-header .brand {
    margin-bottom: 0;
}

.sessions-header .new-chat-btn {
    width: auto;
    padding: 10px 20px;
}

.sessions-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.sessions-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.sessions-title {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a2e;
}

.clear-all-btn {
    background: none;
    border: 1px solid #e0e4ea;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    color: #8b95a8;
    cursor: pointer;
    transition: all 0.15s;
}

.clear-all-btn:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: #fef2f2;
}

.sessions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.session-card {
    background: #fff;
    border: 1px solid #e8ecf4;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.session-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.12);
    transform: translateY(-1px);
}

.session-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.session-card-name {
    font-weight: 600;
    font-size: 15px;
    color: #1a1a2e;
    flex: 1;
    margin-left: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-card-rename-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #8b95a8;
    padding: 4px;
    border-radius: 4px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.15s;
    transform: scaleX(-1);
}

.session-card:hover .session-card-rename-btn {
    opacity: 1;
}

.session-card-rename-btn:hover {
    color: #667eea;
    background: #f0f2ff;
}

.session-card-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #8b95a8;
    padding: 4px;
    border-radius: 4px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.15s;
}

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

.session-card-delete-btn:hover {
    color: #ef4444;
    background: #fef2f2;
}

.session-card-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.session-card-avatar-default {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8effa 0%, #f0ebf7 100%);
    color: #8b95a8;
}

.session-card-rename-input {
    font-size: 15px;
    font-weight: 600;
    border: 1px solid #667eea;
    border-radius: 6px;
    padding: 4px 8px;
    outline: none;
    width: 100%;
}

.session-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #8b95a8;
}

.session-card-mode {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.session-card-mode.previsit { background: #e8f5e9; color: #2e7d32; }
.session-card-mode.realtime { background: #fce4ec; color: #c62828; }

.sessions-footer {
    padding: 12px 32px;
    background: #fff;
    border-top: 1px solid #e8ecf4;
    flex-shrink: 0;
}

.sessions-footer .db-stats {
    font-size: 12px;
    color: #8b95a8;
    padding: 0;
    background: none;
    border: none;
}

/* System Flow Button */
.system-flow-btn {
    position: fixed;
    bottom: 20px;
    right: 24px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #e8ecf4;
    color: #4a5568;
    border: 1px solid #d1d9e6;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    transition: background 0.2s, box-shadow 0.2s;
    z-index: 100;
}
.system-flow-btn:hover {
    background: #dce1ed;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}


/* ===== Work-Board Page ===== */
#page-workboard {
    display: flex;
    flex-direction: column;
}

.workboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #fff;
    border-bottom: 1px solid #e8ecf4;
    flex-shrink: 0;
    height: 50px;
}

.workboard-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid #e8ecf4;
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    color: #555;
    font-size: 13px;
    transition: all 0.15s;
}

.back-btn:hover {
    background: #f0f2ff;
    border-color: #667eea;
    color: #667eea;
}

.workboard-session-name {
    font-weight: 600;
    font-size: 15px;
    color: #1a1a2e;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workboard-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== 3-Panel Resizable Layout ===== */
.workboard {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.panel {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.panel-left {
    width: 280px;
    min-width: 200px;
    max-width: 500px;
    border-right: 1px solid #e8ecf4;
    overflow-y: auto;
}

.panel-center {
    flex: 1;
    min-width: 300px;
    background: #f0f2f5;
    display: flex;
    flex-direction: column;
}

.panel-right {
    width: 400px;
    min-width: 300px;
    max-width: 700px;
    border-left: 1px solid #e8ecf4;
    display: flex;
    flex-direction: column;
}

/* Panel-left reuses the same info-card styles from context-panel */
.panel-left .panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e8ecf4;
    flex-shrink: 0;
}

.panel-left .panel-title {
    font-weight: 600;
    font-size: 14px;
    color: #1a1a2e;
}

.panel-left .panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Panel-right chat container */
.panel-right .chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.panel-right .messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* ===== Resize Handles ===== */
.resize-handle {
    width: 6px;
    cursor: col-resize;
    background: transparent;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    transition: background 0.15s;
}

.resize-handle:hover,
.resize-handle.active {
    background: #667eea;
}

.resize-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 30px;
    background: #ccc;
    border-radius: 1px;
    transition: background 0.15s;
}

.resize-handle:hover::after,
.resize-handle.active::after {
    background: #fff;
}

/* ===== PDF Viewer ===== */
.pdf-tab-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    background: #e8ecf4;
    min-height: 38px;
    overflow-x: auto;
    flex-shrink: 0;
}
.pdf-tab-bar::-webkit-scrollbar {
    height: 6px;
}
.pdf-tab-bar::-webkit-scrollbar-track {
    background: transparent;
}
.pdf-tab-bar::-webkit-scrollbar-thumb {
    background: #d0d5dd;
    border-radius: 3px;
}
.pdf-tab-bar::-webkit-scrollbar-thumb:hover {
    background: #8b95a8;
}

.pdf-tab-placeholder {
    color: #8b95a8;
    font-size: 13px;
    padding: 4px 8px;
}

.pdf-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: #fff;
    border: 1px solid #dde0e7;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    max-width: 180px;
    white-space: nowrap;
    transition: all 0.15s;
}

.pdf-tab.active {
    background: #e0e7ff;
    color: #4338ca;
    border-color: #a5b4fc;
}

.pdf-tab-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdf-tab-close {
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.5;
    flex-shrink: 0;
}

.pdf-tab-close:hover {
    opacity: 1;
}

.pdf-tab.active .pdf-tab-close {
    color: #4338ca;
}

.pdf-viewer-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    position: relative;
    background: #e8ecf0;
}
.pdf-viewer-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.pdf-viewer-container::-webkit-scrollbar-track {
    background: transparent;
}
.pdf-viewer-container::-webkit-scrollbar-thumb {
    background: #d0d5dd;
    border-radius: 3px;
}
.pdf-viewer-container::-webkit-scrollbar-thumb:hover {
    background: #8b95a8;
}

.pdf-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #8b95a8;
    text-align: center;
    padding: 40px;
    gap: 12px;
}

.pdf-placeholder p {
    font-size: 14px;
    line-height: 1.5;
}

.pdf-page-wrapper {
    margin-bottom: 12px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    border-radius: 4px;
    overflow: hidden;
    transition: box-shadow 0.3s;
}

.pdf-page-highlight {
    box-shadow: 0 0 0 3px #ffd54f, 0 2px 12px rgba(255, 213, 79, 0.4) !important;
}

.pdf-page-number {
    padding: 4px 12px;
    font-size: 11px;
    color: #8b95a8;
    background: transparent;
    border: none;
}

.pdf-page-canvas {
    display: block;
    max-width: 100%;
}

.pdf-page-indicator {
    position: sticky;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 4px 14px;
    border-radius: 16px;
    font-size: 12px;
    text-align: center;
    width: fit-content;
    margin: 0 auto;
    z-index: 5;
    pointer-events: none;
}

/* ===== Clickable source tags in chat ===== */
.source-tag.clickable {
    cursor: pointer;
    border: 1px solid #667eea;
    color: #667eea;
}

.source-tag.clickable:hover {
    background: #667eea;
    color: #fff;
}

/* ===== Toggle panel-left collapsed ===== */
.panel-left.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    overflow: hidden;
    border: none;
    padding: 0;
}

/* ===== Adaptive Layout: hide center panel when no PDF ===== */
.panel-center.hidden {
    display: none !important;
}
.resize-handle.hidden {
    display: none !important;
}
.panel-right.full-width {
    flex: 1;
    width: auto !important;
    max-width: none !important;
}

/* ===== PDF Text Layer (selectable text overlay) ===== */
.pdf-page-container {
    position: relative;
    overflow: hidden;
}
.pdf-text-layer {
    position: absolute;
    top: 0;
    left: 0;
    overflow: visible;
    opacity: 1;
    line-height: 1;
    z-index: 2;
    pointer-events: all;
    user-select: text;
    -webkit-user-select: text;
}
.pdf-text-layer br {
    display: none;
}
.pdf-text-layer span {
    position: absolute;
    white-space: pre;
    color: transparent;
    cursor: text;
    pointer-events: all;
    transform-origin: 0% 0%;
}
.pdf-text-layer span::selection {
    background: rgba(0, 100, 255, 0.3);
    color: transparent;
}
.pdf-text-layer span::-moz-selection {
    background: rgba(0, 100, 255, 0.3);
    color: transparent;
}

/* ===== Chunk highlight (yellow background) ===== */
.pdf-chunk-highlight {
    background: rgba(255, 235, 59, 0.5) !important;
    color: transparent !important;
    border-radius: 2px;
}

/* ===== PDF Search bar ===== */
.pdf-search-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0;
    padding: 6px 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-left: auto;
    width: fit-content;
}
.pdf-search-bar input {
    border: none;
    outline: none;
    font-size: 13px;
    width: 135px;
    font-family: inherit;
}
.pdf-search-bar .search-count {
    font-size: 12px;
    color: #8b95a8;
    white-space: nowrap;
    min-width: 40px;
    text-align: center;
}
.pdf-search-bar button {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1;
}
.pdf-search-bar button:hover {
    background: #f3f4f6;
    color: #374151;
}
mark.pdf-search-highlight {
    background: rgba(255, 235, 59, 0.45) !important;
    color: transparent !important;
    border-radius: 2px;
    padding: 0;
}
mark.pdf-search-highlight-active {
    background: rgba(255, 152, 0, 0.6) !important;
    color: transparent !important;
    border-radius: 2px;
    padding: 0;
}

/* ===== Send/Mic button states ===== */
.send-btn.recording {
    background: #ef4444 !important;
    animation: pulse-recording 1.2s ease-in-out infinite;
}
@keyframes pulse-recording {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ===== Chat container: maximize space, reduce padding first on resize ===== */
.panel-right .chat-container {
    padding: 0 10px;
    gap: 0;
}
.panel-right .messages {
    padding: clamp(4px, 2%, 16px);
}
.panel-right .input-area {
    flex-shrink: 0;
}
.input-area-header .mode-toggles {
    flex-wrap: wrap;
}

/* ===== Tools Menu ===== */
.tools-menu-wrapper {
    position: relative;
}

.tools-add-btn {
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: #b0b8c4;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.tools-add-btn:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.08);
}

.tools-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: white;
    border: 1px solid #e8ecf4;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    min-width: 180px;
    padding: 6px;
    z-index: 100;
}

.tools-popup-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #5a6270;
    transition: all 0.1s;
}

.tools-popup-item:hover {
    background: #f0f2ff;
    color: #667eea;
}

.tools-popup-item.active {
    background: #e0f2fe;
    color: #0284c7;
}

.active-tools {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.active-tool-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #e0f2fe;
    border-radius: 12px;
    font-size: 11px;
    color: #0284c7;
    cursor: pointer;
}

.active-tool-chip:hover {
    background: #bae6fd;
}

.active-tool-chip .chip-remove {
    font-size: 13px;
    line-height: 1;
    opacity: 0.6;
}

.active-tool-chip .chip-remove:hover {
    opacity: 1;
}

/* ===== Customer Card ===== */
.customer-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid #e8ecf4;
}

.customer-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e8effa 0%, #f0ebf7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #8b95a8;
    overflow: hidden;
    cursor: pointer;
    transition: opacity 0.15s;
}

.customer-avatar:hover {
    opacity: 0.8;
}

.customer-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.customer-info {
    flex: 1;
    min-width: 0;
}

.customer-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.customer-name {
    font-weight: 600;
    font-size: 15px;
    color: #1a1a2e;
    outline: none;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.15s;
    flex: 1;
    min-width: 0;
}

.customer-name:hover,
.customer-name:focus {
    border-bottom-color: #667eea;
}

.customer-save-btn {
    background: #667eea;
    border: none;
    cursor: pointer;
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.customer-save-btn:hover {
    background: #5a6fd6;
}

.customer-meta {
    font-size: 12px;
    color: #8b95a8;
    margin-top: 2px;
    outline: none;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.15s;
}

.customer-meta:hover,
.customer-meta:focus {
    border-bottom-color: #667eea;
}

/* ===== Memory Chain Items ===== */
.memory-chain-item {
    padding: 6px 0;
    border-bottom: 1px solid #f0f2f5;
    font-size: 12px;
}

.memory-chain-turn {
    font-weight: 600;
    color: #667eea;
    font-size: 11px;
}

.memory-chain-query {
    color: #1a1a2e;
    margin: 2px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.memory-chain-summary {
    color: #8b95a8;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ===== Model selector inline (inside input area) ===== */
.model-selector-inline {
    flex-shrink: 0;
}
.model-selector-inline select {
    background: transparent;
    border: none;
    padding: 4px 16px 4px 2px;
    font-size: 13px;
    color: #8b95a8;
    cursor: pointer;
    outline: none;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b95a8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 2px center;
}
.model-selector-inline select:hover {
    color: #667eea;
}

/* ===== Source reference cards ===== */
.source-ref-card {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #f8f9fc;
    border: 1px solid #e8ecf4;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 12px;
    margin-bottom: 2px;
}
.source-ref-card:hover {
    border-color: #667eea;
    background: #f0f2ff;
}
.source-ref-icon {
    flex-shrink: 0;
    font-size: 16px;
}
.source-ref-info {
    flex: 1;
    min-width: 0;
}
.source-ref-title {
    font-weight: 600;
    color: #1a1a2e;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.source-ref-detail {
    color: #8b95a8;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Toggle PDF panel button ===== */
.toggle-pdf-btn {
    background: none;
    border: 1px solid #e8ecf4;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    color: #8b95a8;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}
.toggle-pdf-btn:hover {
    border-color: #667eea;
    color: #667eea;
}
.toggle-pdf-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .sessions-grid {
        grid-template-columns: 1fr;
    }
    .panel-left { width: 0; min-width: 0; overflow: hidden; }
    .panel-right { width: 100%; min-width: 0; }
    .resize-handle { display: none; }
}
