* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #222;
  background: #fafafa;
}
header, footer {
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid #eee;
}
footer { border-top: 1px solid #eee; border-bottom: 0; }
main { padding: 20px; max-width: 900px; margin: 0 auto; }

/* Modal */
.modal.hidden { display: none; }
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.modal-content {
  background: #fff; color: #222;
  border-radius: 12px; border: 1px solid #e6e6e6;
  width: min(100%, 960px);
  max-height: 90vh; overflow: auto;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}
.modal-actions, .modal-footer { display: flex; gap: 8px; align-items: center; }
.modal-actions { margin: 8px 0 12px; }
.modal-footer { margin-top: 12px; justify-content: flex-end; }

/* Grille de vignettes */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.thumb {
  position: relative;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 8px;
}
.thumb canvas, .thumb img {
  display: block; width: 100%; height: auto;
  border-radius: 6px;
  background: #f8f8f8;
}
.thumb .page-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px; font-size: 12px; color: #555;
}
.thumb .page-meta input[type="checkbox"] { transform: translateY(1px); }

/* Aperçu plein cadre */
.preview.hidden { display: none; }
.preview { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.preview-content { background: #fff; border-radius: 12px; border: 1px solid #e6e6e6; width: min(100%, 95vw); height: min(100%, 95vh); display: flex; flex-direction: column; overflow: hidden; }
.preview-toolbar { display: flex; gap: 8px; align-items: center; padding: 8px; border-bottom: 1px solid #eee; }
.preview-toolbar .spacer { flex: 1; }
.preview-body { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; background: #f6f6f6; }
.preview-body canvas { background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,0.15); }

.drop-section { margin: 24px 0; }
.actions { margin-top: 12px; display: flex; gap: 8px; }
.btn { border: 1px solid #ddd; background: #fff; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: #4a42f3; border-color: #4a42f3; color: #fff; }

.dropzone {
  position: relative;
  border: 2px dashed #6c63ff;
  border-radius: 12px;
  background: #f5f5ff;
  color: #333;
  min-height: 160px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  cursor: pointer;
  outline: none;
}
.dropzone.dragover {
  background: #ebe9ff;
  border-color: #4a42f3;
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-list { list-style: none; padding: 0; margin: 12px 0 0; }
.file-list li {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.file-list li.dragging { opacity: 0.6; }
.file-list li.dragover { border-color: #4a42f3; background: #f0efff; }
.file-list .name { font-weight: 600; }
.file-list .meta { color: #666; font-size: 0.9em; }

.item-actions { display: flex; gap: 6px; }
.item-actions .icon-btn { border: 1px solid #ddd; background: #f9f9f9; border-radius: 6px; padding: 6px 8px; cursor: pointer; }
