:root {
    --bg-color: #0b0f1a;
    --sidebar-color: rgba(15, 23, 42, 0.8);
    --card-bg: rgba(30, 41, 59, 0.4);
    --accent-color: #38bdf8;
    --accent-soft: rgba(56, 189, 248, 0.1);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-blur: 16px;
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
}

.hidden { display: none !important; }

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    line-height: 1.6;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--sidebar-color);
    backdrop-filter: blur(var(--glass-blur));
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 2.5rem 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 3.5rem;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* View Toggle */
.view-toggle {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 2.5rem;
}

.toggle-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-btn.active {
    background: var(--accent-color);
    color: var(--bg-color);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

/* Vault Selector & Model Selector */
.vault-selector-container, .model-selector-container {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 8px;
    align-items: center;
}

.model-selector-container {
    padding: 0 1.5rem 1rem 1.5rem;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 0;
}

.vault-actions {
    display: flex;
    gap: 4px;
}

.vault-action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 10px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.vault-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-color);
    border-color: rgba(56, 189, 248, 0.4);
}

.vault-action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.vault-select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.vault-select:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.vault-select option {
    background-color: #0f172a; /* Bleu très sombre pour le menu déroulant */
    color: #f1f5f9;
    padding: 10px;
}

.vault-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    text-align: left;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent-color);
}

.stats-panel {
    margin-top: auto;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#stat-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.clear-cache-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-cache-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.08), transparent 600px);
}

.sidebar .search-container {
    width: 100%;
    position: relative;
    margin-bottom: 2rem;
}

.sidebar #search-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.4);
    color: white;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.3s;
}

.sidebar #search-input:focus {
    border-color: var(--accent-color);
    background: rgba(15, 23, 42, 0.6);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
}

/* Grid & Graph Containers */
.fiches-grid {
    flex-grow: 1;
    overflow-y: auto;
    padding: 2rem 2.5rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.graph-container {
    flex-grow: 1;
    padding: 0;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    position: relative;
}

/* Section layout */
.grid-section {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.section-icon { font-size: 1.1rem; }

.section-count {
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(255,255,255,0.06);
    color: var(--text-muted);
    border-radius: 100px;
    padding: 2px 9px;
    letter-spacing: 0.02em;
}

/* ── Book cards ─────────────────────────────────────────── */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.book-card {
    display: flex;
    border: 1px solid;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
    min-height: 160px;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 36px -10px rgba(0,0,0,0.55);
    filter: brightness(1.08);
}

.book-card-accent {
    width: 4px;
    flex-shrink: 0;
    border-radius: 16px 0 0 16px;
    opacity: 0.85;
}

.book-card-body {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

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

.book-genre-badge {
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 2px 8px;
    border-radius: 100px;
    border: 1px solid;
}

.book-title {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.35;
    color: #fff;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.book-author {
    font-size: 0.78rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.book-source {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: auto;
    padding-top: 4px;
}

.book-tag-chip {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 100px;
    white-space: nowrap;
}

/* ── Concept cloud chips ─────────────────────────────────── */
.concepts-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.concept-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 100px;
    background: rgba(56,189,248,0.07);
    border: 1px solid rgba(56,189,248,0.18);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.concept-chip:hover {
    background: rgba(56,189,248,0.15);
    border-color: rgba(56,189,248,0.4);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.concept-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #38bdf8;
    flex-shrink: 0;
}

.note-chip {
    background: rgba(148,163,184,0.06);
    border-color: rgba(148,163,184,0.15);
}

.note-chip:hover {
    background: rgba(148,163,184,0.12);
    border-color: rgba(148,163,184,0.3);
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.fiche-card {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 28px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    min-height: 200px;
}

.fiche-card:hover {
    transform: translateY(-8px);
    border-color: rgba(56, 189, 248, 0.4);
    background: rgba(30, 41, 59, 0.6);
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
}

.fiche-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: transparent;
    transition: background 0.3s;
}

.fiche-card.concept::before {
    background: var(--accent-color);
}

.card-tag {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--accent-color);
    font-weight: 800;
    letter-spacing: 1.5px;
}

.card-title {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.3;
    color: #fff;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-badge {
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.card-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

/* Modal Overlay */
.reader-view {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(2, 6, 23, 0.9);
    backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2.5rem;
}

.reader-modal {
    background: #0f172a;
    width: 100%;
    max-width: 1100px;
    height: 100%;
    border-radius: 32px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    animation: modalIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.reader-header {
    padding: 1.5rem 2.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.breadcrumbs {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.breadcrumbs span:last-child {
    color: var(--accent-color);
    font-weight: 600;
}

.close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
}

.close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.2);
}

.reader-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 320px;
    height: 100%;
}

.markdown-body {
    padding: 4rem 5rem;
    color: #cbd5e1;
    font-size: 1.05rem;
    line-height: 1.75;
}

.markdown-body h1 { font-size: 2.5rem; margin-bottom: 2rem; color: #fff; font-weight: 800; }
.markdown-body h2 { font-size: 1.75rem; margin-top: 3rem; margin-bottom: 1.5rem; color: #f1f5f9; font-weight: 700; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
.markdown-body h3 { font-size: 1.3rem; margin-top: 2rem; margin-bottom: 1rem; color: #fff; }

.related-notes {
    background: rgba(255, 255, 255, 0.01);
    border-left: 1px solid var(--border-color);
    padding: 4rem 2rem;
}

.related-notes h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    letter-spacing: 1px;
}

.related-item {
    padding: 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.related-item:hover {
    background: var(--accent-soft);
    color: var(--accent-color);
    border-color: rgba(56, 189, 248, 0.2);
    transform: translateX(4px);
}

/* Dataview Simulation Styles */
.dataview-container {
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(56, 189, 248, 0.05);
    border-radius: 16px;
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.dataview-list {
    list-style: none;
    padding: 0;
}

.dataview-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.dataview-list li:last-child { border-bottom: none; }

.dataview-list a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.dataview-list a:hover {
    color: #fff;
}

.stat-value {
    color: var(--accent-color) !important;
    font-weight: 700;
    background: var(--accent-soft) !important;
    padding: 2px 8px !important;
}

/* Callouts Obsidian Styles */
.callout {
    padding: 1.5rem 2rem;
    margin: 2.5rem 0;
    border-radius: 16px;
    border-left: 5px solid #444;
    background: rgba(255, 255, 255, 0.03);
    position: relative;
}

.callout-title {
    font-weight: 800;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.callout.info { border-left-color: #38bdf8; background: rgba(56, 189, 248, 0.05); }
.callout.info .callout-title { color: #38bdf8; }

.callout.tip { border-left-color: #4ade80; background: rgba(74, 222, 128, 0.05); }
.callout.tip .callout-title { color: #4ade80; }

.callout.warning { border-left-color: #fbbf24; background: rgba(251, 191, 36, 0.05); }
.callout.warning .callout-title { color: #fbbf24; }

.callout.abstract { border-left-color: #a78bfa; background: rgba(167, 139, 250, 0.05); }
.callout.abstract .callout-title { color: #a78bfa; }

/* Markdown Elements */
.markdown-body table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 2.5rem 0;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.markdown-body th {
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
    font-weight: 600;
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.markdown-body td {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.markdown-body tr:last-child td { border-bottom: none; }

.markdown-body blockquote {
    border-left: 4px solid var(--accent-color);
    padding: 1rem 2rem;
    margin: 2.5rem 0;
    background: var(--accent-soft);
    border-radius: 0 16px 16px 0;
    font-style: italic;
}

.markdown-body code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    color: var(--accent-color);
}

.markdown-body pre {
    background: #020617;
    padding: 2rem;
    border-radius: 16px;
    margin: 2.5rem 0;
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    color: #e2e8f0;
}

/* Legend Graph */
#graph-legend {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 20px;
    z-index: 100;
    color: white;
    font-size: 0.8rem;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
    border-left: 4px solid var(--accent-color);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.dot.concept { background: #38bdf8; box-shadow: 0 0 8px rgba(56, 189, 248, 0.4); }
.dot.pedago { background: #f87171; box-shadow: 0 0 8px rgba(248, 113, 113, 0.4); }
.dot.ethique { background: #4ade80; box-shadow: 0 0 8px rgba(74, 222, 128, 0.4); }
.dot.other { background: #94a3b8; }

.legend-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

.line {
    width: 20px;
    height: 3px;
    border-radius: 2px;
}

.line.semantic {
    background: #4ade80;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
}

/* ============================================================
   NOUVEAUX STYLES — UX IMPROVEMENTS
   ============================================================ */

/* --- Loading state --- */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    gap: 1.5rem;
    padding: 4rem;
}
.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(56, 189, 248, 0.15);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* --- Search clear button --- */
.search-container { position: relative; }
.search-clear {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s;
}
.search-clear:hover { color: var(--text-primary); }

/* --- Sort bar --- */
.sort-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 3rem 1rem 3rem;
    flex-shrink: 0;
}
.sort-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 0.25rem;
}
.sort-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.2s;
}
.sort-btn:hover { background: rgba(255,255,255,0.07); color: var(--text-primary); }
.sort-btn.active {
    background: var(--accent-soft);
    border-color: rgba(56, 189, 248, 0.3);
    color: var(--accent-color);
}
.results-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
    font-weight: 500;
}
.view-mode-btns {
    margin-left: auto;
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.03);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.view-mode-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.view-mode-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.view-mode-btn.active { background: var(--accent-color); color: var(--bg-color); }

/* --- Card chips (FL vs Concept) --- */
.card-chip {
    font-size: 0.62rem;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1.2px;
    padding: 3px 9px;
    border-radius: 6px;
    display: inline-block;
    align-self: flex-start;
}
.chip-fl {
    background: rgba(167, 139, 250, 0.12);
    color: #a78bfa;
    border: 1px solid rgba(167, 139, 250, 0.2);
}
.chip-concept {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    border: 1px solid rgba(56, 189, 248, 0.2);
}
.chip-note {
    background: rgba(148, 163, 184, 0.08);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

/* Override old card top strip for FL cards */
.fiche-card.fl::before { background: #a78bfa; }

/* --- Card snippet --- */
.card-snippet {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Tag "+N more" --- */
.tag-more {
    background: rgba(56, 189, 248, 0.06) !important;
    color: var(--accent-color) !important;
    border-color: rgba(56, 189, 248, 0.2) !important;
    font-weight: 700;
}

/* Toast de chargement (Activité IA) */
.activity-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 16px 20px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 16px;
    color: white;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.activity-toast.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

.spinner-small {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

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

.toast-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toast-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-color);
}

.toast-message {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Empty state --- */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 2rem;
    gap: 1rem;
    text-align: center;
}
.empty-icon { font-size: 3rem; opacity: 0.4; }
.empty-state h3 { font-size: 1.1rem; color: var(--text-secondary); font-weight: 600; }
.empty-state p { font-size: 0.85rem; color: var(--text-muted); }

/* --- Stats panel enrichi --- */
.stats-panel strong { color: var(--accent-color); font-weight: 700; }
.stats-panel span { font-size: 0.75rem; color: var(--text-muted); display: block; margin-top: 4px; }

/* --- List view --- */
.fiches-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 3rem 3rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.list-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(30, 41, 59, 0.35);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
}
.list-row:hover {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(56, 189, 248, 0.2);
}
.list-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.list-title {
    flex: 1;
    font-size: 0.88rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list-tags { display: flex; gap: 5px; flex-shrink: 0; }
.list-tag {
    font-size: 0.65rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.04);
    padding: 2px 7px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
}
.list-type {
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 120px;
    text-align: right;
}

/* --- Reader actions bar --- */
.reader-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 7px 13px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.2s;
}
.nav-btn:hover:not(:disabled) {
    background: var(--accent-soft);
    color: var(--accent-color);
    border-color: rgba(56, 189, 248, 0.3);
}
.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.obsidian-btn {
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.25);
    color: #a78bfa;
    padding: 7px 13px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.2s;
}
.obsidian-btn:hover {
    background: rgba(124, 58, 237, 0.18);
    border-color: rgba(167, 139, 250, 0.4);
}

/* --- Wikilinks dans le lecteur --- */
.wikilink {
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: 1px dashed rgba(56, 189, 248, 0.4);
    transition: all 0.15s;
    font-weight: 500;
}
.wikilink:hover {
    color: #fff;
    border-bottom-color: var(--accent-color);
    border-bottom-style: solid;
}
.wikilink-dead {
    color: var(--text-muted);
    border-bottom: 1px dashed rgba(148, 163, 184, 0.3);
    font-style: italic;
}

/* --- Related empty state --- */
.related-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 1rem 0;
}

/* =========================================
   UPLOAD UI (Dropzone & FAB)
   ========================================= */

.dropzone-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 14, 30, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.dropzone-overlay.active {
    opacity: 1;
    visibility: visible;
}

.dropzone-content {
    border: 3px dashed var(--accent-color);
    border-radius: 20px;
    padding: 4rem;
    text-align: center;
    background: rgba(56, 189, 248, 0.05);
    pointer-events: none; /* Laisse les événements de drop passer à la window */
}

.dropzone-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

.dropzone-content h2 {
    color: #fff;
    margin-bottom: 0.5rem;
}

.dropzone-content p {
    color: var(--text-muted);
}

/* FAB caché par défaut (PC) */
.mobile-fab-btn {
    display: none;
}

/* =========================================
   MOBILE RESPONSIVE (max-width: 768px)
   ========================================= */

/* Header Mobile (hidden on desktop) */
.mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
}

.mobile-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Overlay pour masquer le fond quand le menu est ouvert */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    opacity: 1;
}

@media (max-width: 768px) {
    /* Afficher le FAB sur mobile */
    .mobile-fab-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 24px;
        right: 24px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--accent-color);
        color: #fff;
        font-size: 2rem;
        font-weight: 300;
        border: none;
        box-shadow: 0 4px 16px rgba(56, 189, 248, 0.4);
        cursor: pointer;
        z-index: 90;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .mobile-fab-btn:active {
        transform: scale(0.95);
        box-shadow: 0 2px 8px rgba(56, 189, 248, 0.4);
    }

    /* Header visible sur mobile */
    .mobile-header {
        display: flex;
    }
    
    .mobile-header .logo {
        margin-bottom: 0;
    }

    /* L'overlay devient utilisable (display: block géré via JS si besoin, ou juste flex) */
    .mobile-overlay {
        display: block;
        pointer-events: none; /* Ignorer les clics si non actif */
    }
    
    .mobile-overlay.active {
        pointer-events: auto;
    }

    /* Sidebar transformée en Drawer (Plein Écran) */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        z-index: 150;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        padding: 2rem 1.5rem;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* Masquer le logo de la sidebar sur mobile puisqu'il est dans le header */
    .sidebar .logo {
        display: none;
    }

    /* Ajustement du contenu principal */
    .main-content {
        padding: 0; /* Padding retiré pour coller le header mobile */
    }
    
    .sort-bar {
        padding: 1rem 1.5rem;
        flex-wrap: wrap;
        gap: 10px;
    }

    #graph-container {
        /* Ajuster la hauteur pour tenir compte du header mobile (~60px) */
        height: calc(100vh - 60px) !important;
        border-radius: 0;
    }

    #fiches-grid {
        padding: 0 1rem 1rem 1rem;
        height: calc(100vh - 60px - 70px); /* Hauteur dispo - header - sort bar */
    }

    /* Grilles adaptées à l'écran mobile */
    .books-grid {
        grid-template-columns: 1fr; /* 1 colonne */
        gap: 1rem;
    }

    .concepts-cloud {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    /* Reader Plein Écran */
    .reader-view {
        padding: 0;
    }

    .reader-modal {
        max-width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
    }

    .reader-header {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .reader-actions {
        width: 100%;
        justify-content: space-between;
        overflow-x: auto; /* Permet de scroller les boutons si besoin */
        padding-bottom: 4px;
    }

    /* Rend les boutons plus gros pour le tactile */
    .nav-btn, .obsidian-btn, .close-btn {
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    /* Le bouton fermer doit être bien visible */
    .close-btn {
        background: rgba(239, 68, 68, 0.15);
        color: #ef4444;
        border-color: rgba(239, 68, 68, 0.3);
    }

    /* Reader layout en colonne */
    .reader-body {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
    }

    .markdown-body {
        padding: 1.5rem 1rem;
    }

    .related-notes {
        border-left: none;
        border-top: 1px solid var(--border-color);
        padding: 1.5rem 1rem;
    }

    #graph-legend {
        display: none !important;
    }
}
