:root {
    --bg: #12100e;
    --surface: #1d1a16;
    --surface-2: #26221d;
    --border: #38322a;
    --text: #ece7df;
    --text-dim: #a89e8f;
    --accent: #d9a441;
    --accent-2: #7fb0a3;
    --ok: #6fbf73;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

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

header.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.75rem;
}

header.site-header .brand { font-weight: 700; font-size: 1.1rem; }
header.site-header nav a { margin-right: 1rem; color: var(--text-dim); }
header.site-header nav a:hover { color: var(--text); }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

h1, h2, h3 { line-height: 1.2; }

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card img.cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    background: var(--surface-2);
}

.card .body { padding: 0.75rem; flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }
.card .title {
    font-weight: 600;
    line-height: 1.3;
    min-height: 2.6em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card .meta { color: var(--text-dim); font-size: 0.85rem; }

.card.ghost {
    border-style: dashed;
    opacity: 0.6;
}
.card.ghost .cover-placeholder {
    width: 100%;
    aspect-ratio: 3 / 4;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 1.5rem;
    font-weight: 700;
}

.badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-dim);
    border: 1px solid var(--border);
}
.badge.lu { color: var(--ok); border-color: var(--ok); }
.badge.en_cours { color: var(--accent-2); border-color: var(--accent-2); }
.badge.a_lire { color: var(--text-dim); }
.badge.priority-high { color: #e07a7a; border-color: #e07a7a; }

.card-series { border-color: var(--accent); }
.card-series .cover-wrap { position: relative; }
.card-series .stack-badge {
    position: absolute; top: 0.4rem; right: 0.4rem;
    background: var(--accent); color: #16130f; font-weight: 700; font-size: 0.72rem;
    padding: 0.2rem 0.55rem; border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    white-space: nowrap;
}

table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 0.85rem; }

.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem; }
.filters select, .filters input { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 0.4rem 0.6rem; border-radius: 6px; }

.stat-row { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0; }
.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    min-width: 150px;
}
.stat-tile .value { font-size: 1.6rem; font-weight: 700; }
.stat-tile .label { color: var(--text-dim); font-size: 0.85rem; }

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.progress-bar-fill { height: 100%; background: var(--accent); }

.status-picker { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }
.status-picker button { border-radius: 999px; padding: 0.35rem 0.9rem; font-size: 0.85rem; }
.status-picker button.active.lu { background: var(--ok); color: #16130f; }
.status-picker button.active.en_cours { background: var(--accent-2); color: #16130f; }
.status-picker button.active.a_lire { background: var(--accent); color: #16130f; }

.missing-tomes { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.missing-tomes .badge.gap { color: #e07a7a; border-color: #e07a7a; }
.missing-tomes .badge.future { color: var(--text-dim); }

form.entity-form { display: flex; flex-direction: column; gap: 0.9rem; max-width: 560px; }
form.entity-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--text-dim); }
form.entity-form input, form.entity-form select, form.entity-form textarea {
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    padding: 0.5rem 0.6rem; border-radius: 6px; font: inherit;
}
form.entity-form textarea { min-height: 80px; }

button, .btn {
    background: var(--accent); color: #16130f; border: none; padding: 0.55rem 1rem;
    border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 0.9rem;
}
button.secondary, .btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button.danger, .btn.danger { background: #e05a5a; color: white; }

.autocomplete { position: relative; }
.autocomplete-results {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
    max-height: 280px; overflow-y: auto; margin-top: 4px;
}
.autocomplete-results .item { display: flex; gap: 0.6rem; padding: 0.5rem; cursor: pointer; align-items: center; }
.autocomplete-results .item:hover { background: var(--surface); }
.autocomplete-results img { width: 36px; height: 48px; object-fit: cover; border-radius: 4px; background: var(--bg); }

.cover-candidate {
    display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
    cursor: pointer; padding: 0.4rem; border-radius: 8px; border: 2px solid transparent;
    width: 90px;
}
.cover-candidate img { width: 72px; height: 96px; object-fit: cover; border-radius: 4px; background: var(--surface-2); }
.cover-candidate span { font-size: 0.7rem; color: var(--text-dim); text-align: center; }
.cover-candidate:hover { background: var(--surface-2); }
.cover-candidate.selected { border-color: var(--accent); }
.cover-candidate:has(input:checked) { border-color: var(--accent); background: var(--surface-2); }
.cover-candidate input[type="radio"] { margin: 0 0 0.3rem 0; }
.cover-candidate .cover-placeholder {
    width: 72px; height: 96px; display: flex; align-items: center; justify-content: center;
    background: var(--surface-2); border-radius: 4px; color: var(--text-dim); font-weight: 700;
}

.autosave-indicator {
    position: fixed; top: 1rem; right: 1rem; padding: 0.55rem 1rem; border-radius: 8px;
    font-weight: 600; font-size: 0.85rem; opacity: 0; transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease; pointer-events: none; z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.autosave-indicator.visible { opacity: 1; transform: translateY(0); }
.autosave-indicator.ok { background: var(--ok); color: #16130f; }
.autosave-indicator.error { background: #e05a5a; color: white; }

.empty { color: var(--text-dim); font-style: italic; padding: 2rem 0; }
.actions { display: flex; gap: 0.6rem; margin-top: 0.5rem; flex-wrap: wrap; }
.section { margin-bottom: 2rem; }
