/* Petit refuge illustré. Le décor est local ; les livres restent de vrais éléments HTML. */
:root {
  --paper: #fbf4e7;
  --ink: #302839;
  --muted: #7e6c66;
  --purple: #806087;
  --deep: #61466b;
  --lavender: #e8dce9;
  --rose: #f3d5d0;
  --line: #d9c5b0;
  --mint: #e3e8d7;
  --butter: #f5e3b8;
  --peach: #f3dace;
  --sky: #dfe7ec;
  --serif: 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  --hand: 'Segoe Print', 'Bradley Hand', 'Comic Sans MS', cursive;
  /* Le papier du décor commence à 6 % et finit à 93,5 % de sa hauteur. */
  --paper-scroll-top: calc(6dvh + 1cm);
  --paper-scroll-bottom: calc(6.5dvh + 1cm);
}
body {
  background: #f6ecd9 url('/refuge-bg.png') center top / 100% 100dvh no-repeat fixed;
  color: var(--ink);
  height: 100dvh;
  overflow: hidden;
}
.app-shell {
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 30px;
  width: 76%;
  max-width: 1460px;
  height: calc(100dvh - var(--paper-scroll-top) - var(--paper-scroll-bottom));
  min-height: 0;
  margin: var(--paper-scroll-top) 14% 0 10%;
  padding: 0;
  align-items: start;
}
/* Le marque-page et ses onglets restent à gauche. */
.sidebar {
  position: relative;
  top: 0;
  height: auto;
  min-height: 0;
  padding: 21px 12px 20px;
  border: 1px solid #d5bea76b;
  border-radius: 5px 10px 15px 5px;
  background: linear-gradient(105deg, #fff6e9ed, #f5e5ceeb);
  box-shadow: 3px 5px 15px #684a2b16;
}
.sidebar::after { content: none; }
.brand {
  display: flex;
  gap: 4px;
  padding: 0 0 0 3px;
  color: #292238;
  font: 43px/.84 var(--serif);
  letter-spacing: -2.6px;
  align-items: flex-end;
}
.brand-mark {
  order: 2;
  width: 31px;
  height: 38px;
  flex-shrink: 0;
  color: #7b6e69;
  margin: 0 0 1px -3px;
}
.brand-mark > .icon { width: 32px; height: 32px; stroke-width: 1; }
.brand-mark > span, .brand-dot { display: none; }
.brand-tagline {
  font: 8px/1.9 var(--sans);
  letter-spacing: 2.2px;
  color: #8a7369;
  padding: 18px 4px 0;
  text-align: center;
}
.sidebar-caption { margin: 27px 9px 12px; font-size: 8px; letter-spacing: 1.7px; color: #88735f; }
.shelf-nav { gap: 9px; }
.shelf {
  padding: 11px 10px;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 5px 8px 4px 7px;
  min-height: 43px;
  background: #e8dfeb9c;
  color: #665270;
  transition: transform .18s, box-shadow .18s;
}
.shelf > span:nth-child(2) { font: 13px/1.25 var(--serif); }
.shelf .icon { width: 18px; height: 18px; }
.shelf[data-shelf=reading] { background: #e1e8d9c9; color: #5a7054; }
.shelf[data-shelf=to_read] { background: #f2dbd0c7; color: #97624f; }
.shelf[data-shelf=read] { background: #f2d6d0b8; color: #a85d66; }
.shelf[data-shelf=wishlist] { background: #f5e1b2bd; color: #9c772c; }
.shelf[data-shelf=paused] { background: #dfe6e9bc; color: #617b84; }
.shelf[data-shelf=abandoned] { background: #e9e0d5bd; color: #8b7566; }
.shelf:hover { transform: translateX(2px); box-shadow: 1px 2px 5px #72533315; }
.shelf.active {
  border-color: #a18aaf8c;
  box-shadow: 2px 3px 0 #bba3bd38;
  transform: rotate(-1deg);
  color: #52345e;
  font-weight: 600;
}
.shelf-count { font-size: 10px; }
.shelf.active .shelf-count { background: #fff9efaa; border-radius: 50%; padding: 2px 5px; }
.sidebar-note {
  align-self: center;
  min-width: 0;
  width: 140px;
  margin: 31px 0 0;
  padding: 24px 13px 16px;
  background: #fdf1da;
  border: 1px solid #e3c9a9;
  box-shadow: 2px 4px 8px #77552d18;
  transform: rotate(-4deg);
}
.sidebar-note p { font: 14px/1.7 var(--hand); color: #795f4e; }
.note-spark { display: none; }
.note-heart { color: #9c7864; font-size: 25px; }
.tape { left: 39px; width: 58px; height: 18px; background: #dec9a778; }
.sidebar-bottom { margin-top: 25px; padding: 0 3px; font-size: 9px; color: #7c695b; gap: 5px; }
.sidebar-bottom .text-button { margin: 5px 0 0; width: 100%; text-align: left; color: #786080; }
.main-content {
  width: 100%;
  max-width: none;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: #cfb9a3 transparent;
  margin: 0;
  padding: 22px 0 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
.main-content::before, .main-content::after { content: none; }
.library-intro { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin-bottom: 25px; }
.hero { display: block; min-height: 0; padding: 0; flex-shrink: 0; }
.hero-copy::before { content: none; }
.eyebrow { color: #96806d; font-size: 8px; letter-spacing: 2.1px; }
.hero h1 {
  margin: 9px 0 0;
  font: 39px/1.15 var(--serif);
  letter-spacing: -1.5px;
  color: #302438;
  white-space: nowrap;
}
.title-leaf { width: 32px; height: 39px; vertical-align: middle; color: #89927a; stroke-width: 1; transform: rotate(-17deg); }
.hero-description { font: italic 13px/1.6 var(--serif); margin-top: 9px; color: #8a7462; }
.topbar { min-height: 0; padding: 0; border: 0; gap: 12px; flex: 1; justify-content: flex-end; min-width: 0; }
.library-search {
  flex: 1;
  max-width: 310px;
  min-width: 100px;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid #bea695;
  border-radius: 25px;
  background: #fffaf0b8;
  color: #9b8377;
}
.library-search input { width: 100%; min-width: 0; min-height: 41px; font: 12px var(--serif); color: #69554e; }
.library-search input::placeholder { color: #9a857b; }
.library-search:focus-within {
  border-color: var(--purple);
  box-shadow: 0 0 0 2px #80608755;
}
.library-search input:focus-visible { outline: none; }
.button { font-size: 11px; }
.button-primary { background: #806087; border: 1px solid #84678c; border-radius: 24px; box-shadow: 1px 3px 4px #68476d24; }
.button-primary:hover { background: #6b4c75; }
.button-outline { background: #fff8eacf; border: 1px solid #d5bda8; color: #7d665a; box-shadow: none; }
.mobile-settings { display: none; }
/* En-tête compact : la collection occupe la place centrale. */
.library { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 14px; align-items: center; }
.section-heading { margin-bottom: 24px; border: 0; padding: 0; gap: 10px; }
.section-title-row { gap: 8px; }
.section-title-row h2 { font: 21px var(--serif); color: #73604e; letter-spacing: -.4px; }
.book-total { border-radius: 50%; background: #e9dfce; color: #8d725b; font-size: 10px; min-width: 23px; padding: 3px 6px; }
.section-handwriting { display: none; }
.library-toolbar { margin-bottom: 24px; gap: 13px; }
.status-legend { display: none; }
.filter-button { min-height: 32px; padding: 5px 10px; border-radius: 18px; font-size: 10px; }
.sort-control { margin-left: 0; color: #8d7967; font-size: 10px; gap: 3px; }
.sort-control select { background: none; border: 0; border-radius: 0; color: #756151; font-size: 10px; padding: 5px 19px 5px 4px; min-height: 32px; max-width: 160px; }
.filters, .book-grid, .empty-state { grid-column: 1 / -1; }
.filters { background: #f4ead9ea; border: 1px solid #d8c3a7; border-radius: 7px; padding: 19px; }
.filters label { color: #7d6957; font-size: 11px; }
.filters select { background: #fffaf1; border-color: #d9c3ac; }
.book-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 33px 22px; align-items: start; }
.book-grid .book-card {
  min-width: 0;
  position: relative;
  padding: 12px 10px 13px;
  border: 0;
  border-radius: 12px 9px 15px 7px;
  background: linear-gradient(130deg, #edcebb4f, #f6e8d128 53%, #f2dac900);
  box-shadow: none;
  transform: rotate(-.5deg);
  transition: transform .2s, background .2s;
}
.book-grid .book-card:nth-child(4n+2) { background: linear-gradient(130deg, #ded4e44f, #f0e7e52e 50%, #e5dcdd00); transform: rotate(.5deg); }
.book-grid .book-card:nth-child(4n+3) { background: linear-gradient(130deg, #e3dbc94f, #f2ead72e 50%, #e5dcdd00); transform: rotate(-.4deg); }
.book-grid .book-card:nth-child(4n) { background: linear-gradient(130deg, #e8c8bf4f, #f5e1d92e 50%, #e5dcdd00); transform: rotate(.4deg); }
.book-card::before { content: none; }
.book-grid .book-card:hover { transform: translateY(-4px) rotate(0); background-color: #fff8e84d; }
.book-open { position: relative; }
.book-grid .book-card .cover-wrap { background: none; border: 0; padding: 0; border-radius: 2px 4px 4px 2px; }
.book-grid .book-open:hover .cover-wrap { transform: none; box-shadow: none; }
.cover-image { border-radius: 2px 4px 4px 2px; filter: drop-shadow(2px 4px 3px #59412635); }
.cover-image-frame { display: flex; align-items: center; justify-content: center; aspect-ratio: 2/3; width: 100%; }
.cover-image-frame > .cover-image { width: 100%; height: 100%; object-fit: contain; }
.cover-trim-window { display: block; position: relative; overflow: hidden; flex-shrink: 0; }
.cover-image-frame.is-trimmed .cover-image { position: absolute; max-width: none; aspect-ratio: auto; object-fit: fill; border-radius: 0; }
.cover-status { right: 9px; width: 18px; height: 25px; background: #a58ab0; opacity: .92; }
.cover-status .icon { width: 10px; height: 10px; }
.book-grid .book-info { padding: 10px 0 0; margin: 0; background: none; border-radius: 0; box-shadow: none; }
.book-title { font: 17px/1.22 var(--serif); color: #352c2b; letter-spacing: -.3px; min-height: 2.44em; }
.book-author { font: 12px/1.4 var(--serif); color: #7a685c; margin-top: 2px; }
.card-bottom { display: flex; flex-direction: column; align-items: stretch; gap: 10px; margin-top: 10px; }
.status-text { display: flex; justify-content: center; gap: 6px; padding: 6px 7px; border-radius: 20px; background: #e8dceb; color: #71517e; font: 11px/1.25 var(--serif); min-height: 27px; }
.status-text .icon { width: 13px; height: 13px; }
.book-card[data-status=reading] .status-text { background: #e4e8d3; color: #5f7451; }
.book-card[data-status=to_read] .status-text { background: #f7dcd5; color: #a4665f; }
.book-card[data-status=paused] .status-text { background: #dee7e8; color: #617f83; }
.book-card[data-status=abandoned] .status-text { background: #e9dfd6; color: #917660; }
.book-card[data-wishlist=true] .status-text { background: #f5e2b9; color: #99782f; }
.rating-empty { display: flex; flex-direction: column; gap: 4px; font: 11px var(--serif); color: #8e7966; }
.empty-stars { display: block; white-space: nowrap; font: 20px/1.2 var(--serif); letter-spacing: 1px; color: #9c8672; }
.rating-display { display: flex; justify-content: space-between; font: 11px var(--serif); color: #9b815d; min-height: 36px; }
.rating-stars { font-size: 18px; color: #ddcfb9; }
.rating-stars > span { color: #bc9459; }
.needs-choice { position: absolute; top: -7px; right: -8px; margin: 0; z-index: 2; background: #f9e4b1; border: 1px solid #dec490; color: #8d662e; border-radius: 18px; padding: 5px 10px; font: 11px var(--serif); transform: rotate(-5deg); box-shadow: 1px 2px 4px #8c633018; }
.cover-placeholder { background: linear-gradient(135deg, #e9dbe5, #f5ead7); border-left-color: #b39ab15e; box-shadow: 2px 3px 5px #674d3d18; color: #8b6c7d; }
.cover-placeholder::before { border-color: #b89bb955; }
.placeholder-title { font: 20px/1.15 var(--serif); }
.placeholder-author { font-size: 8px; }
.cover-placeholder small { color: #8b746e; font-size: 8px; }
/* Les statistiques restent accessibles, après la collection. */
.stats { gap: 13px; border: 0; padding: 24px 0 0; margin: 25px 0 22px; border-top: 1px solid #d8c5ab80; }
.stat { border: 1px solid #dcc8b37d; border-radius: 6px; background: #f7eddf96; padding: 13px 12px; gap: 10px; box-shadow: none; transform: none; }
.stat:first-child { padding-left: 12px; }
.stat:last-child { border: 1px solid #dcc8b37d; }
.stat-icon { width: 32px; height: 34px; border-radius: 6px; background: #e9dde6 !important; color: #9b7b9d; }
.stat-icon.pink { background: #e3e7d7 !important; color: #849078; }
.stat-icon.peach { background: #f2e2c5 !important; color: #ad9165; }
.stat p { color: #927c67; font-size: 10px; }
.stat-value { font: 25px/1.2 var(--serif); color: #806a56; }
.stat-detail { font-size: 9px; color: #927f6c; }
.genre-distribution { margin: 0 0 23px; background: #eee5d7e8; border: 1px solid #d9c3a9; }
.genre-fill { background: #ad93b0; }
.import-banner { padding: 9px 12px; border: 1px solid #dbccb6; background: #f2e9dbe8; border-radius: 7px; font-size: 11px; color: #927956; margin-bottom: 23px; }
.import-banner.error { background: #f5ead5e8; color: #927244; }
.page-footer { border-top: 1px solid #d8c5ab80; margin-top: 0; padding: 19px 0 28px; font-size: 9px; color: #9c826a; line-height: 1.7; }
.page-footer > span:last-child { font: italic 13px var(--serif); color: #a1846b; }
/* Fiches et formulaires : même papier crème, avec les contrôles natifs. */
.book-dialog, .add-dialog, .settings-dialog { background: #fbf4e7; border: 1px solid #d6bda0; border-radius: 10px; box-shadow: 0 22px 85px #4b352e40; }
.add-dialog { width: 900px; }
.dialog-header h2 { font-family: var(--serif); color: #5b415f; }
.icon-button { background: #eadddf; color: #91717e; }
.detail-art { background: linear-gradient(130deg, #e6d9dd, #eee1ca); }
.detail-art .cover-wrap { background: none; border: 0; padding: 0; }
.detail-art-caption { color: #987e72; font-family: var(--hand); font-size: 13px; line-height: 1.8; }
.detail-art-sticker { color: #b2a283; }
.detail-body { background: #fcf6ea; }
.detail-title { font-family: var(--serif); color: #4d3851; }
.detail-author { color: #90745e; }
.detail-meta, .detail-source { color: #9c836c; }
.detail-summary, .candidate-summary { color: #7b6756; }
.detail-form { border-top: 1px solid #dfcbb1; }
.detail-section-title { font-family: var(--serif); color: #876983; }
.field { color: #8b725e; font-size: 11px; }
.field input, .field select, .field textarea { background: #fffaf2; border-color: #d8c0a7; }
.date-help { color: #9c836c; }
.catalogue-search-form .search-wide { background: #fffaf2; border-color: #d8c0a7; }
.catalogue-status, .small-help { color: #9c816b; font-size: 11px; }
.catalogue-results { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px; align-items: stretch; }
.search-result { display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 17px 15px; background: #f3e9da; border: 1px solid #dec7af; border-radius: 8px; height: 100%; box-shadow: 2px 3px 0 #bfa58e24; }
.search-result:nth-child(3n+2) { background: #eaf0e0; }
.search-result:nth-child(3n) { background: #f3e1df; }
.search-result:hover, .search-result.selected { background: #e9dfe9; border-color: #af8db5; }
.search-result > .icon, .search-result > .result-icon { display: none; }
.candidate-tile-cover { display: grid; place-items: center; width: 100%; max-width: 135px; margin: 0 auto 14px; aspect-ratio: 2/3; background: #e6dacb; border-radius: 3px; overflow: hidden; }
.candidate-tile-cover .cover-wrap { padding: 0; width: 100%; background: none; border: 0; }
.candidate-tile-cover img { width: 100%; height: 100%; object-fit: contain; }
.candidate-cover-status { display: block; font-size: 9px; color: #98836c; line-height: 1.5; margin-bottom: 12px; }
.result-copy { padding-bottom: 16px; }
.result-copy h3 { font: 21px/1.2 var(--serif); color: #6a4e68; }
.result-copy p { font-size: 12px; line-height: 1.5; color: #8b725f; }
.result-copy small { color: #9c846e; }
.result-summary { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; margin-top: 12px; font-size: 12px; line-height: 1.6; }
.candidate-pick { display: block; margin-top: auto; padding: 8px 9px; border-radius: 17px; background: #e6d8e7; color: #86668e; text-align: center; font-size: 11px; }
.choice-dialog .catalogue-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice-dialog .candidate-tile-cover { max-width: 190px; }
.choice-search { margin-top: 22px; font-size: 12px; }
.catalogue-results.choosing .search-result:not(.selected) { opacity: .45; }
.candidate-heading { background: #eee2df; border: 1px solid #d8bcb3; padding: 18px; border-radius: 8px; }
.preview-cover-label { color: #a08771; }
.candidate-tile-cover .preview-cover-label { padding: 15px; }
.detail-cover-error { background: #f5e6c9; border: 1px solid #dcc49e; color: #977747; padding: 12px; margin: 15px 0; border-radius: 7px; font-size: 11px; }
.detail-cover-error button { color: inherit; font-size: 11px; }
.settings-row h3 { font-family: var(--serif); }
.settings-row p, .settings-footnote, .settings-dialog > p { color: #927c68; }
.toast { background: #806087; }
@media (min-width: 2000px) {
  .app-shell { margin-inline: auto; }
}
@media (max-width: 1440px) {
  .hero h1 { font-size: 33px; }
  .title-leaf { width: 25px; }
  .topbar { gap: 9px; }
  .library-search { padding-inline: 11px; }
  .library-search input { font-size: 11px; }
  .topbar .button { padding-inline: 12px; font-size: 10px; }
  .book-grid { gap: 29px 16px; }
  .book-grid .book-card { padding-inline: 8px; }
  .book-title { font-size: 16px; }
  .empty-stars { font-size: 18px; letter-spacing: 0; }
}
@media (max-width: 1240px) {
  body {
    background-image: linear-gradient(#fbf3e63b, #fbf3e63b), url('/refuge-bg.png');
    background-size: 100% 100dvh, calc(100% + 240px) 100dvh;
  }
  .app-shell { grid-template-columns: 158px minmax(0, 1fr); gap: 25px; width: 84%; margin-inline: 8%; }
  .brand { font-size: 38px; letter-spacing: -2.4px; }
  .brand-mark { width: 25px; margin-left: -6px; }
  .brand-mark > .icon { width: 27px; }
  .shelf { gap: 6px; padding-inline: 8px; }
  .shelf > span:nth-child(2) { font-size: 12px; }
  .sidebar-note { width: 125px; }
  .sidebar-note p { font-size: 12px; }
  .library-intro { display: block; }
  .hero h1 { font-size: 37px; }
  .topbar { margin-top: 19px; justify-content: flex-start; }
  .library-search { max-width: none; }
  .book-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px 17px; }
}
@media (max-width: 1040px) {
  body { background-size: 100% 100dvh, calc(100% + 320px) 100dvh; }
  .app-shell { width: 90%; margin-inline: 5%; gap: 23px; grid-template-columns: 150px minmax(0, 1fr); }
  .sidebar { padding-inline: 9px; }
  .brand { font-size: 36px; }
  .brand-tagline { font-size: 7px; letter-spacing: 1.6px; }
  .main-content { padding: 18px 0 0; }
  .stat { padding: 11px 10px; }
  .stat:first-child { padding-left: 10px; }
  .stat-detail { display: block; font-size: 9px; }
  .book-author { font-size: 11px; }
}
@media (max-width: 900px) {
  .book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 30px 18px; }
  .book-title { font-size: 17px; }
  .book-author { font-size: 12px; }
  .library { grid-template-columns: 1fr; }
  .section-heading { margin-bottom: 13px; }
  .library-toolbar { justify-content: space-between; margin-bottom: 22px; }
  .sort-control { margin-left: auto; }
}
@media (max-width: 760px) {
  :root {
    --paper-scroll-top: calc(54px + 1cm);
    --paper-scroll-bottom: max(1cm, calc(100dvh - 841.5px + 1cm));
  }
  body { background-size: auto 900px; background-position: center top; background-attachment: fixed; background-repeat: no-repeat; }
  .app-shell { display: flex; flex-direction: column; width: 94%; height: calc(100dvh - var(--paper-scroll-top) - var(--paper-scroll-bottom)); margin: var(--paper-scroll-top) 3% 0; min-height: 0; padding: 0; align-items: stretch; }
  .sidebar { flex-shrink: 0; }
  .sidebar { display: block; position: relative; top: 0; padding: 20px 18px 0; height: auto; min-height: 0; border-radius: 7px 7px 12px 12px; background: #fbf1e0e8; box-shadow: 1px 3px 7px #7855360f; }
  .brand { display: flex; align-items: center; font-size: 34px; letter-spacing: -1.8px; margin: 0 0 21px; padding: 0; gap: 10px; }
  .brand > span:last-child { display: block; }
  .brand br { display: none; }
  .brand-mark { width: 29px; margin: 0; order: 2; }
  .brand-mark > .icon { width: 29px; height: 29px; }
  .brand-tagline, .sidebar-caption, .sidebar-note, .sidebar-bottom { display: none; }
  .shelf-nav { flex-direction: row; gap: 8px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: #cfb9a3 transparent; margin: 0 -18px; padding: 0 18px 13px; }
  .shelf { padding: 9px 12px; min-height: 37px; flex-shrink: 0; }
  .shelf > .icon { display: block; width: 15px; height: 15px; }
  .shelf > span:nth-child(2) { font-size: 12px; }
  .shelf:hover { transform: none; }
  .shelf.active { transform: none; }
  .main-content { flex: 1; height: auto; margin: 0; padding: 26px 8px 0; }
  .hero h1 { font-size: 38px; }
  .hero-description { font-size: 13px; }
  .title-leaf { width: 30px; }
  .topbar { gap: 10px; }
  .library-search { min-width: 0; }
  .topbar .button { font-size: 11px; padding: 10px 12px; }
  .topbar .button > .icon { width: 16px; }
  .mobile-settings { display: inline-grid; flex-shrink: 0; width: 30px; height: 32px; background: #ece0d2; }
  .mobile-settings .icon { width: 16px; }
  .book-grid { gap: 28px 17px; }
  .book-grid .book-card { padding: 11px 10px 13px; }
  .book-title { font-size: 18px; }
  .book-author { font-size: 12px; }
  .empty-stars { font-size: 21px; }
  .status-text { font-size: 11px; }
  .stats { padding-top: 22px; gap: 9px; }
  .stat { padding: 12px 10px; }
  .stat p { min-height: 0; font-size: 9px; }
  .stat-value { font-size: 25px; }
  .stat-detail { font-size: 9px; }
  .page-footer { flex-wrap: wrap; gap: 9px; padding-bottom: 10px; }
  .catalogue-results { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
  .add-dialog { padding: 25px 20px; }
  .candidate-tile-cover { max-width: 125px; }
  .choice-dialog .candidate-tile-cover { max-width: 160px; }
}
@media (max-width: 540px) {
  .app-shell { width: 96%; margin-inline: 2%; }
  .sidebar { padding: 19px 14px 0; }
  .brand { font-size: 31px; }
  .shelf-nav { margin-inline: -14px; padding-inline: 14px; }
  .main-content { padding: 24px 7px 0; }
  .hero h1 { font-size: 34px; letter-spacing: -1.1px; }
  .hero .eyebrow { font-size: 7px; letter-spacing: 1.6px; }
  .hero-description { font-size: 12px; }
  .topbar { gap: 7px; flex-wrap: nowrap; }
  .library-search { padding-inline: 10px; }
  .library-search input { font-size: 11px; min-height: 39px; }
  .topbar .button { font-size: 0; gap: 0; width: 39px; height: 39px; min-height: 39px; padding: 0; }
  .topbar .button .icon { width: 18px; }
  .topbar .button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .section-title-row h2 { font-size: 21px; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 12px; }
  .book-grid .book-card { padding: 11px 9px 13px; }
  .book-title { font-size: 17px; }
  .book-author { font-size: 12px; }
  .cover-status { right: 7px; }
  .needs-choice { right: -5px; font-size: 10px; padding: 5px 8px; }
  .empty-stars { font-size: 21px; }
  .stats { gap: 7px; }
  .stat, .stat:first-child { padding: 10px 8px; }
  .stat p { font-size: 9px; }
  .stat-detail { font-size: 8px; }
  .stat-value { font-size: 24px; margin-right: 0; }
  .choice-dialog .candidate-tile-cover { max-width: 130px; }
  .search-result { padding: 13px 10px; }
  .result-copy h3 { font-size: 19px; }
  .result-copy p { font-size: 11px; }
  .candidate-heading { padding: 14px; }
}
@media (max-width: 360px) {
  .hero h1 { font-size: 30px; }
  .title-leaf { width: 25px; }
  .brand { font-size: 29px; }
  .book-grid { gap: 22px 10px; }
  .book-grid .book-card { padding-inline: 7px; }
  .book-title { font-size: 16px; }
  .book-author { font-size: 11px; }
  .status-text { font-size: 10px; }
  .empty-stars { font-size: 18px; }
}
/* Garder tous les onglets accessibles sans déplacer le marque-page. */
@media (min-width: 761px) and (max-height: 1050px) {
  .sidebar-note { display: none; }
}
@media (min-width: 761px) and (max-height: 850px) {
  .sidebar { padding-block: 14px; }
  .brand-tagline { padding-top: 10px; }
  .sidebar-caption { margin-block: 15px 9px; }
  .shelf-nav { gap: 6px; }
  .shelf { min-height: 34px; padding-block: 7px; }
  .sidebar-bottom { margin-top: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .book-grid .book-card:hover, .shelf:hover { transform: none; }
}

/* Une seule barre immobile ; seule la collection défile sous sa limite. */
.main-content {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 0;
  overflow: hidden;
}
.main-content > .topbar {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  min-height: 44px;
  margin: 0;
  padding: 0;
}
.main-content > .topbar .library-search {
  flex: 1;
  min-width: 0;
  max-width: none;
  margin: 0;
}
.main-content > .topbar > button { flex-shrink: 0; }
.main-content > .topbar .filter-button {
  width: auto;
  height: 41px;
  padding: 8px 14px;
  gap: 7px;
  font-size: 11px;
}
.main-content > .topbar .filter-button span {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
}
.collection-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: #cfb9a3 transparent;
  padding: 8px 5px 0;
}
.collection-scroll .library { display: block; }
.collection-heading {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.main-content > .filters {
  position: absolute;
  top: 58px;
  right: 0;
  z-index: 5;
  width: min(100%, 720px);
  max-height: calc(100% - 66px);
  overflow-y: auto;
  margin: 0;
  background: #fbf4e7;
  box-shadow: 0 10px 28px #59402e30;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
}
.main-content > .filters .sort-control { display: flex; flex-direction: column; align-items: stretch; margin: 0; }
.main-content > .filters .sort-control select { max-width: none; }
@media (max-width: 760px) {
  .main-content { padding: 0 8px; }
  .main-content > .filters { right: 8px; width: calc(100% - 16px); grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  .main-content > .topbar { gap: 7px; }
  .main-content > .topbar .filter-button { padding-inline: 10px; }
  .main-content > .topbar .library-search { padding-inline: 9px; gap: 6px; }
}
