/* =====================================================
   Mes Livres — Feuille de style principale
   ===================================================== */

/* === Variables thèmes === */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --accent: #ec4899;

    --bg: #fafaf7;
    --bg-elevated: #ffffff;
    --bg-subtle: #f4f4f1;
    --bg-hover: #efeeea;

    --text: #1f2937;
    --text-muted: #6b7280;
    --text-soft: #9ca3af;

    --border: #e5e7eb;
    --border-strong: #d1d5db;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 4px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 12px 32px rgba(0,0,0,.12);

    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --font-serif: "Iowan Old Style", "Apple Garamond", Baskerville, "Times New Roman", serif;
    --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
}

[data-theme="dark"] {
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-light: #312e81;

    --bg: #0f1419;
    --bg-elevated: #1a1f26;
    --bg-subtle: #161b22;
    --bg-hover: #232a33;

    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --text-soft: #6b7280;

    --border: #2a323d;
    --border-strong: #3a434f;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow: 0 4px 12px rgba(0,0,0,.4);
    --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
}

[data-theme="sepia"] {
    --primary: #92400e;
    --primary-hover: #78350f;
    --primary-light: #fef3c7;

    --bg: #f5edd6;
    --bg-elevated: #fdf6e3;
    --bg-subtle: #ebe2c4;
    --bg-hover: #e0d4ad;

    --text: #3e2f1c;
    --text-muted: #6b5840;
    --text-soft: #8b7355;

    --border: #d4c4a0;
    --border-strong: #b89c7a;
}

/* === Reset === */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color .3s, color .3s;
}

img, svg { max-width: 100%; display: block; }

a {
    color: var(--primary);
    text-decoration: none;
    transition: color .15s;
}
a:hover { color: var(--primary-hover); }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, textarea, select {
    font-family: inherit;
    font-size: 1rem;
    color: var(--text);
}

::selection { background: var(--primary); color: white; }

/* === Conteneur === */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.container-narrow { max-width: 720px; }

main { flex: 1; }
.main { padding: 2rem 0 4rem; }

/* === Topbar === */
.topbar {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(10px);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
}
.brand:hover { color: var(--text); }
.brand-icon { font-size: 1.6rem; }

.topnav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    color: var(--text-muted);
    font-weight: 500;
    padding: .5rem .75rem;
    border-radius: var(--radius-sm);
    transition: all .15s;
}
.nav-link:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: background .15s;
}
.icon-btn:hover { background: var(--bg-hover); }

[data-theme="light"] .icon-moon,
[data-theme="sepia"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* === Menu utilisateur === */
.user-menu { position: relative; }

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem .75rem .35rem .35rem;
    border-radius: 999px;
    transition: background .15s;
}
.user-menu-btn:hover { background: var(--bg-hover); }

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
}

.user-name {
    font-weight: 500;
    font-size: .9rem;
}

.caret { font-size: .7rem; color: var(--text-muted); }

.user-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: .5rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: .5rem;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: all .18s;
}
.user-menu.open .user-menu-dropdown {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.user-menu-dropdown a {
    display: block;
    padding: .6rem .75rem;
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: .9rem;
}
.user-menu-dropdown a:hover { background: var(--bg-hover); }

/* === Boutons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .65rem 1.25rem;
    font-weight: 600;
    font-size: .95rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: all .15s;
    text-decoration: none;
    line-height: 1.2;
    white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    color: white;
}

.btn-sm { padding: .4rem .85rem; font-size: .85rem; }
.btn-lg { padding: .85rem 1.75rem; font-size: 1.05rem; }
.btn-block { display: flex; width: 100%; }

/* === Cartes === */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

/* === Formulaires === */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    margin-bottom: .4rem;
    font-weight: 500;
    font-size: .9rem;
    color: var(--text);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: .65rem .9rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    font-size: .95rem;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}

.form-textarea { resize: vertical; min-height: 100px; }

.form-help {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: .35rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    user-select: none;
}
.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* === Flash messages === */
.flash-stack {
    position: fixed;
    top: 80px;
    right: 1.5rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: 380px;
}

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .85rem 1rem;
    background: var(--bg-elevated);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    animation: slideIn .3s ease;
}

@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

.flash-success { border-color: var(--success); }
.flash-error   { border-color: var(--danger); }
.flash-warning { border-color: var(--warning); }
.flash-info    { border-color: var(--info); }

.flash-close {
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    padding: 0 .25rem;
}

/* === Page d'accueil (landing) === */
.hero {
    text-align: center;
    padding: 5rem 1rem 4rem;
    max-width: 800px;
    margin: 0 auto;
}

.hero h1 {
    font-family: var(--font-serif);
    font-size: clamp(2.25rem, 5vw, 3.75rem);
    line-height: 1.15;
    margin: 0 0 1rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

.hero h1 em {
    font-style: italic;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin: 0 0 2.5rem;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin: 4rem 0;
}

.feature {
    text-align: center;
    padding: 1.5rem;
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: .75rem;
}

.feature h3 {
    margin: 0 0 .5rem;
    font-size: 1.15rem;
}

.feature p {
    color: var(--text-muted);
    font-size: .95rem;
    margin: 0;
}

/* === Auth (login/register) === */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 64px);
    padding: 2rem 1rem;
}

.auth-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 440px;
}

.auth-title {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    margin: 0 0 .5rem;
    text-align: center;
}

.auth-subtitle {
    color: var(--text-muted);
    text-align: center;
    margin: 0 0 2rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: .9rem;
}

/* === Dashboard === */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.dashboard-title {
    font-family: var(--font-serif);
    font-size: 2rem;
    margin: 0;
}

.dashboard-subtitle {
    color: var(--text-muted);
    margin: .25rem 0 0;
}

.filter-bar {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.filter-chip {
    padding: .4rem .9rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: .85rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
}
.filter-chip:hover {
    border-color: var(--primary);
    color: var(--text);
}
.filter-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* === Grille de livres === */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
}

.book-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform .2s, box-shadow .2s;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    position: relative;
}
.book-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    color: inherit;
}

.book-cover {
    height: 160px;
    background: var(--cover-color, var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.book-cover::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(0,0,0,.15) 100%);
}

.book-cover-icon {
    font-size: 3rem;
    z-index: 1;
}

.book-lock {
    position: absolute;
    top: .75rem;
    right: .75rem;
    background: rgba(0,0,0,.4);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    backdrop-filter: blur(4px);
}

.book-info {
    padding: 1rem 1.1rem 1.2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-title {
    font-weight: 600;
    font-size: 1.05rem;
    margin: 0 0 .35rem;
    line-height: 1.3;
    color: var(--text);
}

.book-meta {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: auto;
    padding-top: .5rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.book-type-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .75rem;
    color: var(--text-muted);
}

/* Carte d'ajout */
.book-card-add {
    border: 2px dashed var(--border-strong);
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 280px;
    transition: all .18s;
}
.book-card-add:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.book-card-add-content {
    padding: 2rem;
}
.book-card-add-icon {
    font-size: 2.5rem;
    margin-bottom: .5rem;
}

/* === État vide === */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}
.empty-state h2 {
    color: var(--text);
    font-family: var(--font-serif);
    margin: 0 0 .5rem;
}
.empty-state p {
    margin: 0 0 1.5rem;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

/* === Vue d'un livre === */
.book-header {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0;
    overflow: hidden;
    margin-bottom: 2rem;
}

.book-header-banner {
    height: 120px;
    background: var(--cover-color, var(--primary));
    position: relative;
}

.book-header-content {
    padding: 1.5rem 2rem 1.75rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.book-header-info h1 {
    font-family: var(--font-serif);
    margin: 0 0 .35rem;
    font-size: 1.85rem;
}

.book-header-meta {
    color: var(--text-muted);
    font-size: .9rem;
}

.book-header-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

/* Liste d'entrées */
.entries-list {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.entry-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    transition: all .15s;
    color: inherit;
    text-decoration: none;
}
.entry-item:hover {
    border-color: var(--primary);
    transform: translateX(3px);
    color: inherit;
}

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

.entry-item-title {
    font-weight: 600;
    margin: 0 0 .25rem;
    font-size: 1.05rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entry-item-preview {
    color: var(--text-muted);
    font-size: .85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
}

.entry-item-meta {
    color: var(--text-soft);
    font-size: .8rem;
    text-align: right;
    flex-shrink: 0;
}

.entry-position {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    flex-shrink: 0;
}

/* === Éditeur === */
.editor-page {
    background: var(--bg);
}

.editor-toolbar {
    position: sticky;
    top: 64px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    z-index: 40;
    backdrop-filter: blur(10px);
}

.editor-toolbar-inner {
    max-width: 920px;
    margin: 0 auto;
    padding: .65rem 1.5rem;
    display: flex;
    align-items: center;
    gap: .25rem;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 .25rem;
    border-right: 1px solid var(--border);
}
.toolbar-group:last-child { border-right: none; }

.toolbar-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    transition: all .12s;
}
.toolbar-btn:hover { background: var(--bg-hover); color: var(--text); }
.toolbar-btn.active { background: var(--primary-light); color: var(--primary); }
.toolbar-btn b, .toolbar-btn i, .toolbar-btn u, .toolbar-btn s { font-style: normal; }
.toolbar-btn b { font-weight: 800; }
.toolbar-btn i { font-style: italic; font-family: var(--font-serif); }
.toolbar-btn u { text-decoration: underline; }
.toolbar-btn s { text-decoration: line-through; }

.toolbar-spacer { flex: 1; }

.toolbar-status {
    font-size: .82rem;
    color: var(--text-muted);
    padding: 0 .5rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.save-indicator {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}
.save-indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}
.save-indicator.saving .save-indicator-dot {
    background: var(--warning);
    animation: pulse 1s infinite;
}

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

.editor-container {
    max-width: 920px;
    margin: 0 auto;
    padding: 2rem 1.5rem 5rem;
}

.editor-title {
    width: 100%;
    border: none;
    background: transparent;
    font-family: var(--font-serif);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text);
    padding: .75rem 0;
    margin-bottom: 1rem;
    outline: none;
}
.editor-title::placeholder { color: var(--text-soft); }

.editor-meta-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}
.editor-meta-row input,
.editor-meta-row select {
    padding: .4rem .7rem;
    font-size: .9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
}

.editor-content {
    width: 100%;
    min-height: 400px;
    border: none;
    background: transparent;
    font-family: var(--font-serif);
    font-size: 1.15rem;
    line-height: 1.75;
    color: var(--text);
    padding: 0;
    outline: none;
}

.editor-content[contenteditable=true]:empty:before {
    content: attr(data-placeholder);
    color: var(--text-soft);
    font-style: italic;
    pointer-events: none;
}

.editor-content h1,
.editor-content h2,
.editor-content h3 {
    font-family: var(--font-serif);
    margin-top: 1.5em;
    margin-bottom: .5em;
}
.editor-content h1 { font-size: 1.85em; }
.editor-content h2 { font-size: 1.5em; }
.editor-content h3 { font-size: 1.25em; }

.editor-content p { margin: 0 0 1em; }

.editor-content blockquote {
    border-left: 4px solid var(--primary);
    margin: 1em 0;
    padding: .25em 0 .25em 1.25em;
    color: var(--text-muted);
    font-style: italic;
}

.editor-content pre {
    background: var(--bg-subtle);
    padding: 1em;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: .9em;
}

.editor-content code {
    background: var(--bg-subtle);
    padding: .15em .35em;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: .9em;
}

.editor-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2em 0;
}

.editor-content ul, .editor-content ol {
    padding-left: 1.5em;
}

.editor-content a {
    color: var(--primary);
    text-decoration: underline;
}

/* Mode focus / sans distraction */
body.focus-mode .topbar,
body.focus-mode .footer { display: none; }
body.focus-mode .editor-toolbar { top: 0; }

/* === Page de lecture === */
.reader-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1.5rem 5rem;
}

.reader-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.reader-title {
    font-family: var(--font-serif);
    font-size: 2.25rem;
    margin: 0 0 .5rem;
    line-height: 1.2;
}

.reader-meta {
    color: var(--text-muted);
    font-size: .9rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.reader-content {
    font-family: var(--font-serif);
    font-size: 1.18rem;
    line-height: 1.8;
}

.reader-content h1,
.reader-content h2,
.reader-content h3 {
    font-family: var(--font-serif);
    margin: 2em 0 .5em;
}

.reader-content blockquote {
    border-left: 4px solid var(--primary);
    margin: 1.5em 0;
    padding: .5em 0 .5em 1.5em;
    color: var(--text-muted);
    font-style: italic;
}

.reader-content p { margin: 0 0 1.2em; }

/* === Recherche === */
.search-form {
    display: flex;
    gap: .5rem;
    margin-bottom: 2rem;
}

.search-form input {
    flex: 1;
    padding: .85rem 1.1rem;
    font-size: 1rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg-elevated);
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-result {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: all .15s;
}
.search-result:hover {
    border-color: var(--primary);
    color: inherit;
    box-shadow: var(--shadow-sm);
}

.search-result-book {
    color: var(--text-muted);
    font-size: .82rem;
    margin-bottom: .25rem;
}

.search-result-title {
    font-weight: 600;
    margin: 0 0 .5rem;
}

.search-result-snippet {
    color: var(--text-muted);
    font-size: .92rem;
    margin: 0;
}
.search-result-snippet mark {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0 2px;
    border-radius: 3px;
}

/* === Modale === */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn .2s;
}
.modal-backdrop.open { display: flex; }

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

.modal {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
    max-height: 85vh;
    overflow: auto;
    animation: slideUp .25s;
}

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

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

.modal-title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 1.35rem;
}

.modal-body { padding: 1.5rem; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* === Sélection couleur === */
.color-picker {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform .12s;
    border: 3px solid transparent;
}
.color-option:hover { transform: scale(1.1); }
.color-option.selected {
    border-color: var(--text);
}

/* === Sélection type de livre === */
.type-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .75rem;
}

.type-option {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem .75rem;
    text-align: center;
    cursor: pointer;
    transition: all .15s;
    background: var(--bg-elevated);
}
.type-option:hover { border-color: var(--primary); }
.type-option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}
.type-option-icon { font-size: 1.75rem; margin-bottom: .25rem; }
.type-option-label {
    font-size: .82rem;
    font-weight: 500;
    color: var(--text);
}

/* === Footer === */
.footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    color: var(--text-muted);
    font-size: .9rem;
    text-align: center;
}

/* === Responsive === */
@media (max-width: 768px) {
    .container { padding: 0 1rem; }
    .topbar-inner { height: 56px; }
    .nav-link { padding: .35rem .5rem; font-size: .85rem; }
    .user-name { display: none; }
    .hero { padding: 3rem 1rem 2rem; }
    .auth-card { padding: 1.75rem 1.25rem; }
    .form-row { grid-template-columns: 1fr; }
    .editor-title { font-size: 1.65rem; }
    .editor-content { font-size: 1.05rem; }
    .reader-title { font-size: 1.7rem; }
    .reader-content { font-size: 1.05rem; }
    .book-header-content { padding: 1rem 1.25rem 1.25rem; }
    .flash-stack { left: 1rem; right: 1rem; max-width: none; top: 70px; }
    .editor-toolbar-inner { padding: .5rem .75rem; }
    .books-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
    .book-cover { height: 130px; }
    .book-cover-icon { font-size: 2.25rem; }
}

/* =====================================================
   ADMIN PANEL
   ===================================================== */

/* Badges de rôle */
.role-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    line-height: 1;
}

.role-pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.role-pill-user {
    background: #f3f4f6;
    color: #6b7280;
}
.role-pill-moderator {
    background: #fef3c7;
    color: #92400e;
}
.role-pill-admin {
    background: #fee2e2;
    color: #991b1b;
}
[data-theme="dark"] .role-pill-user      { background: #2a323d; color: #9ca3af; }
[data-theme="dark"] .role-pill-moderator { background: #44391a; color: #fbbf24; }
[data-theme="dark"] .role-pill-admin     { background: #4c1d1d; color: #fca5a5; }

.nav-link-admin {
    color: var(--danger) !important;
    font-weight: 600;
}

.status-badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.status-badge-active   { background: #d1fae5; color: #065f46; }
.status-badge-inactive { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .status-badge-active   { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .status-badge-inactive { background: #4c1d1d; color: #fca5a5; }

/* Layout admin */
.admin-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.admin-sidebar {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    height: fit-content;
    position: sticky;
    top: 80px;
}

.admin-sidebar-title {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-soft);
    padding: .5rem .75rem .35rem;
    margin: 0;
    font-weight: 600;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.admin-nav a {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .6rem .75rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: .9rem;
    font-weight: 500;
    transition: all .12s;
}
.admin-nav a:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.admin-nav a.active {
    background: var(--primary-light);
    color: var(--primary);
}

.admin-main { min-width: 0; }

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.admin-title {
    font-family: var(--font-serif);
    font-size: 1.85rem;
    margin: 0;
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
}

.stat-label {
    font-size: .8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    margin: 0 0 .35rem;
}

.stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}
.stat-value.colored { color: var(--primary); }

.stat-detail {
    font-size: .82rem;
    color: var(--text-muted);
    margin-top: .35rem;
}

/* Tableaux admin */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.admin-table thead {
    background: var(--bg-subtle);
}

.admin-table th {
    text-align: left;
    padding: .85rem 1rem;
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.admin-table td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: .92rem;
}

.admin-table tr:last-child td { border-bottom: none; }

.admin-table tr:hover td {
    background: var(--bg-hover);
}

.admin-table .user-cell {
    display: flex;
    align-items: center;
    gap: .65rem;
}

.admin-table .user-cell .user-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.admin-table .user-cell-info {
    min-width: 0;
}

.admin-table .user-cell-name {
    font-weight: 600;
    color: var(--text);
}

.admin-table .user-cell-username {
    font-size: .8rem;
    color: var(--text-muted);
}

.admin-table-actions {
    display: flex;
    gap: .35rem;
    justify-content: flex-end;
}

.admin-table .icon-btn-sm {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all .12s;
    background: transparent;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: .9rem;
}
.admin-table .icon-btn-sm:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.admin-table .icon-btn-sm.danger:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* Toolbar de recherche/filtres */
.admin-toolbar {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.admin-toolbar input,
.admin-toolbar select {
    padding: .5rem .75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    font-size: .9rem;
}

.admin-toolbar input { flex: 1; min-width: 200px; }

/* Page d'erreur 403 / Accès refusé */
.access-denied {
    text-align: center;
    padding: 4rem 2rem;
}
.access-denied-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

/* Pagination */
.pagination {
    display: flex;
    gap: .35rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: .4rem .75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: .9rem;
    text-decoration: none;
}
.pagination a:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.pagination .current {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Responsive admin */
@media (max-width: 900px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }
    .admin-sidebar {
        position: static;
    }
    .admin-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .admin-table {
        font-size: .85rem;
    }
    .admin-table th, .admin-table td {
        padding: .6rem .5rem;
    }
}
