:root {
  --bg: #f6f3ec;
  --card: #fdfbf7;
  --ink: #24211b;
  --muted: #837b6d;
  --accent: #a4512a;
  --accent-ink: #8a4222;
  --accent-soft: #f1e3d8;
  --green: #41724f;
  --green-soft: #e6ede4;
  --amber: #a37e1f;
  --amber-soft: #f2ead2;
  --red: #9d3b32;
  --border: #e2dccd;
  --radius: 8px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

/* Thème sombre : forcé via data-theme="dark", ou automatique (préférence
   système) tant que data-theme="light" n'est pas posé. */
:root[data-theme="dark"] {
  --bg: #1b1915;
  --card: #23201b;
  --ink: #e9e4d8;
  --muted: #948c7c;
  --accent: #c97949;
  --accent-ink: #d98d5e;
  --accent-soft: #382c22;
  --green: #7ba888;
  --green-soft: #26302a;
  --amber: #c9a44a;
  --amber-soft: #35301f;
  --red: #c56b60;
  --border: #38342b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1915;
    --card: #23201b;
    --ink: #e9e4d8;
    --muted: #948c7c;
    --accent: #c97949;
    --accent-ink: #d98d5e;
    --accent-soft: #382c22;
    --green: #7ba888;
    --green-soft: #26302a;
    --amber: #c9a44a;
    --amber-soft: #35301f;
    --red: #c56b60;
    --border: #38342b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: 48px;
}

/* ---------- Barre de navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: baseline; gap: 28px;
  padding: 14px 70px 0 24px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--serif);
  font-weight: 600; font-size: 1.15rem;
  padding-bottom: 12px;
}
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a {
  text-decoration: none; color: var(--muted);
  padding: 0 10px 12px; font-size: 0.92rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.nav a.active { color: var(--ink); border-bottom-color: var(--accent); }
.nav a:hover { color: var(--ink); }

.theme-pick { position: absolute; top: 8px; right: 12px; }
.theme-pick select {
  width: auto; padding: 2px 16px 2px 8px; font-size: 0.72rem;
  color: var(--muted); border-color: transparent;
  cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background: transparent
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat right 5px center / 8px;
}
.theme-pick select:hover, .theme-pick select:focus { border-color: var(--border); color: var(--ink); }

main { max-width: 1060px; margin: 0 auto; padding: 28px 20px; }

h1 {
  font-family: var(--serif);
  font-size: 1.7rem; font-weight: 600;
  margin: 4px 0 20px;
}
h2 {
  font-family: var(--serif);
  font-size: 1.2rem; font-weight: 600;
  margin: 30px 0 12px;
}

/* ---------- Composants ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink); color: var(--bg); border: 1px solid var(--ink);
  padding: 9px 16px; border-radius: var(--radius); font-size: 0.9rem;
  font-weight: 500; cursor: pointer; text-decoration: none;
  font-family: inherit;
}
.btn:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--border); }
.btn.secondary:hover { border-color: var(--muted); background: transparent; color: var(--ink); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--border); }
.btn.danger:hover { border-color: var(--red); background: transparent; color: var(--red); }
.btn.small { padding: 5px 11px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: default; }

input, textarea, select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--card); color: var(--ink);
  font-size: 0.92rem; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
label {
  display: block; margin: 14px 0 5px;
  font-size: 0.72rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 0.86rem; }
.empty { text-align: center; color: var(--muted); padding: 48px 10px; font-style: italic; }
a { color: var(--accent-ink); }

/* ---------- Barre de progression ---------- */
.progress { background: var(--border); border-radius: 99px; height: 6px; overflow: hidden; }
.progress > div { background: var(--accent); height: 100%; border-radius: 99px; transition: width 0.3s; }
.progress.green > div { background: var(--green); }

/* ---------- Grille de livres ---------- */
.book-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.book-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column;
  transition: border-color 0.15s;
}
.book-card:hover { border-color: var(--muted); }
.book-cover {
  position: relative;
  aspect-ratio: 3 / 4; background: var(--accent-soft); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-card .info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.book-card .title { font-family: var(--serif); font-weight: 600; font-size: 0.95rem; line-height: 1.3; }
.book-card .artist { color: var(--muted); font-size: 0.8rem; }

/* ---------- Rangée de couvertures (accueil) ---------- */
.cover-row {
  display: flex; gap: 14px; overflow-x: auto;
  padding: 2px 2px 10px;
  -webkit-overflow-scrolling: touch;
}
.cover-mini {
  width: 96px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 5px;
  text-decoration: none; color: var(--ink);
  position: relative;
}
.cover-mini .c {
  aspect-ratio: 3 / 4; border-radius: var(--radius); overflow: hidden;
  background: var(--accent-soft); color: var(--muted);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.cover-mini .c img { width: 100%; height: 100%; object-fit: cover; }
.cover-mini:hover .c { border-color: var(--muted); }
.cover-mini .pct {
  position: absolute; top: 6px; right: 6px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 99px; padding: 1px 7px;
  font-size: 0.7rem; font-weight: 600;
}
.cover-mini .t {
  font-size: 0.76rem; line-height: 1.3; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cover-mini .rel { font-size: 0.72rem; color: var(--muted); }

/* ---------- Grille de pages ---------- */
.page-grid {
  display: grid; gap: 7px;
  grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
}
.page-cell {
  aspect-ratio: 1; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.9rem; cursor: pointer;
  background: var(--card); color: var(--muted);
  border: 1px solid var(--border);
  position: relative;
  font-family: inherit;
}
.page-cell:hover { border-color: var(--muted); }
.page-cell.done { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.page-cell.in_progress { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.page-cell.skipped { opacity: 0.4; text-decoration: line-through; }
.page-cell .dot {
  position: absolute; bottom: 5px; width: 4px; height: 4px;
  border-radius: 50%; background: currentColor;
}

/* ---------- Contrôle segmenté (statut de page) ---------- */
.segmented {
  display: flex;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--card);
}
.segmented button {
  flex: 1; padding: 9px 4px;
  background: transparent; border: none; cursor: pointer;
  font-family: inherit; font-size: 0.85rem; color: var(--muted);
  border-right: 1px solid var(--border);
}
.segmented button:last-child { border-right: none; }
.segmented button:hover { color: var(--ink); }
.segmented button.active { font-weight: 600; background: var(--accent-soft); color: var(--ink); }
.segmented button.active.todo { background: var(--accent-soft); color: var(--ink); }
.segmented button.active.in_progress { background: var(--amber-soft); color: var(--amber); }
.segmented button.active.done { background: var(--green-soft); color: var(--green); }
.segmented button.active.skipped { background: var(--bg); color: var(--muted); text-decoration: line-through; }

/* ---------- Étoiles ---------- */
.stars { display: inline-flex; gap: 2px; cursor: pointer; font-size: 1.2rem; user-select: none; color: var(--amber); }
.stars.readonly { cursor: default; font-size: 0.9rem; }
.stars .off { color: var(--border); }

/* ---------- Galerie ---------- */
.gallery-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.gallery-item { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; }
.gallery-item:hover { border-color: var(--muted); }
.gallery-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.gallery-item .caption { padding: 9px 12px; font-size: 0.85rem; }
.gallery-item .caption b { font-family: var(--serif); }

/* ---------- Modales ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(30, 26, 18, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 16px;
}
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  padding: 24px;
}
.modal h2 { margin-top: 0; }

/* ---------- Résultats de recherche ---------- */
.result-card {
  display: flex; gap: 14px; padding: 12px; border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 10px; align-items: flex-start;
}
.result-card img, .result-card .no-cover {
  width: 62px; height: 86px; object-fit: cover; border-radius: 4px;
  background: var(--accent-soft); color: var(--muted); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.result-card .r-info { flex: 1; min-width: 0; }
.result-card .r-title { font-family: var(--serif); font-weight: 600; font-size: 0.98rem; }
.result-card .r-desc {
  font-size: 0.82rem; color: var(--muted); margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---------- Statistiques ---------- */
.stat-tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat-tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 14px; }
.stat-tile .v { font-family: var(--serif); font-size: 1.8rem; font-weight: 600; }
.stat-tile .l {
  font-size: 0.7rem; color: var(--muted); margin-top: 2px;
  text-transform: uppercase; letter-spacing: 0.06em;
}

.bar-chart { display: flex; gap: 8px; align-items: flex-end; height: 150px; padding-top: 10px; }
.bar-chart .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.bar-chart .bar > div { width: 100%; max-width: 40px; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 3px; }
.bar-chart .bar span { font-size: 0.68rem; color: var(--muted); }
.bar-chart .bar b { font-size: 0.78rem; font-weight: 600; }

/* ---------- Photos avant / après ---------- */
.photo-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-slot {
  border: 1px dashed var(--border); border-radius: var(--radius);
  aspect-ratio: 3 / 4; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  color: var(--muted); font-size: 0.85rem; cursor: pointer; overflow: hidden;
  position: relative; text-align: center; padding: 8px;
}
.photo-slot:hover { border-color: var(--muted); }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.photo-slot .del {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  background: rgba(20, 16, 10, 0.6); color: #fff; border: none; border-radius: 4px;
  padding: 4px 9px; cursor: pointer; font-size: 0.8rem;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
#toast .t {
  background: var(--ink); color: var(--bg); padding: 9px 18px;
  border-radius: var(--radius); font-size: 0.88rem;
  animation: toast-in 0.25s;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Fiche livre ---------- */
.book-header { display: flex; gap: 22px; align-items: flex-start; }
.book-header .cover-lg {
  width: 132px; aspect-ratio: 3/4; border-radius: var(--radius); overflow: hidden;
  background: var(--accent-soft); color: var(--muted); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.book-header .cover-lg img { width: 100%; height: 100%; object-fit: cover; }
.book-header h1 { margin-bottom: 2px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); margin: 12px 0; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.buy-links { display: flex; gap: 6px; flex-wrap: wrap; }
.buy-links a {
  font-size: 0.8rem; text-decoration: none;
  padding: 4px 11px; border-radius: 99px;
  border: 1px solid var(--border); color: var(--ink);
  background: transparent;
}
.buy-links a:hover { border-color: var(--muted); }

/* ---------- Aperçu couverture ---------- */
.cover-preview {
  width: 88px; aspect-ratio: 3 / 4; border-radius: var(--radius); overflow: hidden;
  background: var(--accent-soft); color: var(--muted); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); font-size: 0.75rem; text-align: center;
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 640px) {
  .topbar { gap: 12px; padding: 12px 16px 0; }
  .nav a { padding: 0 7px 12px; font-size: 0.86rem; }
  .book-header { flex-direction: column; align-items: center; text-align: center; }
  .photo-pair { grid-template-columns: 1fr; }
}

/* ---------- Modale large (galerie) ---------- */
.modal.wide { max-width: 760px; }
code { font-size: 0.85em; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }

/* ---------- Navigation de page en page ---------- */
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.page-head h2 { flex: 1; margin: 0; text-align: center; }
.nav-btn {
  width: 38px; height: 38px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); color: var(--ink); cursor: pointer;
}
.nav-btn:hover:not(:disabled) { border-color: var(--muted); }
.nav-btn:disabled { opacity: 0.3; cursor: default; }
.hint { font-size: 0.78rem; margin: 10px 0 0; }

/* ---------- Sélection multiple des pages ---------- */
.page-grid.selecting .page-cell { cursor: copy; }
.page-cell.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.bulk-bar {
  position: sticky; bottom: 12px; z-index: 40;
  margin-top: 16px; padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(30, 26, 18, 0.12);
}
.bulk-bar[hidden] { display: none; }
.bulk-actions { display: flex; gap: 6px; flex-wrap: wrap; }
#bulk-count { font-weight: 600; font-size: 0.9rem; }

/* ---------- Bibliothèque : recherche, filtres, tri ---------- */
.lib-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.lib-toolbar input[type="search"] { flex: 1; min-width: 200px; }
.lib-toolbar select { width: auto; }
.segmented.compact button { padding: 7px 12px; font-size: 0.82rem; flex: none; }
.badge-done {
  position: absolute; top: 8px; left: 8px;
  background: var(--green); color: #fff;
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 99px;
}
.won { color: var(--green); font-weight: 600; }

/* ---------- Livre terminé ---------- */
.celebrate { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.celebrate .cover-lg {
  width: 120px; aspect-ratio: 3 / 4; border-radius: var(--radius); overflow: hidden;
  background: var(--accent-soft); color: var(--muted); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
}
.celebrate .cover-lg img { width: 100%; height: 100%; object-fit: cover; }
.celebrate h2 { margin: 6px 0 0; font-size: 1.5rem; }
.celebrate-title { font-family: var(--serif); font-size: 1.1rem; margin: 2px 0; }
.celebrate .btn { margin-top: 12px; }

/* ---------- Carte à partager ---------- */
.card-preview {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  min-height: 200px; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.card-preview img { display: block; max-width: 100%; max-height: 62vh; margin: 0 auto; }

/* ---------- Galerie : comparateur avant / après ---------- */
.g-badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(20, 16, 10, 0.6); color: #fff;
  font-size: 0.68rem; padding: 2px 8px; border-radius: 99px;
}
.lightbox-img { border-radius: var(--radius); overflow: hidden; background: var(--bg); }
.lightbox-img img { width: 100%; max-height: 70vh; object-fit: contain; display: block; }
.compare {
  position: relative; width: min(100%, calc(72vh * 3 / 4)); margin: 0 auto; aspect-ratio: 3 / 4;
  border-radius: var(--radius); overflow: hidden; background: var(--bg);
  user-select: none; touch-action: pan-y;
}
.compare .c-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.compare .c-before { clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.compare .c-handle {
  position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-left: -1px;
  background: #fff; box-shadow: 0 0 6px rgba(0, 0, 0, 0.4); pointer-events: none;
}
.compare .c-handle span {
  position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}
.compare .c-label {
  position: absolute; bottom: 10px; pointer-events: none;
  background: rgba(20, 16, 10, 0.55); color: #fff; font-size: 0.72rem;
  padding: 2px 8px; border-radius: 99px;
}
.compare .c-label.left { left: 10px; }
.compare .c-label.right { right: 10px; }
.compare .c-range {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  opacity: 0; cursor: ew-resize; -webkit-appearance: none; appearance: none;
}

/* ---------- Fiche livre : couleur du livre, anneau ---------- */
.book-card-detail { border-left: 4px solid var(--book); background: color-mix(in srgb, var(--book) 6%, var(--card)); }
.book-progress { display: flex; align-items: center; gap: 14px; margin: 10px 0 4px; }
.ring { flex-shrink: 0; }
.ring circle:last-of-type { transition: stroke-dashoffset 0.6s ease; }

/* ---------- Grille : miniatures, animation de fin de page ---------- */
.page-cell.has-photo { background-size: cover; background-position: center; color: transparent; }
.page-cell.has-photo .num {
  position: absolute; left: 4px; bottom: 4px; color: #fff; font-size: 0.7rem;
  background: rgba(20, 16, 10, 0.6); padding: 0 5px; border-radius: 99px;
}
.page-cell.has-photo.done { border-color: var(--green); }
.page-cell .live {
  position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); animation: live 1.2s ease-in-out infinite;
}
@keyframes live { 50% { opacity: 0.3; } }
.page-cell.pop { animation: pop 0.7s ease-out; }
@keyframes pop {
  0% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 50%, transparent); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); box-shadow: 0 0 0 14px transparent; }
}
@media (prefers-reduced-motion: reduce) { .page-cell.pop, .page-cell .live { animation: none; } }

/* ---------- Chronomètre ---------- */
.timer-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.timer-clock { font-family: var(--serif); font-size: 1.5rem; font-variant-numeric: tabular-nums; min-width: 4.5em; }
.timer-clock.running { color: var(--accent); }
.now-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.now-card.running { border-color: var(--accent); }

/* ---------- Pastilles de feutres ---------- */
.swatch-list { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 4px;
  border: 1px solid var(--border); border-radius: 99px; font-size: 0.8rem; background: var(--card);
}
.swatch-chip i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.15); }
.swatch-chip b { cursor: pointer; color: var(--muted); font-weight: normal; margin-left: 2px; }
.swatch-chip.empty { opacity: 0.5; text-decoration: line-through; }
.picker .swatch-chip, .colors-analysis .swatch-chip { cursor: pointer; }
.swatch-chip[data-on] { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
#p-markers-panel { margin-top: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); }
#p-markers-panel input { margin-bottom: 10px; }
.picker { max-height: 220px; overflow-y: auto; }
.colors-analysis { display: flex; flex-direction: column; gap: 10px; }
.color-row { display: flex; align-items: center; gap: 10px; }
.big-swatch { width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0; border: 1px solid rgba(0, 0, 0, 0.12); }
.color-row .share { width: 3em; flex-shrink: 0; font-size: 0.8rem; }
.ambiance-preview img { max-width: 100%; max-height: 220px; border-radius: var(--radius); display: block; margin-bottom: 12px; }

/* ---------- Rubrique Palette ---------- */
.brand-title { font-family: var(--serif); font-size: 1rem; margin: 18px 0 8px; }
.marker-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.marker-tile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 0 0 8px; overflow: hidden; text-align: left; cursor: pointer; font-family: inherit;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--ink);
}
.marker-tile:hover { border-color: var(--muted); }
.tile-color { width: 100%; height: 46px; margin-bottom: 4px; }
.tile-code { font-weight: 600; font-size: 0.82rem; padding: 0 8px; }
.tile-name { font-size: 0.72rem; color: var(--muted); padding: 0 8px; line-height: 1.2; }
.tile-state {
  position: absolute; top: 4px; right: 4px; font-size: 0.62rem; padding: 1px 6px; border-radius: 99px;
  background: rgba(20, 16, 10, 0.6); color: #fff;
}
.marker-tile.state-empty { opacity: 0.55; }
.palette-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.palette-card { cursor: pointer; padding: 12px; }
.palette-card:hover { border-color: var(--muted); }
.palette-strip { display: flex; height: 30px; border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.palette-strip i { flex: 1; }
.color-input { width: 54px; height: 38px; padding: 2px; }
#mk-canvas { max-width: 100%; border-radius: var(--radius); cursor: crosshair; display: block; }

/* ---------- Calendrier d'activité ---------- */
.activity-wrap { overflow-x: auto; padding-bottom: 4px; }
.activity-months, .activity { display: grid; grid-template-columns: repeat(53, 12px); gap: 3px; width: max-content; }
.activity-months { font-size: 0.65rem; color: var(--muted); height: 14px; }
.activity-months span { white-space: nowrap; }
.activity { grid-template-rows: repeat(7, 12px); }
.activity i, .activity-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.l0 { background: var(--border); }
.l1 { background: color-mix(in srgb, var(--green) 30%, var(--card)); }
.l2 { background: color-mix(in srgb, var(--green) 55%, var(--card)); }
.l3 { background: color-mix(in srgb, var(--green) 80%, var(--card)); }
.l4 { background: var(--green); }
.activity-legend { display: flex; align-items: center; gap: 3px; font-size: 0.72rem; margin-top: 6px; }

/* ---------- Accueil ---------- */
.strokes { width: 220px; height: 120px; flex-shrink: 0; }
.strokes path { fill: none; stroke-width: 9; stroke-linecap: round; opacity: 0.55; }
.home-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 6px 0 4px;
}
.home-hero h1 { font-size: 2.2rem; margin: 2px 0 6px; }
.hero-date { color: var(--muted); font-size: 0.85rem; letter-spacing: 0.02em; }
.hero-line { margin: 0; font-family: var(--serif); font-size: 1.08rem; color: var(--ink); opacity: 0.85; }
@media (max-width: 640px) {
  .home-hero .strokes { width: 120px; height: 66px; align-self: flex-start; }
  .home-hero h1 { font-size: 1.8rem; }
}

.resume-card {
  --book: var(--accent);
  display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center;
  margin-top: 22px; padding: 18px 20px;
  border-left: 5px solid var(--book);
  background: linear-gradient(90deg, color-mix(in srgb, var(--book) 9%, var(--card)), var(--card) 60%);
}
.resume-card.running { box-shadow: 0 0 0 1px var(--book) inset; }
.resume-cover {
  width: 84px; aspect-ratio: 3 / 4; border-radius: 6px; overflow: hidden;
  background: var(--accent-soft); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(36, 33, 27, 0.18);
}
.resume-cover img { width: 100%; height: 100%; object-fit: cover; }
.eyebrow { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--book); font-weight: 600; }
.resume-title { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; line-height: 1.25; margin: 2px 0 2px; }
.resume-card .clock { font-variant-numeric: tabular-nums; color: var(--ink); }
@media (max-width: 560px) {
  .resume-card { grid-template-columns: auto 1fr; }
  .resume-ring { display: none; }
}

.recent-row { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 10px; -webkit-overflow-scrolling: touch; }
.recent-tile {
  flex-shrink: 0; width: 132px; text-decoration: none; color: var(--muted); font-size: 0.78rem;
  display: flex; flex-direction: column; gap: 5px;
}
.recent-tile img {
  width: 132px; height: 132px; object-fit: cover; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--card);
  transition: transform 0.15s ease;
}
.recent-tile:hover img { transform: translateY(-2px); }

.stat-tiles.compact { margin-top: 22px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.stat-tiles.compact .stat-tile { padding: 12px 14px; }
.stat-tiles.compact .v { font-size: 1.45rem; }

.home-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
@media (max-width: 760px) { .home-duo { grid-template-columns: 1fr; } }

/* ---------- Bienvenue (premier lancement, connexion) ---------- */
.welcome { max-width: 620px; margin: 4vh auto 0; text-align: left; }
.welcome .strokes { display: block; margin: 0 0 6px -8px; }
.welcome h1 { font-size: 2.1rem; margin: 0 0 8px; }
.welcome .lead { font-family: var(--serif); font-size: 1.12rem; color: var(--muted); margin: 0 0 26px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.steps li {
  display: grid; grid-template-columns: 38px 1fr; gap: 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
}
.steps .n {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-weight: 600; background: var(--accent-soft); color: var(--accent-ink);
}
.steps li:nth-child(2) .n { background: var(--green-soft); color: var(--green); }
.steps li:nth-child(3) .n { background: var(--amber-soft); color: var(--amber); }
.steps p { margin: 2px 0 10px; color: var(--muted); }
.steps li:last-child p { margin-bottom: 0; }
.small-note { margin-top: 18px; font-size: 0.88rem; }

.welcome.login { text-align: center; margin-top: 8vh; max-width: 440px; }
.welcome.login .strokes { margin: 0 auto -50px; width: 260px; height: 140px; }
.welcome.login .app-icon { border-radius: 20px; box-shadow: 0 10px 28px rgba(36, 33, 27, 0.2); position: relative; }
.welcome.login h1 { margin-top: 18px; }
.btn.big { padding: 13px 26px; font-size: 1rem; }
.token-alt { margin-top: 28px; text-align: left; }
.token-alt summary { cursor: pointer; text-align: center; }
body.logged-out .nav, body.logged-out .theme-pick { visibility: hidden; }
@media (max-width: 560px) { .resume-cover { width: 64px; } .resume-card { gap: 14px; padding: 14px 16px; } }

/* ---------- Packs de feutres ---------- */
.pack-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 0; border-top: 1px solid var(--border);
}
.pack-info { min-width: 0; flex: 1; }
.pack-swatches { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 7px; }
.pack-swatches i { width: 12px; height: 12px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
@media (max-width: 560px) { .pack-row { flex-direction: column; align-items: flex-start; } }
