:root {
  color-scheme: dark;
  --bg: #16110d;
  --text: #f3e9dc;
  --muted: #b8a894;
  --gold: #f2bd72;
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --s: 1;
}

* { box-sizing: border-box; }
/* Android colore en bleu la zone touchée : on garde nos propres états (choisi, survol, focus clavier). */
html { -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  min-height: 100dvh;
  padding-bottom: 100px;
  background: radial-gradient(120% 60% at 50% 0%, #2c2018 0%, var(--bg) 65%) fixed;
  color: var(--text);
  font-family: system-ui, sans-serif;
}

button, input, .button { font: inherit; border-radius: 10px; border: 0; padding: 12px 16px; }
button, .button { cursor: pointer; text-align: center; color: var(--text); }
input { background: #ffffff10; color: var(--text); border: 1px solid #ffffff1c; }
.primary { background: linear-gradient(180deg, #f2bd72, #d48f3c); color: #2a1a08; font-weight: 600; box-shadow: 0 6px 20px -6px #d48f3c99; }
.ghost { background: #ffffff14; }
.small { padding: 8px 12px; font-size: .85rem; }
.danger { width: 100%; margin-top: 18px; background: #ffffff0d; color: #ff9b8f; }
.icon { display: grid; place-items: center; padding: 10px 12px; }

/* En-tête */
.top {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 16px 4px;
  display: grid;
  gap: 12px;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
h1 { margin: 0; font: 600 1.5rem var(--serif); letter-spacing: .01em; }
#count { color: var(--muted); font-size: .9rem; }
.search { display: flex; gap: 8px; }
.search input { flex: 1; min-width: 0; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 8px 14px;
  border: 1px solid #ffffff1a;
  border-radius: 999px;
  background: #ffffff0d;
  font-size: .88rem;
}
.chip.is-on { background: linear-gradient(180deg, #f2bd72, #d48f3c); border-color: transparent; color: #2a1a08; font-weight: 600; }
.chip-count { margin-left: 7px; font-size: .78em; opacity: .6; }
.chip-add { border-style: dashed; color: var(--muted); }
.chip-input { flex: none; width: 150px; padding: 8px 14px; border-radius: 999px; font-size: .88rem; }
.picker { display: flex; flex-wrap: wrap; gap: 8px; }

/* Bibliothèques */
#libraries { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.no-results { padding: 40px 0; color: var(--muted); font: italic 1.05rem var(--serif); text-align: center; }

.bookcase {
  position: relative;
  margin: 30px 0;
  padding: 34px 14px 18px;
  border-radius: 12px;
  background:
    repeating-linear-gradient(92deg, #ffffff06 0 2px, transparent 2px 9px),
    linear-gradient(180deg, #5a3820, #3d2413);
  box-shadow: 0 40px 70px -25px #000, inset 0 1px 0 #ffffff1a;
}
@media (max-width: 600px) {
  :root { --s: .78; }
  #libraries { padding: 0 10px; }
  .bookcase { margin: 26px 0; padding: 32px 8px 12px; }
}

/* Plaque de laiton gravée */
.plate {
  position: absolute;
  top: 6px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 40px);
  padding: 3px 12px;
  border-radius: 3px;
  background: linear-gradient(180deg, #f6dc9c, #c99a4b 55%, #a87731);
  box-shadow: 0 2px 5px #000a, inset 0 1px 0 #fffb, inset 0 -1px 0 #0004;
  color: #3b2508;
  transform: translateX(-50%);
}
.plate::before,
.plate::after {
  content: "";
  flex: none;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e9c37a, #6b4714);
  box-shadow: inset 0 0 0 .5px #0006;
}
.plate-name {
  overflow: hidden;
  font: 700 .78rem var(--serif);
  letter-spacing: .12em;
  text-overflow: ellipsis;
  text-shadow: 0 1px 0 #fff8;
  text-transform: uppercase;
  white-space: nowrap;
}

.shelf {
  overflow: hidden;
  border-radius: 4px;
  background: radial-gradient(90% 55% at 50% 0%, #4a3727, #1e150f 75%);
  box-shadow: inset 0 0 70px #000d, inset 0 0 0 1px #0008;
}

/* Étage : ombre de la planche du dessus, puis planche (dessus éclairé, chant) */
.row {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  height: calc(250px * var(--s));
  padding: 0 calc(14px * var(--s)) 19px;
  background:
    linear-gradient(to bottom, #000a, transparent 30px),
    linear-gradient(to bottom,
      transparent calc(100% - 24px),
      #c08a52 calc(100% - 24px), #94643a calc(100% - 15px),
      #63401f calc(100% - 15px), #3b2310 100%);
}
.row.is-empty { height: calc(150px * var(--s)); justify-content: center; }
.empty { margin: 0 0 30px; color: var(--muted); font: italic .95rem var(--serif); list-style: none; }

.slot { flex: none; display: flex; align-items: flex-end; justify-content: center; height: 100%; cursor: pointer; }
/* Le livre déborde de sa case en 3D : seule la case reçoit le toucher, à la largeur exacte du livre rangé. */
.row .book { pointer-events: none; }
.row { touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* Livre 3D */
.book {
  --h: calc(var(--bh) * var(--s) * 1px);
  --w: calc(var(--bw) * var(--s) * 1px);
  --d: calc(var(--bd) * var(--s) * 1px);
  --rest: rotateY(var(--ry));
  position: relative;
  flex: none;
  width: var(--w);
  height: var(--h);
  padding: 0;
  border-radius: 0;
  background: none;
  perspective: 1100px;
  perspective-origin: 50% -40%;
  font-size: calc(var(--w) / 10);
}
.row.is-spine .book { --rest: rotateY(90deg); }
.book::after {
  content: "";
  position: absolute;
  left: -14%;
  right: -4%;
  bottom: -7px;
  height: 16px;
  background: radial-gradient(closest-side, #000d, transparent);
  z-index: -1;
}
.row.is-spine .book::after { left: calc(50% - var(--d)); right: calc(50% - var(--d)); }
.book-3d {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: var(--rest);
  transition: transform .7s cubic-bezier(.2, .8, .2, 1);
}
@media (hover: hover) {
  .slot:hover .book-3d { transform: translateY(-14px) rotateY(8deg); }
  .row.is-spine .slot:hover .book-3d { transform: translateY(-18px) rotateY(66deg); }
}
.book:focus-visible .book-3d { transform: translateY(-14px) rotateY(8deg); }
.row.is-spine .book:focus-visible .book-3d { transform: translateY(-18px) rotateY(66deg); }
/* Loupe : le livre choisi sort de l'étagère et se tourne complètement de face, devant ses voisins. */
.slot.is-picked { position: relative; z-index: 5; }
.slot.is-picked .book-3d,
.row.is-spine .slot.is-picked .book-3d { transform: translateY(-22px) translateZ(60px) rotateY(0deg); transition-duration: .3s; }
.book:focus-visible { outline: none; }

.face { position: absolute; backface-visibility: hidden; }
.front {
  inset: 0;
  overflow: hidden;
  border-radius: 1px 4px 4px 1px;
  background: hsl(var(--hue) 40% 28%);
  transform: translateZ(calc(var(--d) / 2));
}
.front img { display: block; width: 100%; height: 100%; object-fit: cover; }
.front::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, #0007 0, #ffffff30 2.5%, #0004 5%, transparent 9%),
    linear-gradient(120deg, #ffffff26, transparent 45%);
}
.spine {
  top: 0;
  left: 0;
  width: var(--d);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(90deg, hsl(var(--hue) 45% 14%), hsl(var(--hue) 42% 30%) 45%, hsl(var(--hue) 45% 16%));
  transform: translateX(calc(var(--d) / -2)) rotateY(-90deg);
}
.spine::before,
.spine::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: hsl(42 70% 66% / .65);
}
.spine::before { top: 8%; }
.spine::after { bottom: 8%; }
.spine span {
  max-height: 76%;
  overflow: hidden;
  writing-mode: vertical-rl;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: hsl(var(--hue) 35% 90% / .9);
  font: 600 min(calc(var(--d) * .46), 13px) var(--serif);
  letter-spacing: .04em;
}
.pages {
  top: 3px;
  bottom: 3px;
  left: calc(var(--w) - var(--d));
  width: var(--d);
  background: repeating-linear-gradient(90deg, #f4eedf 0 1px, #d6ccb6 1px 2px);
  transform: translateX(calc(var(--d) / 2)) rotateY(90deg);
}
.top-edge {
  top: 0;
  left: 0;
  width: var(--w);
  height: var(--d);
  background: repeating-linear-gradient(0deg, #efe7d4 0 1px, #d3c8b1 1px 2px);
  transform: translateY(calc(var(--d) / -2)) rotateX(90deg);
}
.back {
  inset: 0;
  border-radius: 4px 1px 1px 4px;
  background: hsl(var(--hue) 35% 20%);
  transform: translateZ(calc(var(--d) / -2)) rotateY(180deg);
}

/* Signet : deux plans croisés, visible de face comme de dos */
.mark {
  position: absolute;
  top: calc(var(--h) * -.07);
  left: calc(var(--d) * .9);
  width: calc(7px * var(--s));
  height: calc(var(--h) * .14);
  border-radius: 2px 2px 0 0;
  background: linear-gradient(#ffd98a, #d49a3a);
  box-shadow: 0 0 8px #f2bd7299;
}
.mark-b { transform: rotateY(90deg); }

/* Couverture générée quand aucune image n'existe */
.gen-cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16% 11% 12%;
  background: radial-gradient(120% 80% at 25% 15%, hsl(var(--hue) 55% 44%), hsl(var(--hue) 50% 18%));
  color: hsl(var(--hue) 40% 93%);
  font-family: var(--serif);
  text-align: center;
}
.gen-cover::before {
  content: "";
  position: absolute;
  inset: 6%;
  border: 1px solid hsl(var(--hue) 60% 85% / .45);
  border-radius: 2px;
}
.gen-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  font-size: 1.1em;
  font-weight: 600;
  line-height: 1.15;
}
.gen-author { font-size: .78em; font-style: italic; opacity: .85; }

/* Arrivée d'un livre ajouté */
.book.is-new .book-3d { animation: drop-in 1.1s cubic-bezier(.25, 1.4, .5, 1) both; }
.book.is-new::before {
  content: "";
  position: absolute;
  inset: -30% -40%;
  z-index: -2;
  background: radial-gradient(closest-side, #f2bd7288, transparent);
  animation: glow 2.4s ease-out both;
}
@keyframes drop-in {
  from { transform: translateY(-220px) rotateY(-40deg) rotateX(35deg); opacity: 0; }
  40% { opacity: 1; }
  to { transform: var(--rest); }
}
@keyframes glow {
  from { opacity: 0; }
  25% { opacity: 1; }
  to { opacity: 0; }
}

/* Bouton de scan flottant */
.fabs {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  gap: 10px;
}
.fab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  border-radius: 999px;
  font-size: 1.05rem;
  box-shadow: 0 14px 30px -8px #000, 0 6px 26px -6px #d48f3cbb;
}
.fab-round { width: 56px; height: 56px; padding: 0; justify-content: center; }

/* Scanner plein écran */
#scanner { position: fixed; inset: 0; z-index: 20; background: #000; }
#scanner[hidden] { display: none; }
#scanner video { width: 100%; height: 100%; object-fit: cover; }
.reticle {
  position: absolute;
  top: 42%;
  left: 50%;
  width: min(82vw, 440px);
  aspect-ratio: 2 / 1;
  overflow: hidden;
  border: 2px solid #ffffffaa;
  border-radius: 16px;
  box-shadow: 0 0 0 100vmax #0009;
  transform: translate(-50%, -50%);
}
.reticle::after {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  height: 2px;
  background: #ff5a4d;
  box-shadow: 0 0 14px 2px #ff5a4d;
  animation: laser 1.5s ease-in-out infinite alternate;
}
@keyframes laser { from { top: 12%; } to { top: 86%; } }
.scanner-bar {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, #000d);
}
#scan-status { flex: 1; margin: 0; font-size: .9rem; }

/* Fenêtre : ajout, fiche, liaison */
dialog#modal {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: #1f1712;
  color: var(--text);
  box-shadow: 0 40px 90px #000;
}
dialog#modal::backdrop { background: #0009; backdrop-filter: blur(6px); }
.close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 40px; height: 40px; padding: 0; background: #ffffff14; font-size: 1.4rem; }
.stage {
  --s: 1.5;
  display: flex;
  justify-content: center;
  padding: 44px 0 30px;
  background: radial-gradient(55% 70% at 50% 45%, #5a4129, transparent);
  pointer-events: none;
}
.stage .book-3d { animation: float 7s ease-in-out infinite alternate; }
@keyframes float {
  from { transform: rotateY(-38deg) rotateX(5deg); }
  to { transform: rotateY(38deg) rotateX(-3deg) translateY(-8px); }
}
.sheet { padding: 22px; }
.stage + .sheet { padding-top: 0; }
.sheet h2 { margin: 0 0 4px; padding-right: 40px; font: 600 1.35rem/1.2 var(--serif); }
.sheet h3 { margin: 22px 0 10px; color: var(--muted); font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.sheet .author { margin: 0; color: var(--muted); font-style: italic; }
.sheet .edition { margin: 6px 0 0; color: var(--muted); font-size: .85rem; }
.sheet dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: .9rem; }
.sheet dt { color: var(--muted); }
.sheet dd { margin: 0; overflow-wrap: anywhere; }
.sheet a { color: var(--gold); }
.sheet .field { width: 100%; margin: 14px 0 0; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.warning {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid #f2bd7255;
  border-radius: 12px;
  background: #f2bd7214;
  font-size: .92rem;
}
.warning p { margin: 0 0 10px; }
.warning .warning-question { margin: 12px 0 0; font-weight: 600; }

.list { display: grid; gap: 8px; margin: 10px 0 12px; padding: 0; list-style: none; }
.list-item { display: flex; align-items: center; gap: 8px; }
.list-open {
  flex: 1;
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px;
  background: #ffffff0b;
  text-align: left;
  font-size: .85rem;
}
.list-open strong { font-family: var(--serif); font-size: 1rem; }
.list-open span { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.list-open .list-libs { color: var(--gold); opacity: .85; }

/* Toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: #2b2019ee;
  box-shadow: 0 12px 30px #000a;
  font-size: .92rem;
  opacity: 0;
  transform: translate(-50%, 20px);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
#toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Compte dans l'en-tête */
.account { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.account form { margin: 0; }
.account-name { color: var(--muted); font-size: .85rem; }
a.button { text-decoration: none; }
@media (max-width: 600px) {
  .brand { flex-wrap: wrap; }
  .account-name { display: none; }
}

/* Reprise de l'étagère gardée dans le navigateur */
.import-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #f2bd7255;
  border-radius: 12px;
  background: #f2bd7214;
  font-size: .92rem;
}
.import-banner[hidden] { display: none; }
.import-banner p { flex: 1 1 220px; margin: 0; }

/* Pages connexion et comptes */
body.page { display: grid; place-items: start center; padding: 40px 16px; }
.card {
  position: relative;
  width: min(820px, 100%);
  padding: 30px 24px 24px;
  border-radius: 14px;
  background:
    repeating-linear-gradient(92deg, #ffffff05 0 2px, transparent 2px 9px),
    linear-gradient(180deg, #2a1d14, #1d140e);
  box-shadow: 0 40px 70px -25px #000, inset 0 1px 0 #ffffff14;
}
.card-narrow { width: min(400px, 100%); margin-top: 8vh; padding-top: 44px; }
.card-plate {
  position: absolute;
  top: -14px;
  left: 50%;
  padding: 5px 18px;
  border-radius: 3px;
  background: linear-gradient(180deg, #f6dc9c, #c99a4b 55%, #a87731);
  box-shadow: 0 2px 5px #000a, inset 0 1px 0 #fffb;
  color: #3b2508;
  font: 700 .85rem var(--serif);
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-50%);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card h1 { margin: 0; }
.card h2 { margin: 30px 0 14px; font: 600 1.15rem var(--serif); }
.card-note { margin: 18px 0 0; color: var(--muted); font-size: .85rem; text-align: center; }

.form { display: grid; gap: 14px; }
.form-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.form-field { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; font-size: .85rem; color: var(--muted); }
.form-field input { color: var(--text); font-size: 1rem; }
.form-roles { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.form-roles > span { width: 100%; }
.form-check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .9rem; }
.form-check input { width: 18px; height: 18px; accent-color: #d48f3c; }
.form-actions { display: flex; align-items: end; justify-content: flex-end; }
.form-error { margin: 0; color: #ff9b8f; font-size: .85rem; font-style: normal; }
.form-success { margin: 0 0 16px; padding: 10px 14px; border-radius: 10px; background: #7fd18b1f; color: #a8e6b0; }

.users { width: 100%; border-collapse: collapse; font-size: .9rem; }
.users th { color: var(--muted); font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
.users th, .users td { padding: 10px 8px; border-bottom: 1px solid #ffffff10; }
.users td:last-child, .users th:last-child { text-align: right; }
.role { padding: 3px 10px; border-radius: 999px; background: #ffffff12; font-size: .8rem; }
.role-admin { background: #f2bd7233; color: var(--gold); }
@media (max-width: 600px) {
  .users th:nth-child(2), .users td:nth-child(2) { display: none; }
}

/* Gestion des comptes */
a.account-name { color: var(--muted); text-decoration: none; border-bottom: 1px dotted #b8a89466; }
@media (max-width: 600px) {
  a.account-name { display: inline; }
}
.card-medium { width: min(520px, 100%); }
.card-meta { margin: -8px 0 20px; color: var(--muted); font-size: .85rem; }
.you { color: var(--muted); font-size: .8rem; }
.users td:last-child .button { white-space: nowrap; }
.danger-zone { display: grid; gap: 10px; padding: 16px; border: 1px solid #ff9b8f44; border-radius: 12px; }
.danger-zone p { margin: 0; color: var(--muted); font-size: .9rem; }
.danger-zone .danger { margin-top: 0; }
.form h2 { margin: 14px 0 0; }

/* Bulle « loupe » au-dessus du doigt */
#pick-bubble {
  position: fixed;
  z-index: 40;
  display: grid;
  gap: 2px;
  width: max-content;
  max-width: min(300px, calc(100vw - 24px));
  padding: 10px 14px 10px 18px;
  border-radius: 12px;
  background:
    linear-gradient(90deg, hsl(var(--hue, 30) 45% 32%) 0 6px, transparent 6px),
    #2b2019f2;
  box-shadow: 0 16px 34px #000c, inset 0 0 0 1px #ffffff14;
  pointer-events: none;
  transform: translate(-50%, -100%);
}
#pick-bubble[hidden] { display: none; }
#pick-bubble strong { overflow: hidden; font: 600 1rem/1.2 var(--serif); text-overflow: ellipsis; white-space: nowrap; }
#pick-bubble span { overflow: hidden; color: var(--muted); font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }

/* Recherche pour ajouter */
dialog#modal.is-tall { height: calc(100dvh - 24px); }
dialog#modal.is-tall #modal-body { height: 100%; }
.search-sheet { display: flex; flex-direction: column; gap: 12px; min-height: 100%; padding-bottom: 0; }
.search-head { display: flex; align-items: center; gap: 10px; padding-right: 44px; }
.search-head h2 { flex: 1; margin: 0; padding: 0; }
.advanced-toggle[aria-pressed="true"] { background: linear-gradient(180deg, #f2bd72, #d48f3c); color: #2a1a08; }
.search-sheet .field { margin: 0; }
.advanced-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.advanced-fields[hidden] { display: none; }
.search-status { margin: 0; color: var(--muted); font-size: .85rem; min-height: 1.2em; }
.results { flex: 1; display: grid; align-content: start; gap: 8px; }
.result {
  display: flex;
  align-items: stretch;
  gap: 12px;
  padding: 10px 12px 10px 10px;
  border: 1px solid transparent;
  background: #ffffff0b;
  text-align: left;
}
.result.is-selected { border-color: #f2bd72aa; background: #f2bd721c; }
.result-spine {
  flex: none;
  width: 10px;
  border-radius: 2px;
  background: linear-gradient(90deg, hsl(var(--hue) 45% 16%), hsl(var(--hue) 42% 34%) 50%, hsl(var(--hue) 45% 18%));
}
.result-body { flex: 1; display: grid; gap: 2px; min-width: 0; }
.result-body strong { font: 600 1rem/1.25 var(--serif); }
.result-meta, .result-source { overflow: hidden; color: var(--muted); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.result-source { font-size: .74rem; opacity: .8; }
.badge { justify-self: start; margin-top: 4px; padding: 2px 8px; border-radius: 999px; background: #ffffff14; color: var(--gold); font-size: .74rem; }
.badge-owned { background: #f2bd7226; }
.result-check {
  flex: none;
  align-self: center;
  width: 22px;
  height: 22px;
  border: 2px solid #ffffff40;
  border-radius: 50%;
}
.result.is-selected .result-check {
  border-color: transparent;
  background: radial-gradient(circle, #2a1a08 0 3px, transparent 3.5px), linear-gradient(180deg, #f2bd72, #d48f3c);
}
.search-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 -22px;
  padding: 14px 22px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, #1f1712 18px);
}
.search-count { flex: 1; color: var(--muted); font-size: .85rem; }
.search-footer .primary:disabled { opacity: .45; box-shadow: none; }
#pick-bubble.below { transform: translate(-50%, 0); }
select { font: inherit; padding: 12px 14px; border: 1px solid #ffffff1c; border-radius: 10px; background: #2a1f18; color: var(--text); }
.form-field select { font-size: 1rem; }

/* Bascule de langue */
.locale-switch { display: inline-flex; margin: 0; }
.locale-switch button { padding: 8px 12px; border-radius: 10px; background: #ffffff14; color: var(--text); font-size: .85rem; }
.card-locale { display: flex; justify-content: center; margin-top: 16px; }

/* Bibliothèque repliée : seule la plaque reste, avec le nombre de livres */
.bookcase { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .35s ease, padding-bottom .35s ease; }
.bookcase > .shelf { min-height: 0; }
.bookcase.is-collapsed { grid-template-rows: 0fr; padding-bottom: 6px; }
.bookcase.is-collapsed > .shelf { box-shadow: none; }
.plate-count { display: none; font: 600 .72rem var(--serif); opacity: .7; }
.plate-count::before { content: "· "; }
.bookcase.is-collapsed .plate-count { display: inline; }
.photo-button { display: inline-flex; align-items: center; gap: 6px; }

/* Marque Hylla */
.brand-name { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .01em; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; box-shadow: 0 4px 12px #0008; }
.login-brand { display: grid; justify-items: center; gap: 10px; margin: 0 0 22px; }
.login-brand img { width: 72px; height: 72px; border-radius: 18px; box-shadow: 0 10px 24px #000a; }
.login-brand p { margin: 0; color: var(--muted); font: italic 500 1.05rem var(--serif); }

/* Barre du haut du meuble : repli à gauche, crayon à droite, plaque au centre */
.bookcase-bar {
  position: absolute;
  top: 5px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.bar-button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: #0000002e;
  color: #f2d9a8;
  box-shadow: inset 0 1px 0 #ffffff14;
  pointer-events: auto;
}
.bar-edit { margin-left: auto; }
.bar-fold svg { transition: transform .25s ease; }
.bookcase.is-collapsed .bar-fold svg { transform: rotate(-90deg); }
@media (hover: hover) {
  .bar-button:hover { background: #00000055; color: #fff3d6; }
}

/* Glisser-déposer */
body.is-dragging { cursor: grabbing; -webkit-user-select: none; user-select: none; }
body.is-dragging .bookcase { transition: box-shadow .2s, transform .2s; }
.bookcase.is-drop-target { box-shadow: 0 0 0 3px var(--gold), 0 0 40px #f2bd7266, 0 40px 70px -25px #000; transform: scale(1.01); }
.slot.is-dragged { opacity: .3; }
.drag-ghost {
  --s: 1;
  position: fixed;
  z-index: 60;
  width: 64px;
  height: 96px;
  overflow: hidden;
  border-radius: 2px 5px 5px 2px;
  font-size: 6.4px;
  box-shadow: 0 18px 30px #000c, 0 0 0 1px #ffffff22;
  pointer-events: none;
  transform: translate(-50%, -75%) rotate(-7deg) scale(1.08);
}
.drag-ghost img { display: block; width: 100%; height: 100%; object-fit: cover; }
.picker-hint { margin: 8px 0 0; color: #ff9b8f; font-size: .85rem; }
.picker-hint[hidden] { display: none; }
.sheet-actions .primary:disabled { opacity: .45; box-shadow: none; cursor: not-allowed; }

/* Page d'une bibliothèque */
.plate-link { cursor: pointer; }
.plate-link:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (hover: hover) {
  .plate-link:hover { filter: brightness(1.08); }
}
body.is-library-view .top { display: none; }
.library-head {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 -16px;
  padding: 14px 16px 10px;
  background: rgb(22 17 13 / .82);
  backdrop-filter: blur(14px);
}
.library-head .icon { flex: none; width: 44px; height: 44px; padding: 0; }
.library-plate { position: static; flex: 0 1 auto; margin: 0 auto; padding: 6px 16px; transform: none; }
.library-plate .plate-name { font-size: .95rem; }
.library-stats { margin: 4px 0 14px; color: var(--muted); font-size: .88rem; text-align: center; }
.library-tools { display: grid; gap: 10px; margin-bottom: 18px; }
.library-sorts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.library-sorts > span { color: var(--muted); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; }
.bookcase.is-full { --s: 1; margin-top: 0; padding-top: 14px; }
.row.is-filler { pointer-events: none; }
.action-list { display: grid; gap: 8px; margin-top: 18px; }
.action-item { width: 100%; padding: 15px 16px; background: #ffffff0d; text-align: left; }
@media (hover: hover) {
  .action-item:hover { background: #ffffff18; }
}
@media (max-width: 600px) {
  .library-head { margin: 0 -10px; padding: 12px 10px 8px; }
}
.library-sorts .chip { padding: 6px 11px; font-size: .8rem; }
.library-sorts > span { min-width: 74px; }
