:root {
  --fond: #f5f3ef;
  --carte: #ffffff;
  --texte: #1f2328;
  --discret: #6b7280;
  --bord: #e5e1d8;
  --accent: #3b5bdb;
  --code-fond: #1e1e2e;
  --code-texte: #e6e6f0;
  --get: #2f9e44;
  --post: #e8590c;
  --put: #1971c2;
  --delete: #e03131;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond);
  color: var(--texte);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 24px 8px;
}
h1 { margin: 0; font-size: 1.6rem; }
h2 { margin: 0; font-size: 1.1rem; }
.sous-titre { margin: 4px 0 0; color: var(--discret); }

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  padding: 16px 24px 40px;
}

/* Mode simple : on cache tout ce qui est technique, une seule colonne */
body:not(.mode-technique) .technique { display: none !important; }
body:not(.mode-technique) main { grid-template-columns: minmax(0, 720px); justify-content: center; }

@media (max-width: 860px) {
  main, body:not(.mode-technique) main { grid-template-columns: 1fr; padding: 16px; }
  header { padding: 16px 16px 4px; }
}

/* Interrupteur "Détails techniques" */
.interrupteur {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex: 0;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}
.interrupteur input { position: absolute; opacity: 0; pointer-events: none; }
.glissiere {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: #ced4da;
  transition: background 0.2s;
}
.glissiere::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.interrupteur input:checked + .glissiere { background: var(--accent); }
.interrupteur input:checked + .glissiere::after { transform: translateX(18px); }
.interrupteur input:focus-visible + .glissiere { outline: 2px solid var(--accent); outline-offset: 2px; }

.carte {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: 12px;
  padding: 16px;
}

form { display: flex; flex-direction: column; gap: 10px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; flex: 1; }
label.case { flex-direction: row; align-items: center; gap: 8px; flex: 0; white-space: nowrap; margin-top: 18px; }
.ligne { display: flex; gap: 10px; align-items: flex-start; }

input, select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--bord);
  border-radius: 8px;
  background: #fff;
}

button {
  font: inherit;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button.secondaire { background: #e9ecef; color: var(--texte); }
button.danger { background: #fff0f0; color: var(--delete); }
button.petit { padding: 4px 10px; font-size: 0.85rem; }

.barre-liste {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0 10px;
}
.colonne-journal .barre-liste { margin-top: 0; }

.liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.livre {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: 10px;
  padding: 10px 12px;
}
.livre .infos { flex: 1; min-width: 0; }
.couverture, .sans-couverture {
  width: 48px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 4px;
  object-fit: cover;
  background: #eceae4;
}
.sans-couverture { display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.apercu { width: 40px; height: 60px; object-fit: cover; border-radius: 4px; margin-top: 18px; }
.livre .technique { font-family: ui-monospace, Consolas, monospace; font-size: 0.75rem; color: var(--accent); }

@media (max-width: 520px) {
  .livre { flex-wrap: wrap; }
  .livre .actions { width: 100%; justify-content: flex-end; }
}
.livre .titre { font-weight: 600; }
.livre.lu .titre { text-decoration: line-through; color: var(--discret); }
.livre .auteur { font-size: 0.85rem; color: var(--discret); }
.livre .actions { display: flex; gap: 6px; }
.vide { color: var(--discret); font-style: italic; }

/* Journal */
#journal { display: flex; flex-direction: column; gap: 12px; }
.entree {
  background: var(--code-fond);
  color: var(--code-texte);
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.82rem;
}
.entree .requete { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.methode { font-weight: 700; padding: 2px 8px; border-radius: 6px; color: #fff; }
.methode.GET { background: var(--get); }
.methode.POST { background: var(--post); }
.methode.PUT { background: var(--put); }
.methode.DELETE { background: var(--delete); }
.url { word-break: break-all; }
.statut { font-weight: 700; }
.statut.ok { color: #69db7c; }
.statut.ko { color: #ff8787; }
.etiquette { color: #a0a0b8; margin: 10px 0 4px; }
.entree pre {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
