/* Police Nunito hebergee par l'application (public/fonts, licence OFL) : aucune requete
   vers Google Fonts. Fichiers variables (toutes les graisses), latin et latin etendu. */
@font-face{
  font-family: "Nunito";
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url(fonts/nunito-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face{
  font-family: "Nunito";
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url(fonts/nunito-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  color-scheme: light dark;
  --bg: #fbf8f3;
  --surface: #ffffff;
  --surface-2: #f4efe8;
  --border: #ece5db;
  --text: #2b2521;
  --muted: #7b7068;
  --accent: #0f8b6d;
  --accent-2: #19b58c;
  --accent-contrast: #ffffff;
  --accent-soft: #daf3ea;
  --sun: #f2a818;
  --sun-soft: #fdf0d2;
  --coral: #f2644f;
  --coral-soft: #fde3de;
  --sky: #3d7fe6;
  --sky-soft: #e0ebfc;
  --grape: #8457e8;
  --grape-soft: #ece4fc;
  --rose: #e04a86;
  --rose-soft: #fce1ec;
  --ok: #2e7d4f;
  --ok-soft: #dcefe3;
  --warn: #a4611c;
  --warn-soft: #f6e7d4;
  --danger: #c62f26;
  --danger-soft: #fbe0de;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .04), 0 6px 18px -8px rgba(60, 40, 20, .14);
  --shadow-lg: 0 2px 4px rgba(60, 40, 20, .05), 0 16px 36px -12px rgba(60, 40, 20, .25);
  --glass: rgba(255, 255, 255, .78);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --surface: #211f1c;
    --surface-2: #2c2926;
    --border: #38332f;
    --text: #f1ebe4;
    --muted: #b1a69b;
    --accent: #4fd1a8;
    --accent-2: #7ee0c0;
    --accent-contrast: #0c211b;
    --accent-soft: #1e3a31;
    --sun: #f6c150;
    --sun-soft: #3a2f17;
    --coral: #ff8a78;
    --coral-soft: #3e2420;
    --sky: #7aa9f5;
    --sky-soft: #1d2b42;
    --grape: #ab8cf5;
    --grape-soft: #2c2345;
    --rose: #f27aa8;
    --rose-soft: #3d1f2c;
    --ok: #7cc79a;
    --ok-soft: #1f3327;
    --warn: #e0a868;
    --warn-soft: #3a2c1c;
    --danger: #f08b82;
    --danger-soft: #3d201e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 16px 36px -12px rgba(0, 0, 0, .6);
    --glass: rgba(33, 31, 28, .8);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* Taches de couleur douces en fond. */
  background-image:
    radial-gradient(900px 500px at 105% -10%, color-mix(in srgb, var(--sun) 16%, transparent), transparent 60%),
    radial-gradient(800px 500px at -10% 20%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 60%),
    radial-gradient(700px 500px at 60% 110%, color-mix(in srgb, var(--grape) 10%, transparent), transparent 60%);
  background-attachment: fixed;
}
a { color: var(--accent); }
h1 { font-size: 26px; font-weight: 800; margin: 0 0 4px; line-height: 1.2; letter-spacing: -.01em; }
h2 { font-size: 18px; font-weight: 800; margin: 24px 0 10px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- En-tete ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 16px; background: var(--glass); border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 17px; min-width: 0; margin-right: auto; }
.brand-logo { height: 32px; max-width: 96px; object-fit: contain; }
.brand.logo-only .brand-logo { height: 40px; max-width: 200px; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav a, .nav button {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px 7px 9px; border-radius: 999px; color: var(--muted); text-decoration: none;
  font: inherit; font-size: 14px; font-weight: 700; background: none; border: 0; cursor: pointer; transition: background .15s, color .15s;
}
/* Chaque page a sa couleur (--c : teinte, --cs : fond pastel), fixees par renderNav. */
.nav a { --c: var(--accent); --cs: var(--accent-soft); }
.nav a svg { color: var(--c); flex-shrink: 0; transition: transform .2s; }
.nav a:hover, .nav button:hover { background: var(--cs); color: var(--text); }
.nav a:hover svg { transform: scale(1.12) rotate(-6deg); }
.nav a.active { background: var(--cs); color: var(--text); font-weight: 800; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 35%, transparent); }
.scan-btn { order: 1; }
.install-btn { order: 1; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
/* Ecran moyen/petit : marque, Scanner et compte sur la 1re ligne, navigation dessous. */
@media (max-width: 1340px) {
  .nav { order: 3; margin: 0 -16px; padding: 0 16px; width: calc(100% + 32px); }
}
@media (max-width: 480px) {
  .scan-btn span, .account-btn .name { display: none; }
}

/* Bouton menu (hamburger) : visible uniquement sur petit ecran, ou les pages
   passent dans un panneau deroulant sous l'en-tete. */
.menu-btn { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; flex-shrink: 0; }
.menu-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 760px) {
  .topbar { flex-wrap: nowrap; gap: 8px; }
  .brand { flex: 1 1 auto; font-size: 15px; gap: 8px; }
  .brand-logo { height: 28px; max-width: 64px; }
  .scan-btn span, .install-btn span, .account-btn .name { display: none; }
  .menu-btn.has-links { display: inline-flex; order: -1; }
  .nav { display: none; }
  .nav.open {
    display: flex; flex-direction: column; gap: 2px; position: absolute; top: 100%; left: 0; right: 0; margin: 0; width: auto;
    padding: 8px 12px 12px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg);
    max-height: calc(100vh - 70px); overflow-y: auto;
  }
  .hide-mobile { display: none !important; }
  .btn-row.only-mobile { display: flex !important; }
  span.show-mobile { display: inline !important; }
  .nav.open a { padding: 11px 14px; font-size: 16px; border-radius: 14px; gap: 12px; }
  body.nav-open { overflow: hidden; }
}

/* ---------- Menu du compte (bascule entre bibliotheques) ---------- */
.account { position: relative; order: 2; }
.account-btn { display: inline-flex; align-items: center; gap: 6px; max-width: 200px; }
.account-btn .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-btn svg { flex-shrink: 0; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; width: min(300px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 6px; animation: pop .16s ease-out; transform-origin: top right; max-height: calc(100vh - 90px); overflow: auto;
}
.menu-head { padding: 8px 10px 6px; font-size: 13px; color: var(--muted); }
.menu-head strong { display: block; color: var(--text); font-size: 15px; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }
.menu-title { padding: 6px 10px 2px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 10px; border: 0; background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.menu-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item img { width: 22px; height: 22px; object-fit: contain; border-radius: 4px; flex-shrink: 0; }
.star { border: 0; background: none; cursor: pointer; font-size: 17px; line-height: 1; color: var(--muted); padding: 2px 4px; border-radius: 6px; }
.star.on { color: #d9a21b; }
.star:hover { background: var(--surface-2); }

/* ---------- Accueil (liste des bibliotheques) ---------- */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.lib-card { display: flex; align-items: center; gap: 14px; padding: 18px; text-decoration: none; color: inherit; }
.lib-card { transition: transform .15s, box-shadow .15s; }
.lib-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.lib-card img, .lib-card .ph { width: 48px; height: 48px; object-fit: contain; border-radius: 10px; flex-shrink: 0; }
.lib-card .ph { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: var(--accent-contrast); font-weight: 700; font-size: 20px; }
.lib-card strong { font-size: 16px; }

/* ---------- Selection des etiquettes ---------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; margin-bottom: 12px; }
.seg button { border: 0; background: none; padding: 8px 6px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.sel-list { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.sel-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.sel-row:last-child { border-bottom: 0; }
.sel-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-row button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px; }
.sel-row button:hover { color: var(--danger); }
.search-results { border: 1px solid var(--border); border-radius: 10px; margin-top: 6px; max-height: 280px; overflow: auto; }
.search-results .sel-row button.add { color: var(--accent); font-size: 13px; font-weight: 700; border: 1px solid var(--border); border-radius: 8px; padding: 3px 8px; }
.summary-line { font-weight: 700; margin: 10px 0 4px; }
.seg-3 { grid-template-columns: repeat(3, 1fr); }
.chips-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

/* ---------- Livres numeriques, statuts de lecture ---------- */
.badge-ebook { background: #e3e4fa; color: #3f46a8; }
@media (prefers-color-scheme: dark) { .badge-ebook { background: #26284a; color: #a9aefc; } }
.filters-2 { margin-top: -6px; }
.status-icons { display: flex; gap: 4px; flex-wrap: wrap; }
.st { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.st-to_read { background: var(--warn-soft); color: var(--warn); }
.st-read { background: var(--ok-soft); color: var(--ok); }
.st-reading { background: #dfe9fb; color: #2456a6; }
.st-abandoned { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
@media (prefers-color-scheme: dark) { .st-reading, .pill.pill-reading { background: #1d2c47; color: #9dbcf2; } }
.st-liked { background: #fbe0e6; color: #c2185b; }
.st-disliked { background: var(--surface-2); color: var(--muted); }
.status-editor { margin: 12px 0 4px; }
.status-editor .others { margin-top: 6px; color: var(--muted); }
/* Notes (etoiles) */
.star-input { gap: 0; }
.star-input .small { margin-right: 6px; }
.stars { color: #d9a21b; font-size: 13px; letter-spacing: 1px; white-space: nowrap; }
.stars-off { color: var(--border); }
.rating-avg { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.rating-avg strong { font-size: 28px; }
.rating-dist { display: flex; flex-direction: column; gap: 8px; }
.rating-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 28px; gap: 10px; align-items: center; }
.rating-row .stars { font-size: 15px; }
.rating-row .rank-bar { margin: 0; }
/* Lecteurs d'un livre (fiche) */
.readers-box { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 4px; }
.readers-box .chip { margin: 0; background: var(--grape-soft); color: var(--grape); }
.pill.pill-reader { background: var(--grape-soft); color: var(--grape); }
.pill { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.pill:hover { background: var(--surface-2); }
.pill.on { border-color: transparent; }
.pill.pill-to_read { background: var(--warn-soft); color: var(--warn); }
.pill.pill-read { background: var(--ok-soft); color: var(--ok); }
.pill.pill-reading { background: #dfe9fb; color: #2456a6; }
.pill.pill-abandoned { background: var(--text); color: var(--bg); }
.status-dates { margin-top: 8px; gap: 12px; }
.date-field { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; }
.date-field input { width: auto; min-height: 32px; padding: 4px 8px; font-size: 14px; }
.pill.pill-liked { background: #fbe0e6; color: #c2185b; }
.pill.pill-disliked { background: var(--text); color: var(--bg); }

/* ---------- Scan en serie ---------- */
.batch-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 800px) { .batch-layout { grid-template-columns: minmax(0, 1fr); } }
#batch-list .list { max-height: 460px; overflow: auto; }
.batch-item .thumb { width: 40px; height: 58px; }
.batch-item.flash { animation: flash 1.2s ease; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.qty { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.qty span { min-width: 20px; text-align: center; font-weight: 700; }
.qty button, .batch-item .rm { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: 16px; line-height: 1; }
.batch-item .rm { border: 0; color: var(--muted); font-size: 20px; }
.batch-item .rm:hover { color: var(--danger); }

/* ---------- Categories (reglages) ---------- */
.cat-group { border: 1px solid var(--border); border-radius: 10px; margin-top: 8px; }
.cat-group summary { cursor: pointer; padding: 10px 12px; list-style-position: inside; }
.cat-group .list { padding: 0 12px 4px; }
.cat-row input[type=checkbox] { flex-shrink: 0; }

.shell { max-width: 1100px; margin: 0 auto; padding: 20px 16px 64px; }

/* ---------- Boutons et champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none;
  min-height: 40px; transition: background .15s, box-shadow .15s, transform .1s, filter .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: linear-gradient(135deg, var(--accent-2), var(--accent)); border-color: transparent; color: var(--accent-contrast);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-2), var(--accent)); filter: brightness(1.06) saturate(1.1); box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--accent) 80%, transparent); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-small { padding: 5px 12px; min-height: 32px; font-size: 13px; border-radius: 10px; }
.btn-icon { gap: 6px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.only-mobile, .show-mobile { display: none !important; }
/* Liens d'invitation et role par bibliotheque (Administration > Comptes). */
.invite-form { display: flex; flex-wrap: wrap; gap: 8px; }
.invite-form select { flex: 1 1 130px; min-width: 0; width: auto; }
.sel-row .sel-role { width: auto; min-height: 32px; padding: 2px 8px; font-size: 13px; flex-shrink: 0; }
.scan-btn { background: linear-gradient(135deg, var(--sun), var(--coral)); border-color: transparent; color: #fff;
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--coral) 80%, transparent); }
.scan-btn:hover { background: linear-gradient(135deg, var(--sun), var(--coral)); filter: brightness(1.05); }

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; min-height: 40px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; padding: 0; accent-color: var(--accent); }
.field { margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 12px; }
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-reserved { background: var(--grape-soft); color: var(--grape); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; margin: 0 4px 4px 0; }
.chip-tag { background: var(--surface-2); color: var(--text); text-decoration: none; }
.chip-tag:hover { background: var(--accent-soft); color: var(--accent); }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 0 0 2px; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); font-weight: 600; }
/* Illustration : pile de livres coloree. */
.empty::before {
  content: ""; display: block; width: 88px; height: 88px; margin: 0 auto 14px; border-radius: 50%;
  background: var(--sun-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect x='14' y='18' width='9' height='30' rx='2' fill='%2319b58c'/%3E%3Crect x='25' y='13' width='9' height='35' rx='2' fill='%23f2644f'/%3E%3Crect x='37' y='19' width='8' height='29' rx='2' fill='%233d7fe6' transform='rotate(-12 41 33.5)'/%3E%3Crect x='11' y='48' width='42' height='3.5' rx='1.75' fill='%23f2a818'/%3E%3C/svg%3E") center / 60px no-repeat;
}
.error-box { background: var(--danger-soft); color: var(--danger); padding: 12px 14px; border-radius: 14px; margin-bottom: 12px; font-size: 14px; }
.info-box { background: var(--accent-soft); padding: 12px 14px; border-radius: 14px; margin-bottom: 12px; font-size: 14px; }

/* ---------- Catalogue ---------- */
/* Filtres : se repartissent sur la largeur et passent a la ligne selon la place. */
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.filter-check { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 600; white-space: nowrap; }
.filters > * { min-width: 0; }
.filters > .search { grid-column: span 2; }
.filters > .sort-row { grid-column: span 2; }
/* Recherche seule sur sa ligne, filtres en dessous (grand ecran). */
@media (min-width: 641px) { .filters-search-row > .search { grid-column: 1 / -1; } }
@media (max-width: 420px) { .filters > .search { grid-column: 1 / -1; } }
/* Recherche + bouton de scan ISBN */
.search-scan { display: flex; gap: 6px; min-width: 0; }
.search-scan > input { flex: 1; min-width: 0; }
.search-scan > .btn { flex: none; }
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
/* Smartphone : une colonne, couverture a gauche et texte a droite. */
@media (max-width: 599px) {
  .books { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .books .book-card { flex-direction: row; }
  .books .book-card .cover { width: 92px; flex: none; align-self: flex-start; }
  .books .book-card .meta { min-width: 0; padding: 10px 12px; }
  .books .book-card .cover-ribbon { top: 10px; right: -42px; font-size: 9px; padding: 2px 0; }
}
.book-card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease;
}
.book-card:hover { transform: translateY(-4px) rotate(-.4deg); box-shadow: var(--shadow-lg); }
.book-card .cover img { transition: transform .35s ease; }
.book-card:hover .cover img { transform: scale(1.05); }
.cover { aspect-ratio: 2 / 3; background: var(--surface-2); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover { position: relative; }
/* Bandeau en travers du coin haut droit de la couverture (ex. "Numerique"). */
.cover-ribbon {
  position: absolute; top: 18px; right: -34px; z-index: 1; width: 140px; transform: rotate(45deg); text-align: center;
  background: #3f46a8; color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 0; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); pointer-events: none;
}
.cover-fallback { padding: 12px; text-align: center; font-weight: 800; color: var(--muted); font-size: 14px; }
/* Couverture absente : degrade pastel. */
.cover:has(> .cover-fallback) { background: linear-gradient(160deg, var(--sky-soft), var(--grape-soft) 55%, var(--rose-soft)); }
.book-card .meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.book-card .t { font-weight: 700; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.book-card .a { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-card .badge { align-self: flex-start; margin-top: auto; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.book-card .badges { margin-top: auto; }
.book-card .badges .badge { margin-top: 0; }
.book-card .coll { font-size: 12px; color: var(--accent); font-weight: 600; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
/* Categories et tags sur la miniature. */
.card-terms { display: flex; flex-wrap: wrap; gap: 3px; margin: 2px 0; }
.card-terms .term { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-terms .term-tag { background: var(--surface-2); color: var(--muted); }
.card-terms .term-reader { background: var(--grape-soft); color: var(--grape); }
.grid-collection { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); gap: 0 14px; }
.more { text-align: center; margin-top: 18px; }

/* ---------- Fiche livre ---------- */
.book-detail { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; }
@media (max-width: 640px) { .book-detail { grid-template-columns: minmax(0, 1fr); } .book-detail .cover { max-width: 180px; } }
.book-detail .cover { border-radius: 14px; box-shadow: var(--shadow-lg); }
.subtitle { font-size: 16px; color: var(--muted); margin-bottom: 8px; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 14px 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.summary { white-space: pre-line; text-align: justify; hyphens: auto; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
@media (max-width: 640px) {
  table.stack thead { display: none; }
  table.stack tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { display: block; border: 0; padding: 2px 0; text-align: left !important; }
}
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; white-space: nowrap; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .thumb { width: 38px; height: 56px; border-radius: 4px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button { border-bottom-width: 3px; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.term-tabs { overflow-x: auto; scrollbar-width: none; }
.term-tabs button { flex-shrink: 0; }

/* ---------- Formulaire livre ---------- */
.cover-edit { display: flex; gap: 14px; align-items: flex-start; }
.cover-edit .cover { width: 120px; flex-shrink: 0; border-radius: 8px; }
/* Couverture cliquable (choisir ou photographier une image). */
.cover-pick { cursor: pointer; margin: 0; }
.cover-pick:hover > img, .cover-pick:hover > .cover-fallback { opacity: .8; }
.cover-pick-badge { position: absolute; right: 6px; bottom: 6px; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.isbn-row { display: flex; gap: 8px; }
.isbn-row input { flex: 1; min-width: 0; }
@media (max-width: 600px) {
  .isbn-row { flex-wrap: wrap; } .isbn-row input { flex-basis: 100%; }
  /* Boutons en icones : sur la meme ligne que le champ. */
  .isbn-row:has(> .btn > svg) { flex-wrap: nowrap; } .isbn-row:has(> .btn > svg) input { flex-basis: 0; }
  .isbn-row:has(> .btn > svg) > .btn { padding-left: 12px; padding-right: 12px; }
}
.edition-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 420px; overflow-y: auto; }
.edition-list li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); }
.edition-list li > div:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.edition-list .ed-cover { width: 38px; height: 54px; flex-shrink: 0; border-radius: 4px; overflow: hidden; background: var(--border); }
.edition-list .ed-cover img { width: 100%; height: 100%; object-fit: cover; }
.choice-summary { max-height: 9em; overflow-y: auto; white-space: pre-line; font-size: 14px; line-height: 1.45; margin-bottom: 4px; }

/* ---------- Scanner ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: fade .15s ease-out; }
.modal { animation: pop .18s ease-out; }
.modal { background: var(--surface); border-radius: 20px; width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; padding: 16px; }
.modal h2 { margin-top: 0; }
.modal.modal-wide { max-width: 760px; }
.cover-search-form { display: grid; grid-template-columns: 1fr 1.6fr 1.2fr auto; gap: 8px; }
@media (max-width: 640px) { .cover-search-form { grid-template-columns: 1fr 1fr; } .cover-search-form input[name="title"] { grid-column: 1 / -1; order: -1; } }
.cover-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; min-height: 40px; }
.cover-choice { display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 2px solid transparent; border-radius: 12px; background: var(--surface-2); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.cover-choice:hover, .cover-choice:focus-visible { border-color: var(--accent); outline: none; }
.cover-choice-img { aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden; background: var(--surface); display: flex; align-items: center; justify-content: center; }
.cover-choice-img img { width: 100%; height: 100%; object-fit: cover; }
.cover-choice-src { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .03em; }
.cover-choice-title { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.scanner-video { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; margin-bottom: 12px; }
.scanner-video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-video .frame { position: absolute; inset: 18% 12%; border: 3px solid rgba(255, 255, 255, .85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .25); }
.scanner-video.barcode .frame { inset: 32% 8%; }
.scanner-status { font-size: 13px; color: var(--muted); margin-bottom: 10px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toast-in .25s cubic-bezier(.2, 1.4, .4, 1); }
.toast.error { background: var(--danger); color: #fff; display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.toast-close { margin-left: auto; flex: none; background: none; border: 0; color: inherit; font-size: 20px; line-height: 1; padding: 0 2px; cursor: pointer; }

/* ---------- Etiquettes ---------- */
.label-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .label-layout { grid-template-columns: minmax(0, 1fr); } }
.sheets { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; overflow-x: auto; }
.sheet {
  width: 210mm; height: 297mm; position: relative; background: #fff; color: #000; overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15); zoom: .42; flex-shrink: 0;
}
@media (max-width: 500px) { .sheet { zoom: .38; } }
.lbl {
  position: absolute; display: flex; align-items: center; gap: 2.2mm; padding: 2mm 2.5mm; overflow: hidden;
  font-family: Arial, Helvetica, sans-serif; color: #000;
}
.sheet.show-guides .lbl { outline: 1px dashed #bbb; }
.lbl.blank { outline-color: #eee; }
.lbl .qr { flex-shrink: 0; }
.lbl .qr svg { width: 100%; height: 100%; display: block; }
/* --k : facteur d'echelle calcule d'apres la taille de l'etiquette (1 = 63,5×38 mm),
   pour que textes et logo grandissent avec l'etiquette comme le QR code. */
.lbl { --k: 1; --t: 1; } /* --t : taille du texte choisie (1 = 100 %) */
.lbl .info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: calc(.8mm * var(--k)); height: 100%; }
.lbl .lib { display: flex; flex-direction: column; align-items: flex-start; gap: calc(.6mm * var(--k)); font-size: calc(6.5pt * var(--k) * var(--t)); font-weight: 700; line-height: 1.1; }
.lbl .lib img { max-height: calc(8mm * var(--k)); max-width: 100%; object-fit: contain; object-position: left center; flex-shrink: 0; }
.lbl .lib span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lbl .ttl { font-size: calc(7pt * var(--k) * var(--t)); line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lbl .aut { font-size: calc(6.5pt * var(--k) * var(--t)); line-height: 1.15; font-style: italic; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lbl.small .aut { display: none; }
.lbl .cd { font-family: "Courier New", monospace; font-size: calc(10pt * var(--k) * var(--t)); font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.lbl.small .ttl { display: none; }
.pending-list { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 4px 10px; }
.pending-list .check { padding: 6px 0; border-bottom: 1px solid var(--border); }
.pending-list .check:last-child { border-bottom: 0; }

.snippet { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; background: var(--surface-2); padding: 10px 12px; border-radius: 8px; white-space: pre-wrap; word-break: break-all; }

/* Impression : seules les planches copiees dans #print-root (enfant direct de body) sortent. */
#print-root { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; margin: 0; padding: 0; }
  body > :not(#print-root) { display: none !important; }
  #print-root { display: block; }
  .sheet { zoom: 1 !important; box-shadow: none; page-break-after: always; break-after: page; }
  .sheet:last-child { page-break-after: auto; break-after: auto; }
  .sheet.show-guides .lbl { outline: none; }
}

/* ---------- Liste deroulante filtrante ---------- */
.combo { position: relative; flex: 1; min-width: 0; }
.combo > input { width: 100%; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; max-height: 290px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .16); padding: 4px;
}
.combo-item { display: flex; justify-content: space-between; gap: 10px; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.combo-item:hover, .combo-item.active { background: var(--accent-soft); color: var(--accent); }
.combo-hint { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.combo-empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }

/* ---------- Catalogue : filtres dans une colonne a gauche ---------- */
.catalog-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
.filters-side {
  position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 96px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
}
.filters-side .fgroup label { margin-bottom: 4px; }
.filters-side .fgroup > input, .filters-side .fgroup > select, .filters-side .combo { width: 100%; }
@media (max-width: 760px) {
  .catalog-layout { grid-template-columns: minmax(0, 1fr); }
  .filters-side { position: static; max-height: none; }
}

/* ---------- Reglages : sections en accordeon ---------- */
.settings-group { margin: 26px 0 0; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.settings-group + .settings-section { margin-top: 8px; }
.settings-section { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.settings-section > summary { cursor: pointer; padding: 14px 16px; font-weight: 700; font-size: 16px; list-style: none; display: flex; align-items: center; gap: 10px; }
.settings-section > summary::-webkit-details-marker { display: none; }
.settings-section > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.settings-section[open] > summary::before { transform: rotate(90deg); }
.settings-section > summary .sum-hint { font-weight: 400; font-size: 13px; color: var(--muted); }
.settings-section > .section-body { padding: 0 16px 16px; }
.settings-section > .section-body > .card { border: 0; box-shadow: none; padding: 0; background: none; }

/* Nombre de livres : sous les filtres (barre du haut ou colonne de gauche). */
.catalog-count { color: var(--muted); font-size: 14px; margin: -4px 0 12px; }
.filters-side .catalog-count { margin: 4px 0 0; padding-top: 10px; border-top: 1px solid var(--border); font-weight: 600; color: var(--text); }

/* ---------- Statistiques (tableau de bord) ---------- */
/* Palette categorielle validee (4 teintes, ordre fixe) : clair / sombre. */
:root { --cat-1: #2a78d6; --cat-2: #eb6834; --cat-3: #1baf7a; --cat-4: #eda100; --gold: #d9a21b; --silver: #9aa3ad; --bronze: #b87333; }
@media (prefers-color-scheme: dark) { :root { --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-4: #c98500; } }

.stats-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.period-seg { display: inline-grid; grid-template-columns: repeat(4, auto); margin: 0; }
.period-seg button { padding: 7px 12px; }
@media (max-width: 560px) { .period-seg { grid-template-columns: repeat(2, 1fr); width: 100%; } }
.stats-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; position: relative; z-index: 5; }
.stats-member-pick { flex: 1 1 220px; max-width: 320px; }
.stats-member-pick input { border-radius: 999px; }
.stats-member-pick input.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.stats-tabs button { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 6px 14px 6px 6px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; }
.stats-tabs button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.tab-avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 700; }
.stats-tabs button.active .tab-avatar { background: rgba(255, 255, 255, .25); color: inherit; }
#st-body { transition: opacity .15s; }
#st-body.loading { opacity: .45; }

/* En-tete : objectif + chiffres cles */
.hero { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr); gap: 14px; margin-bottom: 14px; }
@media (max-width: 860px) { .hero { grid-template-columns: minmax(0, 1fr); } }
.goal-card { display: flex; align-items: center; gap: 18px; padding: 16px; border-radius: 16px; color: var(--text);
  background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border: 1px solid var(--border); }
.goal-pct { font-size: 34px; font-weight: 800; line-height: 1; margin-bottom: 6px; }
.good { color: var(--ok); font-weight: 700; }
.late { color: var(--warn); font-weight: 700; }
.ring { flex-shrink: 0; }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 12; }
.ring-value { fill: none; stroke: var(--accent); stroke-width: 12; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.ring-center { font-size: 24px; font-weight: 800; fill: var(--text); }
.ring-sub { font-size: 11px; fill: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.kpis-wide { margin-bottom: 14px; grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .kpis-wide { grid-template-columns: repeat(2, 1fr); } }
.kpi { transition: transform .15s; }
.kpi:hover { transform: translateY(-2px); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-top { display: flex; justify-content: space-between; align-items: center; min-height: 34px; }
.kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); font-size: 17px; }
.spark { color: var(--accent); opacity: .9; }
.kpi-value { font-size: 28px; font-weight: 800; line-height: 1.1; margin-top: 8px; }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-hint { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Grille de panneaux */
.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
@media (max-width: 980px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
#st-body > .panel { margin-bottom: 14px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.panel.span-2 { grid-column: span 2; }
@media (max-width: 640px) { .panel.span-2 { grid-column: auto; } }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut { flex-shrink: 0; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; flex: 1; min-width: 150px; }
.donut-legend li { display: grid; grid-template-columns: 12px 1fr auto 42px; gap: 8px; align-items: center; }
.donut-legend i { width: 12px; height: 12px; border-radius: 4px; }
.donut-legend strong { text-align: right; }
.donut-legend .muted { text-align: right; font-size: 12px; }

/* Colonnes */
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-cur { background: var(--accent); }
.sw-prev { background: var(--border); }
.cols { display: flex; align-items: stretch; gap: 4px; height: 170px; padding-top: 10px; border-bottom: 1px solid var(--border); }
.col-slot { position: relative; flex: 1; display: flex; flex-direction: column; min-width: 0; outline: none; }
.col-pair { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.col { flex: 1; max-width: 22px; border-radius: 4px 4px 0 0; transition: filter .15s; }
.col.cur { background: var(--accent); }
.col.prev { background: var(--border); }
.col-label { font-size: 11px; color: var(--muted); text-align: center; padding-top: 4px; white-space: nowrap; overflow: hidden; }
.col-tip { display: none; position: absolute; bottom: calc(100% - 6px); left: 50%; transform: translateX(-50%); z-index: 5; white-space: nowrap;
  background: var(--text); color: var(--bg); font-size: 12px; padding: 5px 8px; border-radius: 8px; pointer-events: none; }
.col-tip .muted { color: inherit; opacity: .75; }
.col-slot:hover .col-tip, .col-slot:focus .col-tip { display: block; }
.col-slot:hover .col, .col-slot:focus .col { filter: brightness(1.15); }

/* Courbe */
.areachart { position: relative; }
.areachart svg { width: 100%; height: 190px; display: block; }
.axis { stroke: var(--border); stroke-width: 1; }
.axis-label { font-size: 11px; fill: var(--muted); }
.crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.areachart.hover .crosshair { opacity: 1; }
.area-dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); display: none; pointer-events: none; }
.area-tip { position: absolute; top: 0; transform: translateX(-50%); display: none; background: var(--text); color: var(--bg); font-size: 12px; padding: 5px 8px; border-radius: 8px; white-space: nowrap; pointer-events: none; }
.areachart.hover .area-dot, .areachart.hover .area-tip { display: block; }
.chart-table { margin-top: 8px; }
.chart-table table { font-size: 13px; }

/* Podium */
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 8px; margin-bottom: 10px; }
.podium-slot { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; min-width: 0; }
.podium-name { font-size: 13px; font-weight: 600; line-height: 1.25; max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.podium-count { font-size: 12px; color: var(--muted); }
.podium-step { width: 100%; border-radius: 10px 10px 0 0; display: flex; justify-content: center; padding-top: 6px; font-size: 20px; }
.place-1 .podium-step { height: 70px; background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 45%, transparent), var(--surface-2)); }
.place-2 .podium-step { height: 50px; background: linear-gradient(180deg, color-mix(in srgb, var(--silver) 45%, transparent), var(--surface-2)); }
.place-3 .podium-step { height: 36px; background: linear-gradient(180deg, color-mix(in srgb, var(--bronze) 45%, transparent), var(--surface-2)); }
.podium-avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; }
.place-1 .podium-avatar { width: 56px; height: 56px; font-size: 22px; box-shadow: 0 0 0 3px var(--gold); }
.mini-cover { display: inline-flex; align-items: center; justify-content: center; width: 44px; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; background: var(--surface-2); flex-shrink: 0; text-decoration: none; color: var(--muted); font-weight: 700; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); }
.mini-cover img { width: 100%; height: 100%; object-fit: cover; }
.mini-cover.podium-cover { width: 54px; }
.place-1 .mini-cover.podium-cover { width: 66px; box-shadow: 0 0 0 3px var(--gold), 0 4px 10px rgba(0, 0, 0, .2); }

/* Classements */
.rank { display: flex; flex-direction: column; gap: 8px; }
.rank-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 14px; }
.rank-pos { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.rank-main { min-width: 0; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 3px; }
.rank-bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.rank-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.rank-count { font-weight: 700; font-size: 13px; text-align: right; white-space: nowrap; }

/* Records, lectures en cours, bandeaux de couvertures */
.records { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.record { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.record-cover { width: 50px; }
.record-label { font-size: 12px; color: var(--muted); }
.record-title { font-weight: 700; display: block; line-height: 1.25; }
.record-value { font-size: 13px; font-weight: 600; color: var(--accent); }
.reading-now { display: flex; flex-direction: column; gap: 10px; }
.now-item { display: flex; gap: 12px; align-items: center; }
.now-info { flex: 1; min-width: 0; }
.now-info a { font-weight: 600; }
.now-bar { height: 6px; background: var(--surface-2); border-radius: 3px; margin: 5px 0; overflow: hidden; }
.now-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.now-bar.stale span { background: var(--warn); }
.cover-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.strip-item { width: 76px; flex-shrink: 0; }
.strip-item .mini-cover { width: 76px; }
.strip-title { font-size: 11px; line-height: 1.25; margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- Selection multiple (catalogue) ---------- */
.book-card .coll.coll-muted { color: var(--muted); font-weight: 500; }
.book-card { position: relative; }
.book-card.selectable { cursor: pointer; }
.book-card.selectable .cover { opacity: .85; }
.book-card.selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.book-card.selected .cover { opacity: 1; }
.select-check { position: absolute; top: 8px; left: 8px; z-index: 2; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0, 0, 0, .45); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.book-card.selected .select-check { background: var(--accent); }
.book-card.selected .select-check::after { content: ''; position: absolute; left: 7px; top: 3px; width: 7px; height: 12px;
  border: solid var(--accent-contrast); border-width: 0 3px 3px 0; transform: rotate(45deg); }
.select-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 30; display: flex; flex-wrap: wrap;
  align-items: center; gap: 8px; width: min(760px, calc(100% - 32px)); padding: 10px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
body.selecting .shell { padding-bottom: 110px; }
/* Appui long sur une couverture (selection) : pas de loupe / menu de l'image. */
.book-card { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.bulk-edit .bulk-row { display: grid; gap: 6px; padding: 10px 0; border-top: 1px solid var(--border); }
.bulk-edit .bulk-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.bulk-edit input:disabled { opacity: .5; }
.danger-zone { border-color: var(--danger); }

/* ---------- Fiches incompletes ---------- */
.pill-current { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.pill-current:hover { background: var(--accent); }
.pill-zero { opacity: .55; }
a.pill { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
span.thumb { display: block; }

/* ---------- Telephone : application installee, zones tactiles, filtres ---------- */
/* Encoches et barre gestuelle (application installee en plein ecran). */
.topbar { padding-top: max(10px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.shell { padding-bottom: calc(64px + env(safe-area-inset-bottom)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.toasts { bottom: calc(20px + env(safe-area-inset-bottom)); }
.select-bar { bottom: calc(16px + env(safe-area-inset-bottom)); }
/* Appli installee : pas de rebond ni de selection de texte accidentelle sur les boutons. */
html.standalone body { overscroll-behavior-y: none; }
.btn, .pill, .menu-item, .nav a { -webkit-tap-highlight-color: transparent; }
.btn, .pill, .menu-item, .nav a, .seg button, .tabs button { touch-action: manipulation; }

/* Ecran tactile : cibles d'au moins ~40 px. */
@media (pointer: coarse) {
  .btn-small { min-height: 38px; padding: 7px 12px; }
  .pill { padding: 8px 14px; }
  .menu-item { padding: 12px 10px; font-size: 15px; }
  .chip button { padding: 2px 2px 2px 6px; font-size: 18px; }
  .qty button, .batch-item .rm { width: 36px; height: 36px; }
  .sel-row { padding: 9px 10px; }
  .sel-row button { font-size: 22px; padding: 2px 8px; }
  .star { font-size: 20px; padding: 8px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  .check { min-height: 36px; }
}

/* Bouton "Filtres" du catalogue : seulement sur telephone. */
.filters-toggle { display: none; }
@media (max-width: 640px) {
  h1 { font-size: 20px; }
  .page-head { margin-bottom: 12px; }
  .page-head .btn-row { width: 100%; }
  .page-head .btn-row > .btn { flex: 1 1 auto; justify-content: center; }
  .filters { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .filters > *, .filters > .sort-row { grid-column: 1 / -1; }
  .filters > .search { grid-column: 1; }
  .filters > .filters-toggle { grid-column: 2; display: inline-flex; }
  .filters > .filters-toggle:first-child { grid-column: 1 / -1; }
  .filters:not(.open) > :not(.search):not(.filters-toggle) { display: none; }
  .filters-side > .filters-toggle { display: inline-flex; justify-content: center; }
  .filters-side:not(.open) > .fgroup:not(.fgroup-search) { display: none; }
  .card { padding: 14px; }
  .nav.open { max-height: calc(100dvh - 70px); }
  .toasts { width: calc(100% - 24px); }
  .select-bar { width: calc(100% - 16px); padding: 8px 10px; gap: 6px; }
  .select-bar strong { width: 100%; }
}

/* ---------- Animations, icones des titres et menus ---------- */
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#view > * { animation: rise .25s ease-out both; }
/* L'animation (transform) fait de chaque bloc un contexte d'empilement : le bloc qui a le
   focus (liste deroulante ouverte) doit passer devant les blocs suivants. */
#view > :focus-within { position: relative; z-index: 5; }
/* Pastille d'icone devant le titre de page (ajoutee par decorateTitle dans app.js). */
h1 .h-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-right: 12px; vertical-align: -9px;
  border-radius: 13px; background: var(--cs, var(--accent-soft)); color: var(--c, var(--accent)); transform: rotate(-4deg);
}
@media (max-width: 640px) { h1 .h-icon { width: 34px; height: 34px; border-radius: 11px; margin-right: 10px; vertical-align: -7px; } }
.menu-item svg { color: var(--muted); flex-shrink: 0; }
.menu-item:hover svg { color: var(--accent); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Aide contextuelle : icone "?" + info-bulle */
.hint {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 18px; height: 18px; margin: 0 4px; border-radius: 50%; vertical-align: middle;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  font-size: 11px; font-weight: 800; line-height: 1; cursor: help; user-select: none;
}
.hint:hover, .hint:focus-visible { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); outline: none; }
.hint-tip {
  position: absolute; z-index: 1000; max-width: min(300px, calc(100vw - 16px));
  padding: 8px 11px; border-radius: 10px; background: var(--text); color: var(--bg);
  font-size: 13px; font-weight: 500; line-height: 1.4; box-shadow: var(--shadow-lg); pointer-events: none;
}

/* Fichier epub et liseuse */
.ebook-file { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.reader { display: flex; flex-direction: column; gap: 10px; height: calc(100dvh - 150px); min-height: 360px; }
.reader-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.reader-title { font-weight: 700; flex: 1 1 200px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-bar select { max-width: 260px; }
.reader-area { flex: 1; min-height: 0; background: #fff; color: #222; border-radius: 12px; box-shadow: var(--shadow); padding: 12px 8px; overflow: hidden; }

/* Liseuses Kobo, import epub */
.seg-4 { grid-template-columns: repeat(4, 1fr); }
.warn-box { background: var(--warn-soft); color: var(--text); border-radius: 12px; padding: 10px 14px; margin: 0 0 14px; font-size: 14px; }
.kobo-card { display: flex; flex-direction: column; gap: 6px; }
.pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow: auto; margin-bottom: 12px; }
.pick-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 8px 10px; font: inherit; cursor: pointer; }
.pick-row:hover { background: var(--surface-2); }

/* Avancement (scan de la liseuse) */
.progress-modal { max-width: 420px; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 12px; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .2s; }
.progress.indeterminate span { width: 35%; animation: progress-slide 1.2s ease-in-out infinite; }
@keyframes progress-slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
@media (prefers-reduced-motion: reduce) { .progress.indeterminate span { animation: none; width: 100%; opacity: .5; } }

/* Prets : retard, pastille de l'en-tete, listes de choix avec couverture. */
.badge-late { background: var(--danger-soft); color: var(--danger); }
.nav-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.menu-btn { position: relative; }
.menu-btn.has-alert::after { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.pick-line { display: flex; align-items: center; gap: 10px; width: 100%; }
.pick-line .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pick-line .thumb { width: 32px; height: 46px; border-radius: 4px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }

/* Souhaits */
ul.list { list-style: none; margin: 0; padding: 0; }
.wish-owners { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.chip-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 36px; }
.chip-toggle .count { color: var(--muted); font-weight: 700; font-size: 12px; }
.chip-toggle[aria-pressed="true"] { background: var(--rose-soft); border-color: var(--rose); color: var(--text); }
.chip-toggle[aria-pressed="true"] .tab-avatar { background: var(--rose); color: #fff; }
.wish-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.wish-toolbar { margin-bottom: 12px; }
.wish-filter[aria-pressed="true"] { color: var(--rose); }
.wish-filter[aria-pressed="true"] svg { fill: currentColor; }
/* Coeur « Tres envie » : bouton (proprietaire) ou simple indication. */
.wish-heart { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; border: 0; background: none; color: var(--muted); padding: 0; }
button.wish-heart { cursor: pointer; }
button.wish-heart:hover { background: var(--rose-soft); color: var(--rose); }
.wish-heart[aria-pressed="true"], .wish-heart.on { color: var(--rose); }
.wish-heart[aria-pressed="true"] svg, .wish-heart.on svg { fill: currentColor; }
span.wish-heart:not(.on) { visibility: hidden; }
@media (prefers-reduced-motion: no-preference) { button.wish-heart:active svg { transform: scale(.85); } button.wish-heart svg { transition: transform .12s; } }
.wish-item { align-items: flex-start; flex-wrap: wrap; }
.wish-item .grow { display: flex; flex-direction: column; gap: 4px; }
.wish-notes { color: var(--text); font-style: italic; }
.wish-actions { justify-content: flex-end; }
.badge-wish { display: inline-flex; align-items: center; gap: 3px; background: var(--rose-soft); color: var(--rose); }
.wish-share { margin-top: 18px; }
.wish-share summary { cursor: pointer; display: flex; align-items: center; gap: 8px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px 14px; }
.kobo-convert-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow: auto; margin-top: 10px; }
.kobo-convert-list .check { font-weight: 400; align-items: flex-start; }
.kobo-convert-started { color: var(--warn); font-weight: 500; }
.kobo-convert-loss { display: none; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; }
.kobo-convert-read:has(input:checked) { background: var(--danger-soft); border-radius: 10px; padding: 6px 8px; }
.kobo-convert-read:has(input:checked) .kobo-convert-loss { display: inline-block; }
.kobo-convert-summary { color: var(--danger); font-weight: 600; font-size: 14px; margin: 12px 0 0; }
.kobo-convert-summary:empty { display: none; }
.wish-owner-pick { flex-wrap: nowrap; }
.wish-owner-pick .combo { flex: 1 1 240px; max-width: 360px; }
/* Au-dessus des blocs suivants (animation d'apparition = transform, donc empilement propre). */
.wish-owner-pick { position: relative; z-index: 5; }
.wish-export.only-mobile { margin-top: 12px; justify-content: flex-end; }
.wish-form-grid { display: grid; grid-template-columns: 110px 1fr; gap: 14px; align-items: start; }
.wish-form-grid .cover { width: 110px; }
.wish-cover-col { display: flex; flex-direction: column; gap: 8px; }
.wish-cover-col .btn-row { flex-wrap: nowrap; }
@media (max-width: 600px) {
  .wish-form-grid { grid-template-columns: 1fr; }
  .wish-form-grid .cover { width: 90px; }
  .wish-cover-col { flex-direction: row; align-items: flex-end; }
  .wish-actions { width: 100%; justify-content: flex-start; }
}

/* Rappels de retour */
.remind-group { padding: 4px 0 10px; border-bottom: 1px solid var(--border); }
.remind-group:last-child { border-bottom: 0; }
.remind-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding-top: 8px; }
.remind-head h3 { margin: 0; font-size: 16px; }
.remind-head .grow { flex: 1; }
.loan-actions { flex-shrink: 0; }
.btn svg { flex-shrink: 0; }
.error-text { color: var(--danger); }

/* Accessibilite */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: 10px; background: var(--accent); color: var(--accent-contrast); font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 12px; }
fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.plain > legend { padding: 0; margin-bottom: 6px; font-weight: 700; font-size: 14px; }
/* Focus clavier toujours visible (souris : pas de contour). */
:where(a, button, summary, [tabindex], .pick-row, .chip-toggle, .star):focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.btn:focus-visible { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
#view:focus { outline: none; }
@media (forced-colors: active) {
  .badge, .chip-toggle[aria-pressed="true"], .tabs button.active { border: 1px solid CanvasText; }
  .nav-badge { forced-color-adjust: none; }
}

/* Accueil personnalise (#/home) : cartes en grand ecran, tuiles sur smartphone. */
.home { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.home-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.home-hello { flex: 1 1 240px; min-width: 0; }
.home-hello h1 { margin: 0; }
.home-hello p { margin: 2px 0 0; }
.home .h-icon, .home-order .h-icon { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 10px; flex-shrink: 0; background: var(--cs, var(--accent-soft)); color: var(--c, var(--accent)); }
.home h1 .h-icon { width: 40px; height: 40px; border-radius: 13px; }
/* Cartes toutes de meme largeur : deux colonnes egales (une seule en dessous de 860 px),
   meme hauteur sur une rangee. */
.home-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
@media (max-width: 860px) { .home-cards { grid-template-columns: minmax(0, 1fr); } }
.home-card { min-width: 0; }
.home-cards > .card + .card { margin-top: 0; } /* la grille gere l'espacement (sinon cartes decalees) */
.home-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.home-card-head h2 { margin: 0; font-size: 17px; flex: 1; min-width: 0; }
.link-btn { border: 0; background: none; padding: 4px 6px; color: var(--accent); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; border-radius: 8px; }
.link-btn:hover { text-decoration: underline; }
/* Rangee de livres : une seule ligne, les suivantes masquees (jamais de defilement). */
.home-shelf { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); grid-template-rows: auto; grid-auto-rows: 0; column-gap: 14px; row-gap: 0; overflow: hidden; }
.home-shelf > li { min-width: 0; min-height: 0; overflow: hidden; }
.home-book { display: flex; flex-direction: column; gap: 4px; color: var(--text); text-decoration: none; padding-bottom: 2px; }
.home-book .cover { border-radius: 8px; box-shadow: var(--shadow); }
.home-book .t { font-size: 13px; font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.home-book .a { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Progression d'une lecture en cours : barre et pourcentage ecrit. */
.home-progress { display: flex; align-items: center; gap: 8px; }
.home-progress strong { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.home-book .bar { display: block; flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.home-book .bar span { display: block; height: 100%; background: var(--sky); border-radius: inherit; }
.home-todo { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.home-todo-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; border-radius: 14px; border: 1px solid transparent; background: var(--cs); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.home-todo-item:hover { border-color: var(--c); }
.home-todo-item .n { font-size: 24px; font-weight: 800; line-height: 1.1; color: var(--c); font-variant-numeric: tabular-nums; }
.home-todo-item .l { font-size: 13px; font-weight: 700; }
.home-goal { display: flex; align-items: center; gap: 14px; }
.home-goal p { margin: 0; }
.home-goal .ring circle { fill: none; stroke-width: 10; }
.home-goal .ring .track { stroke: var(--surface-2); }
.home-goal .ring .val { stroke: var(--grape); stroke-linecap: round; }
.home-goal .ring text { fill: var(--text); font-weight: 800; font-size: 20px; font-family: inherit; }
.good { color: var(--ok); font-weight: 700; }
.bad { color: var(--danger); font-weight: 700; }
.home-tiles { display: none; }
.home-book .badge { align-self: flex-start; }
.home-stars { display: inline-flex; flex-shrink: 0; }
.home-stars:hover .star { color: #d9a21b; }
.home-stars .star:hover ~ .star { color: var(--muted); }
.home-idea { display: flex; gap: 14px; align-items: flex-start; }
.home-idea-cover { flex: 0 0 96px; }
.home-idea-cover .cover { border-radius: 8px; box-shadow: var(--shadow); }
.home-idea p { margin: 4px 0; }
.home-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.home-kpi { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); }
.home-kpi .n { font-size: 24px; font-weight: 800; line-height: 1.1; color: var(--sky); font-variant-numeric: tabular-nums; }
.home-kpi .l { font-size: 13px; font-weight: 700; }
.home-order { list-style: none; margin: 0; padding: 0; }
.home-order-row { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.home-order-row:last-child { border-bottom: 0; }
.home-order-row .grow { flex: 1; min-width: 0; }

/* Smartphone (et telephone a l'horizontale) : tuiles dans la hauteur de l'ecran. */
@media (max-width: 599px), (max-height: 520px) and (orientation: landscape) and (pointer: coarse) {
  html:has(body.home-fit), body.home-fit { overflow: hidden; overscroll-behavior: none; }
  body.home-fit .shell { padding-top: 12px; padding-bottom: 0; }
  .home { gap: 10px; }
  .home-head { gap: 8px; align-items: center; }
  .home-hello { flex-basis: 100%; }
  .home-hello h1 { font-size: 20px; }
  .home h1 .h-icon { width: 30px; height: 30px; border-radius: 10px; }
  .home-hello p { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hide-phone { display: none !important; }
  .home-cards { display: none; }
  .home-tiles { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows, 4), minmax(0, 1fr)); gap: 8px; min-height: 0; overflow: hidden; }
  .home-tile { display: flex; flex-direction: column; align-items: stretch; gap: 2px; min-width: 0; min-height: 0; overflow: hidden; padding: 8px 10px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; box-shadow: var(--shadow); }
  .home-tile[hidden] { display: none; }
  .home-tile.home-more { align-items: center; justify-content: center; box-shadow: none; background: none; color: var(--accent); }
  .home-tiles.compact .home-tile.home-more { display: flex; }
  .home-tile .tile-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
  .home-tile .h-icon { width: 24px; height: 24px; border-radius: 8px; }
  .home-tile .tile-label { font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .home-tile .tile-value { font-size: 22px; font-weight: 800; line-height: 1.15; color: var(--c); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .home-tile .tile-value small { font-size: 12px; font-weight: 700; color: var(--muted); }
  .home-tile .tile-lines { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; font-size: 12px; color: var(--muted); line-height: 1.35; }
  .home-tile .tile-lines span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
  .home-tiles.compact .home-tile { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); column-gap: 6px; row-gap: 4px; align-content: start; }
  .home-tiles.compact .tile-head { grid-column: 1; }
  .home-tiles.compact .tile-value { grid-column: 2; font-size: 18px; align-self: center; }
  .home-tiles.compact .tile-value small { display: none; }
  .home-tiles.compact .tile-lines { grid-column: 1 / -1; }
}
@media (max-height: 520px) and (orientation: landscape) and (pointer: coarse) {
  .home-hello { flex-basis: auto; }
  .home-hello p { display: none; }
}

/* Objectifs de l'annee : une ligne par objectif (Statistiques, carte de l'accueil). */
.goal-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.goals-panel .goal-list { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; }
.goal-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 4px; }
.goal-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.goal-bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.goal-row.goal-ok .goal-bar span { background: var(--ok); }
.goal-row.goal-ok .goal-head span { color: var(--ok); font-weight: 700; }
.goal-row.goal-late .goal-bar span { background: var(--warn); }
.goal-row.goal-over .goal-bar span { background: var(--danger); }
.goals-panel { margin-bottom: 16px; }

/* Choix de plusieurs comptes (memberPicker) : pastilles puis champ de recherche. */
.member-picker .member-chips { display: flex; flex-wrap: wrap; align-items: center; min-height: 28px; margin-bottom: 4px; }
.member-picker .chip-reader { background: var(--grape-soft); color: var(--grape); }
.member-picker .combo { max-width: 360px; }

/* Resultats d'un import epub : action Verifier, lignes deja verifiees attenuees. */
.hist-action { white-space: nowrap; text-align: right; }
.hist-checked td:first-child, .hist-checked td:nth-child(2) { opacity: .6; }

/* Tri du catalogue : liste + bouton de sens. */
.sort-row { display: flex; gap: 6px; align-items: center; min-width: 0; }
.sort-row select { flex: 1; min-width: 0; }
.sort-dir { white-space: nowrap; flex-shrink: 0; }
/* Statistiques : chiffres qui ouvrent la liste des livres */
.kpi-link, .legend-link { cursor: pointer; }
.kpi-link:focus-visible, .legend-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.legend-link:hover span:first-of-type { text-decoration: underline; }
.stats-book-list .list-item { color: inherit; text-decoration: none; align-items: center; }
.stats-book-list .list-item:hover strong { text-decoration: underline; }

/* ---------- Catalogue : boutons flottants et vue liste ---------- */
/* Ajouter / Selectionner en icones : toujours sur smartphone, sinon une fois l'en-tete
   sorti de l'ecran (classe fab-scrolled). Masques pendant une selection. */
.fab-stack { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 25;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  opacity: 0; transform: translateY(14px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.fab-stack.fab-scrolled { opacity: 1; transform: none; pointer-events: auto; }
.fab { width: 56px; height: 56px; border-radius: 50%; border: 0; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-contrast); box-shadow: 0 8px 22px rgba(0, 0, 0, .28); cursor: pointer; text-decoration: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.fab:hover { filter: brightness(1.06); }
.fab.fab-secondary { width: 46px; height: 46px; background: var(--surface); color: var(--text); border: 1px solid var(--border); }
body.selecting .fab-stack { display: none; }
@media (max-width: 760px) { .fab-stack { opacity: 1; transform: none; pointer-events: auto; } }
@media (max-width: 760px) { .shell:has(.books) { padding-bottom: calc(150px + env(safe-area-inset-bottom)); } }

/* Vue liste au choix (au moins 600 px de large ; en dessous, cartes) : tableau, un
   livre par ligne. Colonnes : --cols (grand ecran) et --cols-narrow (sans les colonnes
   .col-wide, l'auteur passe sous le titre). */
.view-toggle { display: none; }
@media (min-width: 600px) {
  .view-toggle { display: inline-flex; padding-left: 10px; padding-right: 10px; flex: none !important; }
  .books.books-table { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: clip; }
  .books-table .list-head, .books-table .book-row { display: grid; grid-template-columns: var(--cols); gap: 0 12px; align-items: center; padding: 6px 12px; }
  .books-table .list-head { background: var(--surface-2); padding-top: 9px; padding-bottom: 9px; font-size: 11px; font-weight: 800;
    letter-spacing: .06em; text-transform: uppercase; color: var(--muted); position: sticky; top: 0; z-index: 3; }
  .books-table .list-head button { all: unset; cursor: pointer; white-space: nowrap; }
  /* Trop de colonnes pour la largeur : defilement horizontal (en-tete alors non collant). */
  .books.books-table.scroll-x { overflow-x: auto; }
  .books-table.scroll-x .list-head, .books-table.scroll-x .book-row { min-width: var(--min-w); }
  .books-table .list-head button:hover, .books-table .list-head button.sorted { color: var(--accent); }
  .books-table .list-head button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
  .books-table .book-card.book-row { border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none; background: transparent;
    transform: none; color: inherit; text-decoration: none; font-size: 14px; }
  .books-table .book-row:hover { background: var(--accent-soft); transform: none; box-shadow: none; }
  .books-table .book-row.selected { outline: 0; background: var(--accent-soft); }
  .books-table .cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; display: flex; flex-direction: column; gap: 1px; }
  .books-table .cell-title .t { font-weight: 800; font-size: 14px; -webkit-line-clamp: 2; }
  .books-table .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .books-table .cell-categories .sub, .books-table .cell-tags .sub, .books-table .cell-readers .sub { white-space: normal; }
  .books-table .narrow-only { display: none; }
  .books-table .cell-cover .cover { width: 30px; border-radius: 4px; }
  .books-table .cell-cover .cover img:hover, .books-table .book-row:hover .cover img { transform: none; }
  .books-table .cell-cover .cover-fallback { font-size: 0; }
  .books-table .cell .badge { align-self: flex-start; margin: 0; }
  .books-table .cell-availability { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .books-table .status-icons { margin: 0; }
  .books-table .select-check { position: relative; top: auto; left: auto; width: 22px; height: 22px; flex: none;
    background: var(--surface); border-color: var(--muted); box-shadow: none; }
  .books-table .book-row.selected .select-check { background: var(--accent); border-color: var(--accent); }
  .books-table .book-row.selected .select-check::after { left: 5px; top: 1px; width: 6px; height: 11px; }
}
@media (min-width: 600px) and (max-width: 899px) {
  .books-table .list-head, .books-table .book-row { grid-template-columns: var(--cols-narrow); }
  .books-table .col-wide { display: none; }
  .books-table .narrow-only { display: block; }
}

/* Surlignages et notes Kobo (fiche d'un livre). */
.kobo-notes { display: grid; gap: 14px; }
.kobo-note + .kobo-note { border-top: 1px solid var(--border); padding-top: 14px; }
.kobo-note blockquote { margin: 0 0 6px; padding: 2px 0 2px 12px; border-left: 3px solid var(--sun, #e0a800); font-style: italic; white-space: pre-wrap; }
.kobo-note-text { margin: 0 0 6px; white-space: pre-wrap; }

/* Etiquette de tranche : code seul, ecrit verticalement et centre. */
.lbl.spine { display: flex; align-items: center; justify-content: center; padding: 0; overflow: hidden; }
.lbl.spine .spine-code { writing-mode: vertical-rl; font-family: "Courier New", monospace; font-weight: 700; line-height: 1; white-space: nowrap; letter-spacing: .02em; }
.lbl.spine .spine-code.up { transform: rotate(180deg); }
.lbl.spine .spine-code.stack { text-orientation: upright; letter-spacing: 0; }

/* Page d'une liseuse : lignes selectionnees. */
tr.row-selected td { background: var(--accent-soft); }

/* ---------- E-mails ---------- */
.mail-preview { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 14em; overflow-y: auto; font: inherit; font-size: 13px; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }

/* Bandeau hors connexion */
.offline-bar { background: #8a5a00; color: #fff; text-align: center; font-size: 13px; padding: 6px 12px; }
.offline-bar[hidden] { display: none; }
.cam-tools { align-items: center; gap: 12px; margin-bottom: 10px; }
.cam-zoom { display: flex; align-items: center; gap: 8px; flex: 1; }
.cam-zoom input { flex: 1; min-width: 0; }
.cam-tools [aria-pressed="true"] { background: var(--accent, #2563eb); color: #fff; }
.cam-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; width: 100%; }
.cam-panel[hidden] { display: none; }
