/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-main: #0f0f13;
    --bg-card: #1a1a24;
    --bg-input: #252532;
    --bg-hover: #2a2a3a;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --purple: #8b5cf6;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #2e2e3e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #22c55e;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent-light); text-decoration: none; }
a:hover { color: var(--accent); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Navbar ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 56px;
    background: rgba(15, 15, 19, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.02em;
}

.brand-icon {
    font-size: 1.4rem;
    color: var(--accent);
}

.nav-links { display: flex; gap: 4px; }

.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-link:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-link.active { color: var(--accent-light); background: rgba(99, 102, 241, 0.12); }

/* ===== Main Content ===== */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 72px 24px 24px;
    min-height: 100vh;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
    border-color: #3e3e52;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: #5558e6; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }

.btn-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.btn-warning:hover { background: rgba(245, 158, 11, 0.25); }

.btn-sm { padding: 4px 12px; font-size: 0.82rem; }

/* ===== Forms ===== */
.form-group {
    margin-bottom: 16px;
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-row {
    display: flex;
    gap: 16px;
}

input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: border-color var(--transition);
    outline: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
}

textarea { resize: vertical; }

select {
    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='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

input[type="range"] {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    margin-top: 8px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--bg-card);
}

input[type="color"] {
    width: 40px;
    height: 40px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    cursor: pointer;
}

.color-picker-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-hex {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: monospace;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.form-card { margin-bottom: 20px; }

/* ===== Section Header ===== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ===== Home / Conversations ===== */
.home-grid {
    max-width: 800px;
    margin: 0 auto;
}

.conv-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.conv-card {
    display: block;
    color: var(--text-primary);
    cursor: pointer;
}

.conv-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.15);
}

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

.conv-status {
    display: inline-block;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-active { background: rgba(34, 197, 94, 0.12); color: var(--success); }
.status-paused { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.status-completed { background: rgba(99, 102, 241, 0.12); color: var(--accent-light); }

.conv-date { font-size: 0.8rem; color: var(--text-muted); }

.conv-topic {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 8px;
}

.conv-summary {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.conv-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
    display: flex;
    gap: 16px;
}

/* Agent checkboxes in new conversation form */
.agent-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.agent-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.9rem;
}

.agent-checkbox:hover { border-color: var(--accent); }

.agent-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.agent-checkbox .cb-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ===== Chat Layout ===== */
.chat-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 0;
    height: calc(100vh - 72px);
    margin: -24px -24px 0;
    padding: 0 24px;
}

.chat-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--border);
    padding-right: 20px;
}

/* Chat header */
.chat-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-header-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 200px; }

.chat-topic {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Chat summary */
.chat-summary {
    padding: 8px 14px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(99, 102, 241, 0.06);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    line-height: 1.5;
    white-space: pre-line;
    flex-shrink: 0;
}

/* Topic rename input */
.chat-topic-input {
    font-size: 1.1rem;
    font-weight: 600;
    background: var(--bg-input);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 4px 10px;
    font-family: inherit;
    outline: none;
    width: 100%;
    min-width: 200px;
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.message {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: var(--radius);
    line-height: 1.55;
    font-size: 0.92rem;
    animation: msgIn 0.25s ease;
}

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

.message-agent {
    align-self: flex-start;
    background: var(--bg-card);
    border-left: 3px solid var(--accent);
}

.message-user {
    align-self: flex-end;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
    gap: 12px;
}

.message-sender {
    font-weight: 600;
    font-size: 0.82rem;
}

.message-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.message-body {
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Message actions (footer icons) */
.msg-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}
.message:hover .msg-actions {
    opacity: 1;
}
.btn-msg-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    color: var(--text-muted);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    opacity: 0.5;
}
.btn-msg-action:hover {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.12);
    opacity: 1;
}

/* Markdown in messages */
.message-body strong { font-weight: 600; }
.message-body em { font-style: italic; }
.message-body code {
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.85em;
    font-family: "SF Mono", "Fira Code", monospace;
}
.message-body pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
}
.message-body pre code {
    background: none;
    padding: 0;
}
.message-body ul, .message-body ol {
    padding-left: 20px;
    margin: 6px 0;
}
.message-body p { margin: 4px 0; }
.message-body p:first-child { margin-top: 0; }
.message-body p:last-child { margin-bottom: 0; }

/* Typing indicator */
.typing-indicator {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.82rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.typing-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
}

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

.typing-avatar-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
}

.typing-name { font-weight: 600; }

.typing-dots {
    display: inline-flex;
    gap: 3px;
    margin-left: 2px;
}

.dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: bounce 1.4s infinite ease-in-out;
}

.dot:nth-child(1) { animation-delay: 0s; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-6px); opacity: 1; }
}

.typing-icon {
    font-size: 1rem;
    margin-left: 4px;
    animation: pulse-icon 1.5s infinite ease-in-out;
}

@keyframes pulse-icon {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Agent pass (cerveau) */
.message-pass {
    opacity: 0.45;
}

.message-pass .msg-content {
    min-height: auto;
}

.pass-body {
    font-size: 1.3rem;
    line-height: 1;
    padding: 2px 0;
}

/* Chat input */
.chat-input-area {
    padding: 12px 0 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-textarea {
    flex: 1;
    padding: 10px 14px;
    font-size: 0.92rem;
    font-family: inherit;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    resize: none;
    outline: none;
    max-height: 140px;
    line-height: 1.5;
    transition: border-color var(--transition);
}

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

.btn-send {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: var(--radius);
    flex-shrink: 0;
}

/* Chat sidebar */
.chat-sidebar {
    padding: 16px 0 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.sidebar-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.sidebar-agents {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-agent {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.sidebar-agent:hover { background: var(--bg-hover); }

.agent-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.agent-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.agent-name {
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-model {
    font-size: 0.75rem;
}

.agent-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.sidebar-meta {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    padding: 4px 0;
}

/* ===== Agents Page ===== */
.agents-page {
    max-width: 1000px;
    margin: 0 auto;
}

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

.agent-card { display: flex; flex-direction: column; gap: 12px; }

.agent-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agent-dot-lg {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}

.agent-card-name {
    font-size: 1.05rem;
    font-weight: 600;
}

.agent-card-personality {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.agent-card-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tool-pill {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.72rem;
    font-weight: 500;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-light);
    border-radius: 999px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.agent-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.agent-card-actions { display: flex; gap: 6px; }

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-content h2 {
    font-size: 1.15rem;
    margin-bottom: 16px;
}

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state p { margin-bottom: 4px; }

/* ===== Utilities ===== */
.text-muted { color: var(--text-muted); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .chat-layout {
        grid-template-columns: 1fr;
    }

    .chat-sidebar {
        display: none;
    }

    .chat-main {
        border-right: none;
        padding-right: 0;
    }

    .message { max-width: 90%; }

    .form-row { flex-direction: column; gap: 0; }

    .agent-grid {
        grid-template-columns: 1fr;
    }

    .nav-inner { padding: 0 16px; }
    .main-content { padding: 64px 16px 16px; }
}

/* ===== Avatars ===== */
.msg-avatar, .agent-avatar-sm, .agent-avatar-lg {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.msg-avatar { width: 32px; height: 32px; }
.msg-avatar-dot {
    width: 32px; height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255,255,255,0.8);
}
.msg-avatar-wrap {
    flex-shrink: 0;
    margin-top: 2px;
}
.msg-content { flex: 1; min-width: 0; }

.message-agent {
    display: flex;
    gap: 10px;
}

.agent-avatar-sm { width: 28px; height: 28px; }
.agent-avatar-lg { width: 40px; height: 40px; }

/* ===== Tools checkboxes ===== */
.tools-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tool-cb {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
}
.tool-cb:hover { border-color: var(--accent); }
.tool-cb input { accent-color: var(--accent); }

/* ===== Chart.js in messages ===== */
.chart-wrap {
    position: relative;
    height: 240px;
    width: 100%;
    min-width: min(320px, 100%);
    background: rgba(15, 15, 19, 0.6);
    padding: 8px;
    border-radius: var(--radius);
    margin: 8px 0;
}
.chart-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
    text-align: center;
    color: var(--text-secondary);
}
.chart-error {
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 0.8rem;
    margin: 8px 0;
}
.chart-error pre {
    margin-top: 6px;
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ===== Mermaid diagrams ===== */
.mermaid-wrap {
    margin: 8px 0;
    padding: 12px;
    background: rgba(15, 15, 19, 0.4);
    border-radius: var(--radius);
    overflow-x: auto;
    text-align: center;
}
.mermaid-wrap svg {
    max-width: 100%;
    height: auto;
}

/* ===== Markdown tables ===== */
.msg-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 0.85rem;
}
.msg-table th,
.msg-table td {
    padding: 6px 10px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    text-align: left;
}
.msg-table th {
    background: rgba(99, 102, 241, 0.1);
    font-weight: 600;
    color: var(--text);
}
.msg-table td {
    color: var(--text-muted);
}
.msg-table tr:nth-child(even) td {
    background: rgba(15, 15, 19, 0.3);
}

/* ===== Images in messages ===== */
.msg-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-sm);
    margin: 8px 0;
    cursor: pointer;
    transition: opacity var(--transition);
    display: block;
}
.msg-image:hover { opacity: 0.85; }

/* ===== Delete conversation button ===== */
.conv-card {
    position: relative;
}
.conv-card-link {
    display: block;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
}
.btn-delete-conv {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition), background var(--transition);
}
.conv-card:hover .btn-delete-conv { opacity: 1; }
.btn-delete-conv:hover { background: rgba(239, 68, 68, 0.25); }

/* ===== Upload button ===== */
.btn-upload {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: all var(--transition);
}
.btn-upload:hover { border-color: var(--accent); color: var(--accent-light); }

/* ===== Stop button ===== */
.btn-stop {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: var(--radius);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ===== Danger button ===== */
.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

/* Active toggle button */
.btn-active {
    background: rgba(34, 197, 94, 0.2) !important;
    color: var(--success) !important;
    border-color: rgba(34, 197, 94, 0.4) !important;
}

/* ===== Settings / Keys ===== */
.settings-page {
    max-width: 900px;
    margin: 0 auto;
}

.keys-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.keys-tbl th,
.keys-tbl td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.keys-tbl th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.keys-tbl code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.78rem;
}

.keys-empty {
    padding: 14px;
    text-align: center;
    font-size: 0.85rem;
}

.usage-bar {
    display: inline-block;
    width: 120px;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    vertical-align: middle;
    margin-right: 6px;
}

.usage-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s ease;
}

.usage-pct {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.incomp-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.incomp-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 4px 4px 10px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 999px;
    font-size: 0.8rem;
}

.incomp-chip code {
    background: transparent;
    color: var(--danger);
    padding: 0;
    font-size: 0.78rem;
}

.incomp-x {
    border: none;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 6px;
    border-radius: 50%;
}

.incomp-x:hover { background: rgba(239, 68, 68, 0.2); }

/* ===== Helper agents ===== */
.message-helper {
    margin-left: 32px;
    border-left-style: dashed !important;
    opacity: 0.9;
}

.helper-badge {
    display: inline-block;
    padding: 1px 8px;
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(139, 92, 246, 0.15);
    color: var(--purple);
    border-radius: 999px;
    vertical-align: middle;
    margin-left: 4px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.agent-card-helper {
    border-left: 3px dashed var(--purple);
}

.sidebar-helper {
    padding-left: 20px;
    opacity: 0.85;
}

.helper-status-emoji {
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* ============ MAP / ANALYSE PAGE ============ */

.map-page {
    padding: 16px 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.map-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

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

.map-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 0;
    color: var(--text-secondary);
    gap: 16px;
}

.loader-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--bg-hover);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.map-error {
    padding: 20px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius);
    color: var(--danger);
    text-align: center;
}

/* Summary cards */
.map-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.summary-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    border-left: 4px solid var(--accent);
}

.summary-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 10px 0;
}

.summary-card p {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0;
}

.summary-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.summary-card ul li {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.6;
    padding-left: 14px;
    position: relative;
}

.summary-card ul li::before {
    content: '\2022';
    position: absolute;
    left: 0;
    color: var(--text-muted);
}

.summary-problematic {
    border-left-color: #ff3df0;
}

.summary-conclusions {
    border-left-color: #00f0ff;
}

.summary-todos {
    border-left-color: #3ee68a;
}

/* Mindmap */
.map-mindmap {
    position: relative;
}

.map-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.map-canvas {
    width: 100%;
    height: 65vh;
    background: var(--bg-main);
    border-radius: var(--radius);
    border: 1px solid var(--bg-hover);
    overflow: hidden;
}

.map-canvas svg {
    width: 100%;
    height: 100%;
}

/* SVG elements */
.link {
    fill: none;
    stroke: #6b5fad;
    stroke-opacity: 0.5;
    stroke-width: 1.5;
}

.node-text {
    font-size: 13px;
    font-weight: 500;
    pointer-events: none;
}

.node-body-text {
    font-size: 11px;
    font-weight: 400;
    pointer-events: none;
}

.node:hover .node-rect {
    filter: brightness(1.15);
}

.node.selected .node-rect {
    stroke-width: 2.5;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.2));
}

.node-root .node-text {
    font-size: 14px;
    font-weight: 600;
}

@media (max-width: 768px) {
    .map-summary {
        grid-template-columns: 1fr;
    }
    .map-canvas {
        height: 50vh;
    }
    .map-page {
        padding: 12px;
    }
}

.flash-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 10px 16px;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: var(--success);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    z-index: 300;
    animation: fadeIn 0.2s ease;
}
