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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    color: #1a1a2e;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

header {
    margin-bottom: 1.5rem;
}

header h1 {
    font-size: 1.6rem;
    color: #16213e;
    display: inline;
}

.subtitle {
    color: #666;
    font-size: 0.85rem;
    margin-left: 0.5rem;
    display: inline;
}

.project-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.project-selector {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.88rem;
    color: #555;
}

.project-selector select {
    padding: 0.3rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 0.88rem;
    background: #fff;
    cursor: pointer;
}

.project-new {
    display: flex;
    gap: 0.3rem;
}

.project-new input {
    padding: 0.3rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 0.85rem;
    width: 140px;
}

.project-new button {
    padding: 0.3rem 0.6rem;
    background: #0f3460;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
}

.project-new button:hover {
    background: #16213e;
}

.project-delete {
    padding: 0.3rem 0.6rem;
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
}

.project-delete:hover {
    background: #ffcdd2;
}

.main-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: 10px;
    padding: 1rem;
}

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

.sidebar-header h3 {
    font-size: 0.95rem;
    color: #333;
}

.sidebar-toggle {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: #666;
}

.sidebar-toggle:hover {
    background: #f5f5f5;
}

.history-empty {
    font-size: 0.82rem;
    color: #999;
}

.history-list {
    list-style: none;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.82rem;
}

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

.history-query {
    flex: 1;
    color: #0f3460;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-query:hover {
    text-decoration: underline;
}

.history-meta {
    color: #999;
    font-size: 0.75rem;
    white-space: nowrap;
}

.history-delete {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

.history-delete:hover {
    color: #c62828;
    background: #ffebee;
}

.content {
    flex: 1;
    min-width: 0;
}

.search-form {
    margin-bottom: 1.5rem;
}

.search-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.search-box input[type="text"] {
    flex: 1;
    padding: 0.7rem 1rem;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input[type="text"]:focus {
    border-color: #0f3460;
}

.search-box button {
    padding: 0.7rem 1.5rem;
    background: #0f3460;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.search-box button:hover {
    background: #16213e;
}

.search-options {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: #555;
    flex-wrap: wrap;
}

.search-options label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
}

.htmx-indicator {
    opacity: 0;
    transition: opacity 0.3s;
    text-align: center;
    padding: 1rem;
    color: #666;
    pointer-events: none;
}

.htmx-request.htmx-indicator {
    opacity: 1;
}

form.htmx-request + .htmx-indicator {
    opacity: 1;
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #ddd;
    border-top-color: #0f3460;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-bottom: 0.5rem;
}

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

.placeholder, .no-results {
    text-align: center;
    color: #999;
    padding: 2rem 1rem;
}

.results-meta {
    font-size: 0.88rem;
    color: #666;
    margin-bottom: 1rem;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.result-card {
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    transition: box-shadow 0.2s;
}

.result-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.result-source {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.4rem;
}

.source-crossref { background: #e3f2fd; color: #1565c0; }
.source-openalex { background: #e8f5e9; color: #2e7d32; }
.source-pubmed { background: #fce4ec; color: #c62828; }
.source-arxiv { background: #fff3e0; color: #e65100; }
.source-hal { background: #f3e5f5; color: #7b1fa2; }
.source-naeb { background: #e0f2f1; color: #00695c; }
.source-encyclopédie { background: #fff8e1; color: #f57f17; }
.source-fda { background: #e3f2fd; color: #1565c0; }
.source-tcm { background: #fce4ec; color: #880e4f; }

.result-title {
    font-size: 1rem;
    margin-bottom: 0.3rem;
}

.result-title a {
    color: #0f3460;
    text-decoration: none;
}

.result-title a:hover {
    text-decoration: underline;
}

.result-meta {
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 0.2rem;
}

.result-year {
    color: #888;
}

.result-details {
    font-size: 0.8rem;
    color: #777;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.result-citations {
    color: #e65100;
    font-weight: 500;
}

.result-tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.tribe-tag {
    background: #fce4ec;
    color: #880e4f;
}

.use-tag {
    background: #fff8e1;
    color: #f57f17;
}

.fda-ingredient { background: #e3f2fd; color: #1565c0; }
.fda-generic { background: #e8eaf6; color: #283593; }

.chapter-tag {
    background: #e8eaf6;
    color: #283593;
}

.result-abstract {
    font-size: 0.88rem;
    color: #444;
    margin-top: 0.4rem;
    padding: 0.4rem 0.6rem;
    background: #fafafa;
    border-left: 3px solid #b2dfdb;
    border-radius: 0 4px 4px 0;
}

.result-oa {
    background: #c8e6c9;
    color: #2e7d32;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
}

.result-oa-link {
    color: #1b5e20;
    font-weight: 600;
    font-size: 0.78rem;
}

.result-arxiv {
    color: #e65100;
    font-size: 0.8rem;
}

.extract-btn {
    margin-top: 0.6rem;
    padding: 0.35rem 0.9rem;
    font-size: 0.82rem;
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.extract-btn:hover {
    background: #ffe0b2;
}

.extract-spinner {
    font-size: 0.8rem;
    color: #e65100;
    padding: 0.4rem 0;
}

.extract-container {
    margin-top: 0.4rem;
}

.extract-result {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.85rem;
    font-size: 0.85rem;
}

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

.extract-status {
    color: #2e7d32;
    font-weight: 600;
    font-size: 0.8rem;
}

.extract-cached {
    color: #999;
    font-size: 0.75rem;
}

.extract-size {
    color: #666;
    font-size: 0.78rem;
    margin-left: auto;
}

.extract-preview {
    font-family: 'Georgia', serif;
    font-size: 0.82rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 250px;
    overflow-y: auto;
    color: #333;
    background: #fff;
    padding: 0.6rem;
    border-radius: 4px;
    border: 1px solid #eee;
}

.extract-error {
    color: #c62828;
    font-size: 0.82rem;
    padding: 0.4rem 0;
}

.upload-form {
    margin-top: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.upload-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: #555;
    cursor: pointer;
}

.upload-label input[type="file"] {
    font-size: 0.8rem;
    color: #555;
}

.upload-btn {
    padding: 0.3rem 0.8rem;
    background: #0f3460;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 0.82rem;
    cursor: pointer;
}

.upload-btn:hover { background: #16213e; }

.upload-hint {
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.4rem;
}

.upload-hint a { color: #0f3460; }

.scihub-link {
    display: inline-block;
    margin-top: 0.6rem;
    margin-left: 0.5rem;
    font-size: 0.78rem;
    color: #888;
    text-decoration: none;
    border-bottom: 1px dashed #ccc;
}

.scihub-link:hover {
    color: #444;
    border-bottom-color: #888;
}

/* Sélecteur de mode de recherche */
.search-mode-selector {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
    font-size: 0.92rem;
    color: #444;
}

.search-mode-selector strong {
    color: #333;
}

.search-mode-selector label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
}

.search-mode-selector input[type="radio"] {
    cursor: pointer;
    width: 1rem;
    height: 1rem;
}

/* AI form */
.ai-form {
    margin-bottom: 1.5rem;
}

.ai-question-box {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.ai-question-box textarea {
    flex: 1;
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    resize: vertical;
    font-family: inherit;
    min-height: 80px;
    transition: border-color 0.2s;
}

.ai-question-box textarea:focus {
    border-color: #0f3460;
}

.ai-question-box button {
    padding: 0.7rem 1.5rem;
    background: #e65100;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.ai-question-box button:hover {
    background: #bf360c;
}

.ai-info {
    font-size: 0.82rem;
    color: #888;
    margin-top: 0.5rem;
}

.ai-spinner {
    padding: 2rem 0;
}

.ai-progress-card {
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    max-width: 480px;
    margin: 0 auto;
}

.ai-progress-steps {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1.25rem 0;
    text-align: left;
}

.ai-step {
    font-size: 0.88rem;
    color: #bbb;
    padding-left: 1.6rem;
    position: relative;
    transition: all 0.3s;
}

.ai-step::before {
    content: '○';
    position: absolute;
    left: 0;
    top: 0;
    color: #ddd;
    font-size: 0.9rem;
}

.ai-step.active {
    color: #0f3460;
    font-weight: 600;
}

.ai-step.active::before {
    content: '◌';
    color: #0f3460;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes stepComplete {
    0% { opacity: 1; }
    50% { transform: scale(1.2); }
    100% { opacity: 0.7; }
}

.ai-wait {
    font-size: 0.82rem;
    color: #999;
    font-style: italic;
}

.ai-error {
    color: #c62828;
    font-size: 0.85rem;
    padding: 1rem;
    background: #ffebee;
    border-radius: 8px;
}

/* AI results */
.ai-analysis {
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: 10px;
    overflow: hidden;
}

.ai-header {
    padding: 1.25rem;
    background: #fafafa;
    border-bottom: 1px solid #e8ecf1;
}

.ai-header h2 {
    font-size: 1.1rem;
    color: #16213e;
    margin-bottom: 0.3rem;
}

.ai-question {
    font-size: 0.9rem;
    color: #555;
    font-style: italic;
}

.ai-section {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f0f0f0;
}

.ai-section:last-child {
    border-bottom: none;
}

.ai-section h3 {
    font-size: 0.95rem;
    color: #333;
    margin-bottom: 0.6rem;
}

.ai-queries {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-query {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 0.75rem;
    background: #f5f7fa;
    border-radius: 6px;
}

.ai-query code {
    font-size: 0.9rem;
    color: #0f3460;
}

.ai-query-reason {
    font-size: 0.8rem;
    color: #888;
}

.ai-sources {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.ai-source-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.ai-source-title {
    color: #0f3460;
    text-decoration: none;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-source-title:hover {
    text-decoration: underline;
}

.ai-source-authors {
    color: #777;
    font-size: 0.8rem;
}

.ai-more {
    font-size: 0.82rem;
    color: #999;
    text-align: center;
    padding: 0.5rem;
}

.ai-extracted {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.ai-extracted-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.ai-extracted-num {
    display: inline-block;
    background: #e8f5e9;
    color: #2e7d32;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
}

.ai-extracted-item a {
    color: #0f3460;
    text-decoration: none;
}

.ai-extracted-item a:hover {
    text-decoration: underline;
}

.ai-synthesis {
    background: #fafafa;
}

.ai-synthesis-content {
    font-size: 0.9rem;
    line-height: 1.7;
    color: #333;
}

.ai-synthesis-content strong {
    color: #16213e;
}

footer {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.8rem;
    color: #aaa;
    clear: both;
    padding-top: 1rem;
}

/* Knowledge Graph entity cards */
.result-card-kg {
    border-left: 4px solid #7c4dff;
}

.source-graphe {
    background: #f3e5f5;
    color: #7b1fa2;
}

.kg-entity {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.kg-entity-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.kg-type-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kg-type-herb {
    background: #e8f5e9;
    color: #2e7d32;
}

.kg-type-disease {
    background: #ffebee;
    color: #c62828;
}

.kg-type-general {
    background: #e3f2fd;
    color: #1565c0;
}

.kg-type-mineral {
    background: #fff8e1;
    color: #f57f17;
}

.kg-type-vitamin {
    background: #fff3e0;
    color: #e65100;
}

.kg-type-food {
    background: #fce4ec;
    color: #880e4f;
}

.kg-entity-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a2e;
}

.kg-relations {
    font-size: 0.85rem;
    color: #555;
}

.kg-relation-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

.kg-relation-tag {
    display: inline-block;
    font-size: 0.78rem;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    background: #f5f5f5;
    color: #444;
    border: 1px solid #e0e0e0;
}

.kg-rel-herb { background: #e8f5e9; border-color: #a5d6a7; }
.kg-rel-disease { background: #ffebee; border-color: #ef9a9a; }
.kg-rel-general { background: #e3f2fd; border-color: #90caf9; }
.kg-rel-mineral { background: #fff8e1; border-color: #ffe082; }
.kg-rel-vitamin { background: #fff3e0; border-color: #ffcc80; }
.kg-rel-food { background: #fce4ec; border-color: #f48fb1; }

.kg-relation-tag small {
    color: #999;
    font-size: 0.7rem;
    margin-left: 0.2rem;
}

/* ── Score de confiance & badges COI ─────────────────────────────── */
.confidence-type {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    border-radius: 10px;
    background: #e3f2fd;
    color: #1565c0;
    font-weight: 500;
}
.confidence-type-meta_analysis,
.confidence-type-systematic_review { background: #e8f5e9; color: #2e7d32; }
.confidence-type-rct                { background: #e3f2fd; color: #1565c0; }
.confidence-type-clinical_trial     { background: #e8eaf6; color: #3949ab; }
.confidence-type-review,
.confidence-type-cohort             { background: #fff3e0; color: #e65100; }
.confidence-type-animal,
.confidence-type-in_vitro          { background: #fafafa; color: #757575; }
.confidence-type-case_report        { background: #fce4ec; color: #880e4f; }

.confidence-score {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 10px;
    min-width: 2.8rem;
    text-align: center;
}
.confidence-score-high { background: #e8f5e9; color: #1b5e20; }
.confidence-score-mid  { background: #fff3e0; color: #bf360c; }
.confidence-score-low  { background: #fce4ec; color: #880e4f; }

.coi-warning {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    background: #fff3e0;
    color: #e65100;
    cursor: help;
}
.coi-warning--verified {
    background: #fce4ec;
    color: #c62828;
}
.coi-companies {
    font-weight: 400;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}
.coi-source-link {
    font-size: 0.75rem;
    text-decoration: none;
    opacity: 0.7;
}
.coi-source-link:hover { opacity: 1; }

/* ── Header user bar ───────────────────────────────────────────────── */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.user-email {
    color: #333;
    font-weight: 500;
}

.quota-counter {
    color: #666;
    font-size: 0.8rem;
}

.quota-counter.unlimited {
    color: #2e7d32;
}

.plan-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.plan-free  { background: #f0f0f0; color: #555; }
.plan-pro   { background: #e3f2fd; color: #1565c0; }
.plan-assoc { background: #e8f5e9; color: #2e7d32; }

.btn-link {
    color: #0f3460;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid #ccd6e0;
    border-radius: 5px;
    transition: background 0.15s;
}

.btn-link:hover {
    background: #f0f4f8;
    text-decoration: none;
}

.btn-link-primary {
    background: #0f3460;
    color: #fff;
    border-color: #0f3460;
}

.btn-link-primary:hover {
    background: #16213e;
}

/* ── Locked sources ────────────────────────────────────────────────── */
.source-locked {
    opacity: 0.5;
    cursor: pointer !important;
}

.source-locked input {
    cursor: not-allowed;
}

.pro-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: #e3f2fd;
    color: #1565c0;
    vertical-align: middle;
    letter-spacing: 0.03em;
}

/* ── Quota exceeded message ────────────────────────────────────────── */
.quota-exceeded {
    text-align: center;
    padding: 2rem 1rem;
    color: #c62828;
    background: #ffebee;
    border-radius: 8px;
    font-size: 0.95rem;
}

/* ── Upgrade modal ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-box {
    background: #fff;
    border-radius: 14px;
    padding: 2rem;
    max-width: 640px;
    width: 100%;
    position: relative;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.1rem;
    color: #999;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.modal-close:hover { background: #f5f5f5; color: #333; }

.modal-title {
    font-size: 1.3rem;
    color: #16213e;
    margin-bottom: 0.5rem;
}

.modal-desc {
    font-size: 0.92rem;
    color: #555;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.plan-cards {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.plan-card {
    flex: 1;
    min-width: 160px;
    border: 1px solid #e8ecf1;
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.plan-card-featured {
    border-color: #0f3460;
    background: #f8fbff;
}

.plan-card-name {
    font-weight: 700;
    font-size: 1rem;
    color: #16213e;
}

.plan-card-price {
    font-size: 1.4rem;
    font-weight: 700;
    color: #0f3460;
}

.plan-card-price span {
    font-size: 0.85rem;
    font-weight: 400;
    color: #888;
}

.plan-card-features {
    list-style: none;
    font-size: 0.82rem;
    color: #555;
    flex: 1;
}

.plan-card-features li::before {
    content: '✓ ';
    color: #2e7d32;
    font-weight: 600;
}

.btn-plan {
    display: block;
    text-align: center;
    padding: 0.6rem 1rem;
    border: 1px solid #0f3460;
    border-radius: 7px;
    color: #0f3460;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: background 0.15s;
    margin-top: 0.5rem;
}

.btn-plan:hover { background: #f0f4f8; }

.btn-plan-primary {
    background: #0f3460;
    color: #fff;
}

.btn-plan-primary:hover { background: #16213e; }

/* ── Auth pages (login / signup) ────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-box {
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: 14px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.07);
}

.auth-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    text-decoration: none;
    margin-bottom: 1.75rem;
}
.auth-logo img {
    height: 72px;
    width: auto;
}
.auth-logo-name {
    font-size: 1rem;
    font-weight: 800;
    color: #0f3460;
    letter-spacing: -.3px;
}
.auth-logo-name em { font-style: normal; color: #0da57a; }

/* ── Logo dans l'en-tête de l'app ───────────────────────────────── */
.app-site-logo {
    display: flex;
    align-items: center;
    gap: .75rem;
    text-decoration: none;
}
.app-site-logo img {
    height: 44px;
    width: auto;
    flex-shrink: 0;
}
.app-site-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.app-site-logo-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: #0f3460;
    letter-spacing: -.3px;
}
.app-site-logo-name em { font-style: normal; color: #0da57a; }
.app-site-logo-sub {
    font-size: .72rem;
    color: #888;
    font-weight: 400;
}

.auth-title {
    font-size: 1.4rem;
    color: #16213e;
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 1.5rem;
}

.auth-error {
    background: #ffebee;
    color: #c62828;
    border-radius: 7px;
    padding: 0.6rem 0.9rem;
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.form-group label {
    font-size: 0.88rem;
    font-weight: 500;
    color: #333;
}

.label-hint {
    font-weight: 400;
    color: #999;
}

.form-group input {
    padding: 0.65rem 0.9rem;
    border: 1px solid #ccc;
    border-radius: 7px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: #0f3460;
}

.btn-submit {
    padding: 0.75rem;
    background: #0f3460;
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 0.25rem;
}

.btn-submit:hover { background: #16213e; }

.auth-switch {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.88rem;
    color: #666;
}

.auth-switch a {
    color: #0f3460;
    font-weight: 500;
}

/* ── Sources complètes (collapsible) ───────────────────────────────── */
.ai-sources-details summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: #0f3460;
    font-weight: 500;
    padding: 0.4rem 0;
    user-select: none;
}
.ai-sources-details summary:hover { text-decoration: underline; }
.ai-sources-details .ai-sources { margin-top: 0.75rem; }

/* ── Questions complémentaires ─────────────────────────────────────── */
.ai-followup-section { border-top: 2px solid #e8f0fe; padding-top: 1.5rem; }
.ai-followup-hint { font-size: 0.85rem; color: #888; margin-bottom: 1rem; }

.ai-conversation { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.25rem; }

.ai-followup-qa {
    border: 1px solid #e0e8f5;
    border-radius: 10px;
    overflow: hidden;
}
.ai-followup-question {
    background: #f0f4fa;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.ai-fq-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #0f3460;
}
.ai-fq-text { font-size: 0.9rem; color: #222; }

.ai-followup-answer {
    padding: 1rem 1.25rem;
    font-size: 0.9rem;
    line-height: 1.75;
    color: #222;
    background: #fff;
    white-space: pre-wrap;
    overflow-x: auto;
}

.ai-followup-form { display: flex; flex-direction: column; gap: 0.5rem; }
.ai-followup-input { display: flex; gap: 0.5rem; align-items: flex-start; }
.ai-followup-input textarea {
    flex: 1;
    padding: 0.65rem 0.9rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}
.ai-followup-input textarea:focus { border-color: #0f3460; }
.ai-followup-btn {
    padding: 0.65rem 1.2rem;
    background: #0f3460;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}
.ai-followup-btn:hover { background: #16213e; }
.ai-followup-loading {
    font-size: 0.85rem;
    color: #666;
    padding: 0.25rem 0;
    align-items: center;
}

/* ── Publication blog (Associés) ───────────────────────────────────── */
.ai-publish-section { border-top: 1px solid #e5e9f0; padding-top: 1.25rem; }

.publish-toggle-btn {
    background: none;
    border: 1.5px solid #0f3460;
    color: #0f3460;
    padding: 0.5rem 1rem;
    border-radius: 7px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.publish-toggle-btn:hover { background: #0f3460; color: #fff; }

.publish-form-box {
    background: #f8faff;
    border: 1px solid #d0ddf5;
    border-radius: 10px;
    padding: 1.25rem;
    margin-top: 0.75rem;
}
.publish-form-box h3 { font-size: 0.95rem; color: #0f3460; margin-bottom: 0.25rem; }
.publish-desc { font-size: 0.82rem; color: #888; margin-bottom: 0.75rem; }
.publish-actions { display: flex; gap: 0.6rem; margin-top: 0.25rem; }
.publish-submit-btn {
    padding: 0.55rem 1.1rem;
    background: #0f3460;
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.publish-submit-btn:hover { background: #16213e; }
.publish-cancel-btn {
    padding: 0.55rem 0.9rem;
    background: none;
    border: 1px solid #ccc;
    border-radius: 7px;
    font-size: 0.88rem;
    color: #666;
    cursor: pointer;
    transition: border-color 0.2s;
}
.publish-cancel-btn:hover { border-color: #999; }
.publish-success {
    margin-top: 0.75rem;
    padding: 0.65rem 1rem;
    background: #e8f5e9;
    border-radius: 7px;
    color: #2e7d32;
    font-size: 0.9rem;
    font-weight: 500;
}
.publish-success a { color: #1b5e20; font-weight: 600; }
.publish-error {
    margin-top: 0.75rem;
    padding: 0.65rem 1rem;
    background: #fdecea;
    border-radius: 7px;
    color: #c62828;
    font-size: 0.9rem;
}

/* ── Tooltips sources ──────────────────────────────────────────────── */
label[data-tooltip] {
    position: relative;
}
label[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #16213e;
    color: #fff;
    padding: 0.45rem 0.75rem;
    border-radius: 7px;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.45;
    width: 210px;
    text-align: center;
    white-space: normal;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 300;
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}
label[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #16213e;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 300;
}
label[data-tooltip]:hover::after,
label[data-tooltip]:hover::before {
    opacity: 1;
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile & tablette
   ══════════════════════════════════════════════════════════════════ */

/* ── Tablette (≤ 768px) ────────────────────────────────────────── */
@media (max-width: 768px) {
    .container {
        padding: 1rem 0.85rem;
    }

    /* Header */
    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .app-site-logo img { height: 36px; }
    .app-site-logo-name { font-size: .95rem; }
    .app-site-logo-sub  { font-size: .68rem; }

    .user-bar {
        width: 100%;
        justify-content: flex-start;
        font-size: 0.8rem;
        gap: 0.45rem;
        flex-wrap: wrap;
    }

    /* Sélecteur de mode */
    .search-mode-selector {
        flex-wrap: wrap;
        gap: 0.6rem 1rem;
    }

    /* Barre de recherche classique */
    .search-box {
        flex-direction: column;
        gap: 0.5rem;
    }
    .search-box button {
        width: 100%;
        padding: 0.75rem;
    }

    /* Cases à cocher sources */
    .search-options {
        gap: 0.5rem 0.75rem;
    }

    /* Formulaire question IA */
    .ai-question-box {
        flex-direction: column;
    }
    .ai-question-box button {
        width: 100%;
        padding: 0.75rem;
    }
    .ai-question-box textarea {
        min-height: 90px;
    }

    /* Résultats */
    .results-meta {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    /* Synthèse IA */
    .ai-synthesis-card {
        padding: 1.1rem;
    }

    /* Conversation follow-up */
    .ai-followup-input {
        flex-direction: column;
    }
    .ai-followup-btn {
        width: 100%;
    }

    /* Bloc publication */
    .publish-actions {
        flex-direction: column;
    }
    .publish-submit-btn,
    .publish-cancel-btn {
        width: 100%;
        text-align: center;
    }

    /* Blog */
    .blog-grid {
        grid-template-columns: 1fr;
    }

    /* Auth */
    .auth-box {
        padding: 1.5rem 1.1rem;
        margin: 1rem 0.5rem;
    }
}

/* ── Mobile (≤ 480px) ──────────────────────────────────────────── */
@media (max-width: 480px) {
    .container {
        padding: 0.75rem 0.75rem;
    }

    /* Header compact */
    .user-bar .user-email { display: none; } /* pseudo caché, garde badge + quota */
    .plan-badge { font-size: .65rem; }
    .quota-counter { font-size: .75rem; }
    .btn-link { font-size: .78rem; }

    /* Titre section */
    header h1 { font-size: 1.25rem; }

    /* Mode de recherche : on masque le label "Mode :" */
    .search-mode-selector strong { display: none; }

    /* Résultats */
    .result-card {
        padding: 0.85rem 0.9rem;
    }
    .result-title a { font-size: 0.9rem; }
    .result-meta    { font-size: 0.75rem; }
    .result-tags    { gap: 0.25rem; }
    .result-tag     { font-size: 0.7rem; padding: 0.1rem 0.4rem; }

    /* Sources détails */
    .ai-sources-details summary { font-size: 0.85rem; }

    /* Désactiver les tooltips (inutilisables au doigt) */
    label[data-tooltip]::after,
    label[data-tooltip]::before {
        display: none;
    }

    /* Upload form */
    .upload-form {
        padding: 0.85rem;
    }

    /* Extraction */
    .extract-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }

    /* Blog */
    .blog-post-content {
        font-size: 0.93rem;
    }

    /* Publish */
    .publish-form-box {
        padding: 0.9rem;
    }
}

/* ══════════════════════════════════════════════════════════════════
   INDICATEURS DE CHARGEMENT
   ══════════════════════════════════════════════════════════════════ */

/* Barre chargement recherche classique */
.search-loading-bar {
    display: none;
    margin-top: .75rem;
    background: #eef4ff;
    border: 1px solid #c5d5ef;
    border-radius: 10px;
    padding: .85rem 1.1rem;
}
.search-loading-bar.htmx-request { display: block; }
.search-loading-inner {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: #0f3460;
    font-size: .9rem;
    font-weight: 500;
}
.search-loading-spinner {
    width: 18px; height: 18px;
    border: 3px solid #c5d5ef;
    border-top-color: #0f3460;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Overlay chargement IA */
.ai-loading-overlay {
    display: none;
    margin-top: 1rem;
}
.ai-loading-overlay.htmx-request { display: block; }

.ai-loading-card {
    background: linear-gradient(135deg, #0f3460 0%, #16407a 100%);
    color: #fff;
    border-radius: 14px;
    padding: 1.5rem 1.6rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 4px 20px rgba(15,52,96,.25);
}

.ai-loading-pulse {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,.25);
    border-top-color: #4dd4b0;
    animation: spin .8s linear infinite;
    align-self: center;
}

.ai-loading-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    text-align: center;
}
.ai-loading-title {
    font-size: 1.05rem;
    font-weight: 700;
}
.ai-loading-steps {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}
.ai-lstep {
    font-size: .82rem;
    color: rgba(255,255,255,.45);
    transition: color .5s, font-weight .3s;
}
.ai-lstep.active {
    color: #fff;
    font-weight: 600;
}

/* Barre de progression simulée */
.ai-loading-bar {
    background: rgba(255,255,255,.15);
    border-radius: 20px;
    height: 6px;
    overflow: hidden;
}
.ai-loading-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4dd4b0, #2d7dd2);
    border-radius: 20px;
    animation: progress-fill 55s ease-out forwards;
    width: 0%;
}
@keyframes progress-fill {
    0%   { width: 0%; }
    10%  { width: 12%; }
    25%  { width: 35%; }
    50%  { width: 58%; }
    75%  { width: 78%; }
    95%  { width: 92%; }
    100% { width: 95%; }
}

.ai-loading-hint {
    font-size: .75rem;
    color: rgba(255,255,255,.5);
    text-align: center;
    margin: 0;
}

/* Notification résultats prêts (scroll prompt) */
.results-ready-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #0f3460;
    color: #fff;
    padding: .7rem 1.4rem;
    border-radius: 30px;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(15,52,96,.4);
    transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .35s;
    opacity: 0;
    z-index: 999;
    white-space: nowrap;
}
.results-ready-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ── Badge modèle IA utilisé ────────────────────────────────────── */
.ai-model-badge {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-top: 1rem;
    padding: .5rem .8rem;
    background: #f4f7fc;
    border: 1px solid #dde5f5;
    border-radius: 8px;
    font-size: .78rem;
    color: #555;
}
.ai-model-icon { font-size: .95rem; flex-shrink: 0; }
.ai-model-badge strong { color: #0f3460; }
.ai-model-badge a { color: #0f3460; }
.ai-model-fallback { color: #e65100; font-style: italic; }
.ai-model-note    { color: #555; font-style: italic; }
.ai-model-note a  { color: #0f3460; }

/* ══════════════════════════════════════════════════════════════════
   HISTORIQUE — TIROIR MOBILE
   ══════════════════════════════════════════════════════════════════ */

/* Bouton flottant "Historique" — visible uniquement sur mobile */
.history-mobile-btn {
    display: none;
}

/* Bouton fermeture dans le header du sidebar — caché sur desktop */
.sidebar-close-mobile {
    display: none;
}

@media (max-width: 768px) {
    /* Cacher le sidebar du flux normal */
    .main-layout {
        display: block; /* plus de flex, le sidebar sort du flux */
    }

    /* Bouton "Historique" visible en haut */
    .history-mobile-btn {
        display: flex;
        align-items: center;
        gap: .5rem;
        width: 100%;
        padding: .6rem 1rem;
        margin-bottom: .75rem;
        background: #fff;
        border: 1px solid #dde5f5;
        border-radius: 10px;
        font-size: .88rem;
        font-weight: 600;
        color: #0f3460;
        cursor: pointer;
        text-align: left;
        transition: background .15s;
    }
    .history-mobile-btn:hover { background: #f0f4fa; }
    .history-mobile-btn::after {
        content: '›';
        margin-left: auto;
        font-size: 1.1rem;
        color: #aaa;
    }

    /* Fond sombre */
    .history-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 30, 60, 0.45);
        z-index: 199;
        backdrop-filter: blur(2px);
    }
    .history-backdrop.visible { display: block; }

    /* Sidebar devient un tiroir pleine largeur depuis le bas */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 72vh;
        overflow-y: auto;
        border-radius: 16px 16px 0 0;
        border: none;
        border-top: 1px solid #dde5f5;
        box-shadow: 0 -4px 24px rgba(15, 52, 96, .15);
        z-index: 200;
        padding: 1rem 1rem 2rem;
        transform: translateY(100%);
        transition: transform .3s cubic-bezier(.32, .72, 0, 1);
        -webkit-overflow-scrolling: touch;
    }

    /* Poignée visuelle en haut du tiroir */
    .sidebar::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: #dde5f5;
        border-radius: 2px;
        margin: 0 auto .85rem;
    }

    /* Tiroir ouvert */
    .sidebar.drawer-open {
        transform: translateY(0);
    }

    /* Bouton ✕ visible sur mobile */
    .sidebar-close-mobile {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        background: #f0f4fa;
        border: none;
        border-radius: 50%;
        font-size: .9rem;
        color: #555;
        cursor: pointer;
        flex-shrink: 0;
    }
    .sidebar-close-mobile:hover { background: #dde5f5; }

    /* Le contenu principal prend toute la largeur */
    .content {
        width: 100%;
    }
}
