body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, sans-serif;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    height: 100vh; /* Prend toute la hauteur de l'écran */
}

/* Barre de navigation supérieure */
.top-bar {
    background-color: #ffffff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}
.back-link {
    text-decoration: none;
    color: #2c3e50;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}
.back-link:hover { color: #3498db; }
.book-title {
    margin: 0;
    font-size: 1.1rem;
    color: #7f8c8d;
}

/* Conteneur principal du lecteur */
.reader-container {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Boutons Précédent/Suivant */
.nav-btn {
    background: transparent;
    border: none;
    font-size: 2rem;
    color: #bdc3c7;
    cursor: pointer;
    padding: 20px;
    transition: color 0.2s, transform 0.2s;
    z-index: 5;
}
.nav-btn:hover {
    color: #3498db;
    transform: scale(1.1);
}

/* Zone d'affichage du livre */
#viewer {
    flex: 1;
    height: 90%;
    max-width: 1200px;
    background-color: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    border-radius: 8px;
    overflow: hidden;
}

.chapter-selector {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: #fff;
    color: #333;
    font-weight: bold;
    cursor: pointer;
    margin-right: 15px; /* Sépare la liste du bouton Thème */
    max-width: 250px;
}

/* Variante pour ton mode sombre (grâce à la classe dark-ui déjà en place) */
body.dark-ui .chapter-selector {
    background-color: #444;
    color: #fff;
    border-color: #666;
}

/* Style par défaut (Thème clair) */
.page-info {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 100; /* Assure que ce soit toujours au premier plan */
    pointer-events: none; /* Empêche l'élément de bloquer les clics sur le livre */
}

/* Adaptation pour le Thème Sombre */
body.dark-ui .page-info {
    background-color: rgba(44, 44, 44, 0.9);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* --- MODALE D'ÉDITION --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}
.modal-content {
    background: #fff;
    color: #333;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
body.dark-ui .modal-content {
    background: #2c2c2c;
    color: #fff;
}
.modal-content input, .modal-content textarea {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.modal-content textarea {
    height: 400px;
    font-family: monospace;
    background: #1e1e1e;
    color: #4CAF50; /* Vert style Matrix pour bien différencier le code */
}
.modal-content button {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    color: white;
    background: #007BFF;
    cursor: pointer;
    font-weight: bold;
}
.modal-content button:hover { opacity: 0.8; }
#edit-message { margin-top: 10px; font-weight: bold; }
