:root {
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-300: #93c5fd;
    --blue-400: #60a5fa;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(180deg, var(--blue-50) 0%, #f0f4f8 100%);
    color: var(--gray-800);
    height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* --- Header --- */
header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-100);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.paul-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
}

.paul-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--gray-800);
}

.paul-status {
    font-size: 12px;
    color: var(--blue-500);
}

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

.model-select {
    padding: 4px 8px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    color: var(--gray-600);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 18px;
    background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 8 5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L4 4L7 1' stroke='%239ca3af' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
}

.model-select:hover {
    border-color: var(--blue-300);
    color: var(--blue-600);
}

.cost-badge {
    background: var(--blue-100);
    color: var(--blue-600);
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
}

.debug-toggle {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.debug-toggle:hover {
    background: var(--blue-100);
    color: var(--blue-500);
}

/* --- Sovereignty banner --- */
.sovereignty {
    background: linear-gradient(90deg, #002395 0%, #002395 33%, #fff 33%, #fff 66%, #ED2939 66%, #ED2939 100%);
    height: 3px;
}

/* --- Source badge on answers --- */
.source-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    margin-bottom: 10px;
    width: fit-content;
}

.source-badge.from-files {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.source-badge.not-found {
    background: #fef3c7;
    color: #d97706;
    border: 1px solid #fde68a;
}

.source-badge.unknown {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

/* --- Learning counter --- */
.learning-counter {
    font-size: 11px;
    color: var(--gray-400);
    display: flex;
    align-items: center;
    gap: 4px;
}

.learning-counter .count {
    color: var(--blue-500);
    font-weight: 600;
}

/* --- Status bar --- */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--white);
    border-top: 1px solid var(--gray-100);
    font-size: 12px;
    color: var(--gray-400);
}

.status-bar .sync-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sync-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
    margin-right: 2px;
}

.status-bar strong {
    color: var(--blue-600);
}

/* --- Chat area --- */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* --- Welcome --- */
.welcome {
    text-align: center;
    padding: 60px 20px 40px;
    color: var(--gray-500);
}

.welcome-avatar {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 30px;
    margin: 0 auto 20px;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}

.welcome h2 {
    color: var(--gray-800);
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 10px;
}

.welcome p {
    font-size: 15px;
    line-height: 1.6;
    max-width: 420px;
    margin: 0 auto;
    color: var(--gray-500);
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
}

.suggestion {
    padding: 10px 18px;
    background: var(--white);
    border: 1px solid var(--blue-200);
    border-radius: 24px;
    font-size: 13px;
    color: var(--blue-600);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.suggestion:hover {
    background: var(--blue-50);
    border-color: var(--blue-400);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* --- Messages --- */
.message {
    display: flex;
    gap: 10px;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

.message.paul .message-avatar {
    background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
    color: white;
}

.message.user .message-avatar {
    background: var(--gray-200);
    color: var(--gray-600);
}

.message-bubble {
    padding: 16px 20px;
    border-radius: var(--radius);
    line-height: 1.7;
    font-size: 15px;
    max-width: 85%;
}

.message.paul .message-bubble {
    background: var(--white);
    border: 1px solid var(--blue-100);
    box-shadow: var(--shadow-md);
}

.message.paul .message-bubble strong {
    color: var(--gray-900);
}

.message.paul .message-bubble em {
    color: var(--gray-500);
    font-size: 13px;
}

.message.paul .message-bubble code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'SF Mono', 'Menlo', monospace;
    color: var(--blue-600);
}

.message.paul .message-bubble pre {
    background: var(--gray-900);
    color: var(--gray-300);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 12px 0;
    font-size: 13px;
    line-height: 1.5;
}

.message.paul .message-bubble pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
    color: white;
    box-shadow: var(--shadow);
}

/* --- Message actions --- */
.message-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--gray-100);
}

.action-btn {
    padding: 4px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    background: var(--white);
    font-size: 11px;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.action-btn:hover {
    border-color: var(--blue-300);
    color: var(--blue-600);
    background: var(--blue-50);
}

.action-btn.correct:hover {
    border-color: #fca5a5;
    color: #dc2626;
    background: #fef2f2;
}

.action-btn.remember:hover {
    border-color: #86efac;
    color: #16a34a;
    background: #f0fdf4;
}

/* --- Correction dialog --- */
.correction-dialog {
    margin-top: 8px;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: var(--radius-sm);
    display: none;
}

.correction-dialog.visible {
    display: block;
}

.correction-dialog textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    outline: none;
    margin: 6px 0;
}

.correction-dialog textarea:focus {
    border-color: #dc2626;
}

.correction-dialog .correction-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.correction-dialog button {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    border: none;
}

.btn-cancel {
    background: var(--gray-100);
    color: var(--gray-600);
}

.btn-save-correction {
    background: #dc2626;
    color: white;
}

.btn-save-memory {
    background: #16a34a;
    color: white;
}

/* --- Remember toast --- */
.remember-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #16a34a;
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.remember-toast.visible {
    opacity: 1;
}

/* --- Source citations --- */
.source-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 12px;
    font-family: 'SF Mono', 'Menlo', monospace;
    color: var(--gray-600);
    text-decoration: none;
    margin: 3px 2px;
    transition: all 0.15s;
}

.source-link:hover {
    background: var(--blue-50);
    border-color: var(--blue-300);
    color: var(--blue-600);
}

/* --- Progress indicator --- */
.progress {
    display: flex;
    gap: 10px;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
}

.progress-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-content {
    padding: 10px 14px;
    background: var(--white);
    border: 1px solid var(--blue-100);
    border-radius: var(--radius);
    flex: 1;
    max-width: 85%;
}

.progress-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--blue-600);
    margin-bottom: 8px;
}

.progress-label {
    font-weight: 500;
}

.progress-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--blue-200);
    border-top-color: var(--blue-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.progress-steps {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--gray-500);
}

.progress-step.active {
    color: var(--blue-600);
}

.progress-step.done {
    color: var(--gray-400);
}

.step-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.step-icon.spinning {
    animation: spin 1s linear infinite;
}

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

.progress-file {
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 11px;
    color: var(--blue-500);
    background: var(--blue-50);
    padding: 1px 6px;
    border-radius: 3px;
}

/* --- Input area --- */
.input-area {
    background: var(--white);
    border-top: 1px solid var(--gray-100);
    padding: 16px 20px;
    flex-shrink: 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.03);
}

.input-wrapper {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.input-field-wrapper {
    flex: 1;
    position: relative;
}

.input-field {
    flex: 1;
    padding: 14px 18px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 52px;
    max-height: 120px;
    line-height: 1.5;
    background: var(--white);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input-field:focus {
    border-color: var(--blue-400);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.08);
}

.input-field::placeholder {
    color: var(--gray-400);
}

.send-button {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.send-button:hover {
    background: linear-gradient(135deg, var(--blue-600), #1d4ed8);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.send-button:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.3);
}

.send-button:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* --- Debug panel --- */
.debug-panel {
    display: none;
    background: var(--gray-900);
    color: var(--gray-300);
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 11px;
    padding: 12px;
    max-height: 150px;
    overflow-y: auto;
    border-top: 2px solid var(--blue-500);
}

.debug-panel.visible {
    display: block;
}

.debug-line {
    padding: 1px 0;
}

.debug-line .timestamp {
    color: var(--gray-500);
}

.debug-line .tool {
    color: var(--blue-400);
}

.debug-line .path {
    color: #86efac;
}

/* --- Tables in responses --- */
.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.message-bubble th,
.message-bubble td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.message-bubble th {
    font-weight: 600;
    color: var(--gray-700);
    background: var(--gray-50);
}

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

/* --- Headings in responses --- */
.message-bubble h2 {
    font-size: 16px;
    font-weight: 700;
    margin: 16px 0 6px;
    color: var(--gray-800);
}

.message-bubble h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 14px 0 4px;
    color: var(--gray-800);
}

.message-bubble h4 {
    font-size: 14px;
    font-weight: 700;
    margin: 12px 0 4px;
    color: var(--gray-700);
}

/* --- Source links in responses --- */
.message-bubble a[target="_blank"] {
    display: inline-block;
    padding: 2px 8px;
    background: var(--blue-50);
    border: 1px solid var(--blue-200);
    border-radius: 12px;
    color: var(--blue-600);
    font-size: 12px;
    text-decoration: none;
    transition: all 0.15s;
}

.message-bubble a[target="_blank"]::after {
    content: " \2197";
    font-size: 10px;
    opacity: 0.6;
}

.message-bubble a[target="_blank"]:hover {
    background: var(--blue-100);
    border-color: var(--blue-300);
}

/* --- Footer --- */
.footer-info {
    text-align: center;
    padding: 4px;
    font-size: 10px;
    color: var(--gray-400);
    background: var(--white);
    border-top: 1px solid var(--gray-100);
}

/* --- Sources modal --- */
.sources-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

.sources-modal.visible {
    display: flex;
}

.sources-modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 720px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

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

.sources-modal-header h3 {
    font-size: 16px;
    color: var(--gray-800);
}

.sources-modal-close {
    border: none;
    background: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--gray-400);
}

.sources-section-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.sources-totals {
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    margin: 16px 0;
    border-top: 1px solid var(--gray-200);
    border-bottom: 1px solid var(--gray-200);
}

.sources-total-item {
    text-align: center;
    font-size: 13px;
    color: var(--gray-600);
}

.sources-total-item strong {
    color: var(--gray-800);
}

.sources-footer {
    text-align: center;
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
}

.sources-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.source-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--blue-50);
    border: 1px solid var(--blue-200);
    border-radius: 10px;
    gap: 4px;
}

.source-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.source-item-icon {
    font-size: 18px;
}

.source-item-name {
    font-size: 13px;
    font-weight: 600;
}

.source-item-meta {
    font-size: 11px;
    color: var(--gray-400);
}

.source-item-status {
    color: #22c55e;
    font-size: 12px;
}

.source-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.source-sync-btn {
    background: none;
    border: 1px solid var(--blue-200);
    border-radius: 6px;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 8px;
    transition: all 0.2s;
}

.source-sync-btn:hover {
    color: var(--blue-400);
    border-color: var(--blue-400);
}

.source-sync-btn:disabled {
    cursor: wait;
    opacity: 0.6;
}

.source-delete-btn {
    background: none;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    color: var(--gray-300);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 8px;
    transition: all 0.2s;
}

.source-delete-btn:hover {
    color: #ef4444;
    border-color: #ef4444;
}

.source-sync-progress {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sync-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--blue-100);
    border-radius: 2px;
    overflow: hidden;
}

.sync-progress-fill {
    height: 100%;
    background: var(--blue-400);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s;
}

.sync-progress-text {
    font-size: 11px;
    color: var(--gray-400);
    white-space: nowrap;
}

.sources-add-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.source-add-btn {
    padding: 8px 14px;
    border: 1px dashed var(--gray-300);
    border-radius: 10px;
    background: none;
    color: var(--gray-500);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* --- Welcome input (centered) --- */
.welcome-input {
    margin-top: 28px;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.welcome-input .input-field {
    font-size: 16px;
    min-height: 56px;
    padding: 16px 20px;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius);
}

.welcome-input .send-button {
    height: auto;
    width: 56px;
    font-size: 20px;
    border-radius: var(--radius);
}

.welcome-stats {
    margin-top: 12px;
    font-size: 12px;
    color: var(--blue-400);
}

/* --- Status bar add source button --- */
.status-add-source {
    padding: 3px 10px;
    border: 1px dashed var(--blue-300);
    border-radius: 12px;
    background: none;
    color: var(--blue-500);
    font-size: 11px;
    cursor: pointer;
    font-weight: 500;
}

/* --- Mobile --- */
@media (max-width: 640px) {
    header { padding: 8px 10px; }
    .header-left { gap: 6px; }
    .paul-name { font-size: 14px; }
    .paul-status { font-size: 10px; }
    .header-right { gap: 4px; }
    .learning-counter { display: none; }
    .model-select { display: none; }
    .cost-badge { display: none; }
    .debug-toggle { display: none; }
    .chat-container { padding: 10px; }
    .input-area { padding: 8px 10px; }
    .input-field { font-size: 16px; min-height: 44px; }
    .send-button { width: 44px; height: 44px; }
    .message { max-width: 100%; }
    .message-bubble { max-width: 92%; font-size: 14px; padding: 12px 14px; }
    .message-avatar { width: 28px; height: 28px; font-size: 12px; }
    .welcome { padding: 20px 12px; }
    .welcome-avatar { width: 48px; height: 48px; font-size: 22px; }
    .welcome h2 { font-size: 18px; }
    .welcome p { font-size: 13px; }
    .welcome-input .input-field { font-size: 16px; }
    .welcome-suggestions { flex-direction: column; align-items: stretch; }
    .suggestion { text-align: center; }
    .sovereignty { display: none; }
    .progress-content { max-width: 92%; }
    .progress-status { font-size: 12px; }
    .progress-step { font-size: 11px; }
    .source-badge { font-size: 9px; }
    .message-actions { flex-wrap: wrap; }
    .action-btn { font-size: 10px; }
    .status-bar {
        flex-direction: column;
        gap: 4px;
        padding: 6px 12px;
        font-size: 10px;
        text-align: center;
    }
    .status-bar .sync-info {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    .status-add-source { display: none; }
    .sources-modal-content { width: 95%; padding: 16px; }
    .sources-add-list { flex-direction: column; }
}

/* --- Dark mode --- */
@media (prefers-color-scheme: dark) {
    :root {
        --blue-50: #0c1929;
        --blue-100: #172554;
        --blue-200: #1e3a5f;
        --gray-50: #111827;
        --gray-100: #1f2937;
        --gray-200: #374151;
        --gray-300: #4b5563;
        --gray-400: #9ca3af;
        --gray-500: #d1d5db;
        --gray-600: #e5e7eb;
        --gray-700: #f3f4f6;
        --gray-800: #f9fafb;
        --gray-900: #ffffff;
        --white: #0f172a;
        --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
        --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
        --shadow-lg: 0 4px 16px rgba(0,0,0,0.5);
    }

    body {
        background: linear-gradient(180deg, #0a0e1a 0%, #111827 100%);
        color: #e2e8f0;
    }

    header {
        background: #0f172a;
        border-bottom-color: #1e293b;
    }

    .model-select {
        background-color: #1e293b;
        border-color: #334155;
        color: #cbd5e1;
        background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 8 5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L4 4L7 1' stroke='%2394a3b8' stroke-linecap='round'/%3E%3C/svg%3E");
    }

    .model-select:hover { border-color: #60a5fa; color: #93c5fd; }

    .cost-badge { background: #172554; color: #93c5fd; }

    .debug-toggle:hover { background: #172554; color: #60a5fa; }

    .chat-container { background: transparent; }

    .welcome { color: #94a3b8; }
    .welcome h2 { color: #f1f5f9; }
    .welcome p { color: #94a3b8; }

    .suggestion {
        background: #1e293b;
        border-color: #334155;
        color: #93c5fd;
    }
    .suggestion:hover {
        background: #172554;
        border-color: #60a5fa;
    }

    .message.paul .message-bubble {
        background: #1e293b;
        border-color: #334155;
    }
    .message.paul .message-bubble strong { color: #f1f5f9; }
    .message.paul .message-bubble em { color: #94a3b8; }
    .message.paul .message-bubble code {
        background: #334155;
        color: #93c5fd;
    }

    .message.user .message-avatar { background: #334155; color: #cbd5e1; }

    .source-badge.from-files { background: #064e3b; color: #6ee7b7; border-color: #065f46; }
    .source-badge.not-found { background: #78350f; color: #fbbf24; border-color: #92400e; }
    .source-badge.unknown { background: #1f2937; color: #9ca3af; border-color: #374151; }

    .progress-content { background: #1e293b; border-color: #334155; }
    .progress-step { background: #111827; border-color: #1e293b; }

    .message-actions { border-top-color: #334155; }
    .action-btn { background: #1e293b; border-color: #334155; color: #94a3b8; }
    .action-btn:hover { background: #172554; border-color: #60a5fa; color: #93c5fd; }
    .action-btn.correct:hover { background: #450a0a; border-color: #dc2626; color: #fca5a5; }
    .action-btn.remember:hover { background: #052e16; border-color: #16a34a; color: #86efac; }

    .correction-dialog { background: #450a0a; border-color: #7f1d1d; }
    .correction-dialog textarea { background: #1e293b; border-color: #7f1d1d; color: #fca5a5; }

    .source-link { background: #1e293b; border-color: #334155; color: #94a3b8; }
    .source-link:hover { background: #172554; border-color: #60a5fa; color: #93c5fd; }

    .input-area { background: #0f172a; border-top-color: #1e293b; }
    .input-field {
        background: #1e293b;
        border-color: #334155;
        color: #f1f5f9;
    }
    .input-field:focus { border-color: #60a5fa; }
    .input-field::placeholder { color: #64748b; }

    .status-bar { background: #0f172a; border-top-color: #1e293b; }
    .status-bar strong { color: #93c5fd; }
    .status-add-source { border-color: #334155; color: #60a5fa; }

    .remember-toast { background: #065f46; }

    .debug-panel { background: #0f172a; border-color: #1e293b; color: #94a3b8; }

    /* --- Sources modal dark --- */
    .sources-modal-content { background: #1e293b; border-color: #334155; }
    .sources-modal-header { border-bottom-color: #334155; }
    .sources-modal-header h3 { color: #f1f5f9; }
    .sources-modal-close { color: #94a3b8; }
    .sources-modal-close:hover { color: #f1f5f9; }
    .source-item { border-color: #334155; }
    .source-item-name { color: #e2e8f0; }
    .source-item-meta { color: #64748b; }
    .source-sync-btn { border-color: #334155; color: #64748b; }
    .source-sync-btn:hover { border-color: #60a5fa; color: #60a5fa; }
    .source-delete-btn { border-color: #334155; color: #475569; }
    .source-delete-btn:hover { border-color: #ef4444; color: #ef4444; }
    .source-add-btn { background: #111827; border-color: #334155; color: #cbd5e1; }
    .source-add-btn:hover { background: #172554; border-color: #60a5fa; color: #93c5fd; }
    .sources-totals { background: #111827; border-color: #334155; color: #94a3b8; }
    .sources-section-label { color: #64748b; }
    .sources-footer { color: #475569; }

    /* --- Login page dark --- */
    .login-card { background: #1e293b; }
    .login-title { color: #f1f5f9; }
    .login-subtitle { color: #94a3b8; }
    .login-btn { background: #0f172a; border-color: #334155; color: #e2e8f0; }
    .login-btn:hover { background: #172554; border-color: #60a5fa; color: #93c5fd; }
    .login-footer { color: #475569; }
    .login-footer strong { color: #64748b; }

    /* --- Scrollbar --- */
    ::-webkit-scrollbar { width: 6px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
    ::-webkit-scrollbar-thumb:hover { background: #475569; }
}
