:root {
  /* Palette de couleurs repensée et plus élégante */
  --bg-body: #f4f7fb;
  --bg-surface: #ffffff;
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  
  --color-roman: #059669; /* Vert émeraude */
  --color-hors-serie: #0284c7; /* Bleu océan */
  
  --border-light: #e2e8f0;
  --border-strong: #cbd5e1;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  background-color: var(--bg-body);
  -webkit-font-smoothing: antialiased;
}

/* =========================================
   Héro (En-tête)
========================================= */
.hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  width: min(1180px, calc(100% - 2rem));
  margin: 1.5rem auto 2rem;
  padding: 2.5rem 3rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: white;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

/* Effet de lumière subtil dans le header */
.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(79, 70, 229, 0.25) 0%, transparent 60%);
  pointer-events: none;
}

.hero-content h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.subtitle {
  margin: 0.5rem 0 0;
  color: #94a3b8;
  font-size: 1.1rem;
  font-weight: 500;
}

/* =========================================
   Statistiques
========================================= */
.stats {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(12px);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  min-width: 260px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stats-text {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.stats strong {
  font-size: 2.5rem;
  line-height: 1;
  font-weight: 700;
}

.stats span {
  color: #cbd5e1;
  font-weight: 500;
  font-size: 1.1rem;
}

.progress {
  height: 8px;
  margin-top: 1.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #818cf8, #38bdf8);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   Conteneur principal et Barre d'outils
========================================= */
.container {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto 5rem;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 0;
  margin-bottom: 1.5rem;
  position: sticky;
  top: 1rem;
  z-index: 10;
}

/* =========================================
   Boutons et Inputs
========================================= */
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--text-main);
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.2s ease;
  outline: none;
}

input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

button {
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: var(--text-muted);
}

/* =========================================
   Groupes par années
========================================= */
.yearGroup {
  margin-bottom: 2.5rem;
  animation: fadeIn 0.4s ease-out forwards;
}

.yearTitle {
  margin: 0 0 1.25rem 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.yearTitle::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-strong);
  opacity: 0.5;
}

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

/* =========================================
   Cartes de livres (Books)
========================================= */
.book {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.book:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.book .title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-main);
  transition: color 0.2s ease;
  padding-top: 0.1rem;
}

/* Identifiants visuels des collections */
.book.is-hors-serie .title {
  color: var(--color-hors-serie);
}

.book.is-roman .title {
  color: var(--color-roman);
}

/* =========================================
   Custom Checkbox (Pur CSS)
========================================= */
.book input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  margin: 0;
  margin-top: 0.1rem; /* Alignement visuel avec le texte */
  border: 2px solid var(--border-strong);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.book:hover input[type="checkbox"]:not(:checked) {
  border-color: var(--primary);
}

.book input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.book input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* =========================================
   Livre lu (État gris)
========================================= */
.book.is-read {
  background: #f8fafc;
  border-color: var(--border-light);
  box-shadow: none;
}

.book.is-read:hover {
  transform: none;
  background: #f1f5f9;
}

.book.is-read .title {
  color: var(--text-muted) !important;
  font-weight: 500;
}

/* =========================================
   Écran de connexion (Login)
========================================= */
.loginScreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loginScreen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loginBox {
  width: min(400px, 100%);
  padding: 2.5rem;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: scaleUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.loginBox h1 {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  color: var(--text-main);
  letter-spacing: -0.03em;
}

.loginBox p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.loginBox input {
  margin-bottom: 1rem;
}

.loginBox button {
  width: 100%;
}

.loginError {
  margin-top: 1rem;
  min-height: 1.5rem;
  color: #dc2626;
  font-weight: 600;
  font-size: 0.9rem;
}

/* =========================================
   État vide
========================================= */
.empty {
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  font-weight: 500;
}

/* =========================================
   Animations
========================================= */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* =========================================
   Responsive
========================================= */
@media (max-width: 768px) {
  .hero {
    flex-direction: column;
    align-items: stretch;
    padding: 2rem;
    gap: 1.5rem;
  }
  
  .stats {
    width: 100%;
  }

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