/* =========================================================
   Taillepierre — catalogue
   Même feuille que Dragons & Legends ; seule la palette change :
   pierre et ardoise pour les fonds, or pour l'accent, bronze en second.
   ========================================================= */

:root {
  --accent: #d9ae3f;
  --accent-soft: rgba(217, 174, 63, 0.14);
  --bronze: #b07a45;
  --bronze-soft: rgba(176, 122, 69, 0.16);
  --bg: #181715;
  --bg-panel: #22211e;
  --bg-raised: #2b2e31;
  --line: rgba(236, 229, 214, 0.09);
  --line-strong: rgba(236, 229, 214, 0.17);
  --text: #ece5d6;
  --muted: #a39e94;
  --muted-dim: #77726a;
  --radius: 10px;
  --head-h: 116px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app {
  width: 100%;
  min-height: calc(100dvh - var(--gl-footer-h, 44px));
  margin: 0;
  padding: 0 14px 28px;
}

/* ---------- En-tete ----------
   Collante et opaque : titre et recherche restent accessibles quel que soit
   l'endroit de la galerie. Le fond n'a pas besoin de deborder jusqu'aux bords
   de la fenetre — tout le contenu vit dans `.app`, et les gouttieres de 14 px
   sont vides ; rien ne peut donc defiler derriere. */

.da-head {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 16px 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.da-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  text-decoration: none;
  color: inherit;
}
.da-logo {
  width: 30px;
  height: 30px;
  flex: none;
  display: block;
}
@media (max-width: 400px) {
  /* Sous 400 px, le logo dispute la place au titre et au hamburger. */
  .da-logo { display: none; }
}
.da-brand h1 {
  margin: 0;
  font-size: 1.22rem;
  letter-spacing: -0.01em;
  font-weight: 650;
}
.da-brand h1 .amp { color: var(--accent); }
.da-brand .da-count {
  font-size: 0.78rem;
  color: var(--muted-dim);
  font-variant-numeric: tabular-nums;
}

.da-searchwrap {
  position: relative;
  flex: 1 1 320px;
  min-width: 220px;
}
.da-searchwrap::before {
  content: "⌕";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--muted-dim);
  pointer-events: none;
}
#da-search {
  width: 100%;
  padding: 10px 82px 10px 32px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#da-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#da-search::placeholder { color: var(--muted-dim); }

.da-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  padding: 3px 9px;
  font: inherit;
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.da-search-clear.on { display: block; }
.da-search-clear:hover { color: var(--text); border-color: var(--line-strong); }

/* ---------- Mise en page ---------- */

.da-layout {
  display: grid;
  grid-template-columns: 234px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  padding-top: 16px;
}

/* Meme raison que le `minmax(0, …)` de la colonne : sans cela, la mosaïque
   et la barre d'outils imposent leur largeur de contenu au conteneur. */
.da-main { min-width: 0; }

/* `--head-h` est mesuree en JS : la hauteur de l'en-tete depend du texte et
   du retour a la ligne de la recherche sur ecran etroit. */
.da-side {
  position: sticky;
  top: calc(var(--head-h, 70px) + 12px);
  max-height: calc(100dvh - var(--head-h, 70px) - var(--gl-footer-h, 44px) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}
.da-side::-webkit-scrollbar { width: 8px; }
.da-side::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}

.da-side h2 {
  margin: 0 0 8px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted-dim);
  font-weight: 600;
}
.da-side section + section { margin-top: 20px; }

.da-node { user-select: none; }
.da-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 5px 8px;
  font: inherit;
  font-size: 0.83rem;
  text-align: left;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 7px;
  cursor: pointer;
}
.da-row:hover { background: var(--bg-panel); color: var(--text); }
.da-row.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
/* Personnages > Races / Classes : intitules de groupe, pas des filtres. */
.da-row.da-group .da-label { font-size: .78em; letter-spacing: .06em; text-transform: uppercase; opacity: .75; }
.da-row .da-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.da-row .da-n {
  font-size: 0.72rem;
  color: var(--muted-dim);
  font-variant-numeric: tabular-nums;
}
.da-row.on .da-n { color: var(--accent); }
.da-caret {
  width: 12px;
  flex: none;
  font-size: 0.6rem;
  color: var(--muted-dim);
  transition: transform 0.15s;
}
.da-caret.open { transform: rotate(90deg); }
/* La rangee « Favoris » n'a pas d'enfants a deplier : son chevron sert de
   pastille, et reprend le cœur pose sur les tuiles. */
.da-row[data-fav] .da-caret { color: #ff6b81; font-size: 0.72rem; }
.da-children { display: none; margin-left: 12px; border-left: 1px solid var(--line); padding-left: 4px; }
.da-children.open { display: block; }

.da-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.da-chip {
  padding: 3px 9px;
  font: inherit;
  font-size: 0.73rem;
  color: var(--muted);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.da-chip:hover { color: var(--text); border-color: var(--line-strong); }
.da-chip.on {
  color: #1b1403;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
/* La portee des tags affiches : sans elle, une liste qui change au clic sur
   une categorie passe pour une liste globale qui aurait bouge toute seule. */
.da-scope {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--muted-dim);
  text-transform: none;
  letter-spacing: 0;
}
.da-tags-empty { font-size: 0.75rem; color: var(--muted-dim); margin: 0; }

/* ---------- Barre d'outils ---------- */

.da-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.da-results { font-size: 0.84rem; color: var(--muted); }
.da-results strong { color: var(--text); font-variant-numeric: tabular-nums; }
.da-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.da-select {
  padding: 6px 10px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  cursor: pointer;
}
.da-active-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.da-active {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 10px;
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
}
.da-active button {
  padding: 0 3px;
  font: inherit;
  line-height: 1;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.7;
}
.da-active button:hover { opacity: 1; }

.da-reset {
  padding: 3px 11px;
  font: inherit;
  font-size: 0.75rem;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.da-reset:hover { color: var(--text); border-color: var(--accent); }
.da-reset[hidden] { display: none; }

/* ---------- Grille en mosaïque ----------
   Colonnes reparties en JS plutot qu'en `column-count` : chaque tuile est
   placee dans la colonne la plus courte au moment ou elle arrive, ce qui
   evite au navigateur de tout redistribuer a chaque palier de defilement
   infini — et donc de faire sauter la position de lecture. */

.da-grid {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.da-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 0;
  min-width: 0;
}

.da-tile {
  position: relative;
  overflow: hidden;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
}
.da-tile:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.da-tile.picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
/* La tuile porte le ratio exact de l'image (pose en style inline depuis
   l'index) : la place est reservee avant le chargement — aucun saut de
   mise en page — et l'image est vue en entier, sans recadrage. */
.da-tile img {
  width: 100%;
  height: auto;
  aspect-ratio: var(--ar, 1);
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.25s;
}
.da-tile img.loaded { opacity: 1; }

.da-tile-cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 18px 8px 7px;
  font-size: 0.7rem;
  line-height: 1.3;
  color: #f2f6ff;
  background: linear-gradient(to top, rgba(12, 11, 10, 0.94), rgba(12, 11, 10, 0));
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.da-tile:hover .da-tile-cap { opacity: 1; }

.da-pick {
  position: absolute;
  top: 7px; right: 7px;
  z-index: 2;
  width: 27px; height: 27px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 0.67rem;
  font-weight: 800;
  line-height: 1;
  color: transparent;
  background: rgba(14, 13, 11, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, border-color 0.15s, transform 0.15s;
}
.da-pick::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
}
.da-pick { isolation: isolate; }
.da-pick::before { z-index: -1; }
.da-tile:hover .da-pick, .da-tile.picked .da-pick { opacity: 1; }
.da-pick:hover { border-color: #fff; transform: scale(1.06); }
.da-tile.picked .da-pick {
  color: #1b1403;
  border-color: var(--accent);
}
.da-tile.picked .da-pick::before { background: var(--accent); border-color: var(--accent); }

/* Colonne gauche : favori, puis MagicGrid. Les deux reprennent exactement le
   meme carre exterieur que les controles de selection a droite. */
.da-fav {
  position: absolute;
  z-index: 2;
  top: 7px; left: 7px;
  width: 27px; height: 27px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  color: rgba(255, 107, 129, 0.78);
  background: rgba(14, 13, 11, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}
.da-tile:hover .da-fav { opacity: 1; }
.da-fav:hover { color: #ff6b81; border-color: #ff6b81; opacity: 1 !important; transform: scale(1.06); }
.da-tile.faved .da-fav {
  color: #ff6b81;
  border-color: #ff6b81;
  opacity: 1;
}

/* MagicGrid n'apparait qu'au survol. Le focus clavier le revele lui aussi,
   sinon le lien deviendrait invisible pour qui navigue avec Tab. */
.da-magicgrid {
  position: absolute;
  z-index: 2;
  top: 39px;
  left: 7px;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(14, 13, 11, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}
.da-magicgrid svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.da-magicgrid:hover { color: var(--accent); border-color: var(--accent); opacity: 1; transform: scale(1.06); }
.da-tile:hover .da-magicgrid,
.da-magicgrid:focus-visible { opacity: 1; pointer-events: auto; }
.da-magicgrid:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Troisieme action de la colonne gauche, sous MagicGrid. Comme celle-ci,
   elle n'encombre jamais l'image au repos. */
.da-find-similar {
  position: absolute;
  z-index: 2;
  top: 71px;
  left: 7px;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(14, 13, 11, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}
.da-find-similar svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.da-find-similar:hover { color: #b07a45; border-color: #b07a45; transform: scale(1.06); }
.da-tile:hover .da-find-similar,
.da-find-similar:focus-visible { opacity: 1; pointer-events: auto; }
.da-find-similar:focus-visible { outline: 2px solid #b07a45; outline-offset: 2px; }

/* Vue des favoris : le tri et l'orientation n'ont rien a trier ici — la liste
   a son ordre propre, du plus recemment ajoute au plus ancien. */
.da-toolbar.fav #da-orient,
.da-toolbar.fav #da-sort { display: none; }

.da-fav-note {
  margin: -4px 0 12px;
  font-size: 0.78rem;
  color: var(--muted-dim);
  max-width: 62ch;
}
.da-fav-note[hidden] { display: none; }

/* Le bouton « ♥ Favori » de la visionneuse, allume quand l'image y est. */
#da-lb-fav.on {
  color: #ff6b81;
  border-color: #ff6b81;
}

/* ---------- Accueil : une carte par catégorie ---------- */

.da-home { display: none; }
.da-home.on { display: block; }

.da-home-intro {
  margin: 0 0 22px;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--muted);
  max-width: 62ch;
}
.da-home-intro strong { color: var(--text); }

/* 5 catégories : trois colonnes donnent une rangée de 3 puis de 2, plus
   equilibre qu'une quatrieme colonne qui laisserait un orphelin. */
.da-home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 16px;
}
@media (min-width: 1100px) {
  .da-home-cards { grid-template-columns: repeat(3, 1fr); }
}

.da-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.14s, box-shadow 0.14s;
}
.da-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
}

/* Filmstrip a hauteur fixe plutot qu'une mosaïque en grille : la grille
   recadrait chaque vignette en carre (object-fit: cover) pour remplir sa
   cellule, ce qui coupait la tete ou les pieds des portraits — 85 % du
   fonds. Ici chaque image garde son ratio reel (`width: auto`) ; seul un
   `max-width` evite qu'un paysage tres large (2048×520) ne fasse exploser
   la largeur de la carte. */
.da-card-mosaic {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 3px;
  height: 232px;
  overflow: hidden;
  background: var(--bg);
}
.da-card-mosaic img {
  height: 100%;
  width: auto;
  max-width: 62%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.3s;
}
.da-card-mosaic img.loaded { opacity: 1; }

.da-card-body { padding: 13px 15px 15px; }
.da-card-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}
.da-card-title h3 { margin: 0; font-size: 1rem; font-weight: 620; }
.da-card-title .da-n { font-size: 0.78rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.da-card-subs {
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--muted-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.da-sentinel { height: 1px; }
.da-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted-dim);
  font-size: 0.9rem;
}
.da-empty strong { color: var(--muted); }

/* ---------- Panier ---------- */

.da-cart {
  position: fixed;
  right: 16px;
  bottom: calc(var(--gl-footer-h, 44px) + 14px);
  z-index: 45;
  width: min(340px, calc(100vw - 32px));
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.55);
  transform: translateY(calc(100% + 70px));
  transition: transform 0.22s ease;
}
.da-cart.on { transform: translateY(0); }

.da-cart-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
}
.da-cart-head strong { font-size: 0.87rem; }
.da-cart-head .da-cart-n {
  padding: 1px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #1b1403;
  background: var(--accent);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.da-cart-head .da-cart-toggle {
  margin-left: auto;
  padding: 2px 8px;
  font: inherit;
  font-size: 0.72rem;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: transform 0.18s, color 0.15s;
}
.da-cart-head .da-cart-toggle:hover { color: var(--text); }
.da-cart.folded .da-cart-toggle { transform: rotate(180deg); }

.da-cart-body { max-height: 40vh; overflow-y: auto; padding: 9px; }
.da-cart.folded .da-cart-body, .da-cart.folded .da-cart-foot { display: none; }

.da-cart-items { display: flex; flex-wrap: wrap; gap: 7px; }
.da-cart-item {
  position: relative;
  width: 56px; height: 56px;
  overflow: hidden;
  border-radius: 7px;
  border: 1px solid var(--line);
}
.da-cart-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.da-cart-item button {
  position: absolute;
  inset: 0;
  font: inherit;
  font-size: 0.95rem;
  color: #fff;
  background: rgba(14, 13, 11, 0.72);
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.13s;
}
.da-cart-item:hover button { opacity: 1; }

.da-cart-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border-top: 1px solid var(--line);
}
.da-btn {
  padding: 8px 14px;
  font: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  color: #1b1403;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.15s;
}
.da-btn:hover:not(:disabled) { filter: brightness(1.08); }
.da-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.da-btn-ghost {
  color: var(--muted);
  background: none;
  border: 1px solid var(--line-strong);
}
.da-btn-ghost:hover { color: var(--text); }
.da-cart-hint { font-size: 0.72rem; color: var(--muted-dim); margin-left: auto; text-align: right; }
.da-cart-hint.warn { color: var(--accent); }

/* ---------- Visionneuse ---------- */

.da-lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  background: rgba(10, 9, 8, 0.94);
  backdrop-filter: blur(4px);
}
/* `grid-template-rows` doit etre explicite : sans ligne definie, la rangee se
   dimensionne sur son contenu, la hauteur de la scene depend donc de celle de
   l'image — et le `max-height: 100%` de l'image se resout contre elle-meme.
   Resultat : les images hautes debordaient de l'ecran. `minmax(0, 1fr)` donne
   une rangee bornee par la fenetre, et `min-height: 0` empeche la scene de
   grandir au-dela. */
.da-lightbox.on {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  grid-template-rows: minmax(0, 1fr);
}
@media (max-width: 900px) {
  /* Sur telephone, `auto` donnait au panneau de details toute sa hauteur
     naturelle (prompt + suggestions). La scene n'avait alors plus de place
     dans la fenetre et les images semblaient se meler hors du cadre. Les deux
     zones ont des hauteurs bornees et le panneau du bas defile seul. */
  .da-lightbox.on {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(220px, 52dvh) minmax(0, 1fr);
  }
  .da-lb-side {
    border-top: 1px solid var(--line);
    border-left: 0;
    overscroll-behavior: contain;
  }
}

/* Centrage en flex, pas en grille. Une grille sans `grid-template-rows`
   dimensionne sa rangee implicite sur son contenu : la rangee prenait la
   hauteur naturelle de l'image (1152 px dans une scene de 950 px), et le
   `max-height: 100%` de l'image se resolvait contre cette rangee — donc
   contre elle-meme. En flex, le pourcentage se resout contre la hauteur
   definie du conteneur, et l'image est bornee pour de bon. */
.da-lb-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.da-lb-stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
}
/* Miniature affichée en attendant l'original : même emprise que l'image finale. */
.da-lb-stage img.da-lb-apercu {
  width: 100%;
  height: 100%;
  filter: blur(1.5px);
}
.da-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px; height: 62px;
  font-size: 1.4rem;
  color: var(--text);
  background: rgba(34, 33, 30, 0.8);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.da-lb-nav:hover { background: var(--bg-raised); }
.da-lb-nav:disabled {
  color: var(--muted-dim);
  background: rgba(34, 33, 30, 0.3);
  border-color: rgba(255, 255, 255, 0.07);
  cursor: default;
  opacity: 0.45;
}
.da-lb-nav:disabled:hover { background: rgba(34, 33, 30, 0.3); }
.da-lb-prev { left: 14px; }
.da-lb-next { right: 14px; }

/* Image ouverte par permalien (/i/<id>) : elle n'appartient pas a la grille,
   il n'y a donc ni precedente ni suivante. Des fleches inertes laisseraient
   croire a une panne. */
.da-lightbox.da-lb-solo .da-lb-nav { display: none; }

/* « Dans le meme esprit » — la sortie laterale de la visionneuse. */
.da-similar { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.da-similar h4 {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
/* Grille plutot que rangee defilante : le panneau lateral est etroit, et une
   bande horizontale a faire defiler y serait invisible sur telephone. */
.da-similar-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.da-similar-tile {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 1;
}
.da-similar-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.da-similar-tile:hover { border-color: var(--accent); }
.da-similar-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.da-lb-side {
  overflow-y: auto;
  padding: 18px 20px 24px;
  background: var(--bg-panel);
  border-left: 1px solid var(--line);
  min-height: 0;
}
.da-lb-side h3 { margin: 0 0 12px; font-size: 0.95rem; line-height: 1.4; }
.da-lb-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 34px; height: 34px;
  font-size: 1.15rem;
  color: var(--text);
  background: rgba(34, 33, 30, 0.85);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  z-index: 2;
}
.da-meta { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 0.77rem; margin-bottom: 14px; }
.da-meta dt { color: var(--muted-dim); }
.da-meta dd { margin: 0; color: var(--text); word-break: break-word; font-variant-numeric: tabular-nums; }
.da-prompt {
  margin: 0 0 14px;
  padding: 10px 12px;
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.da-lb-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Divers ---------- */

.da-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--gl-footer-h, 44px) + 18px);
  transform: translate(-50%, 22px);
  z-index: 120;
  padding: 10px 18px;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.da-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Dialogues publics ---------- */
.da-dialog {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 9, 8, 0.78);
  backdrop-filter: blur(4px);
}
.da-dialog-box {
  width: min(460px, 100%);
  padding: 22px;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.58);
}
.da-dialog h2 { margin: 0 0 10px; font-size: 1.08rem; }
.da-dialog-body { margin: 0 0 20px; color: var(--muted); font-size: 0.88rem; line-height: 1.55; }
.da-dialog-field { display: block; margin: -4px 0 8px; }
.da-dialog-field span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.76rem; }
.da-dialog-field input {
  width: 100%;
  padding: 9px 10px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font: inherit;
  font-size: 0.8rem;
}
.da-dialog-field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.da-dialog-status { min-height: 1.2em; margin: 0 0 8px; color: var(--accent); font-size: 0.74rem; }
.da-dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 4px; }
.da-btn-danger { color: #fff; background: #b83b4b; }
.da-btn-danger:hover:not(:disabled) { filter: brightness(1.14); }

.da-loading { padding: 70px 20px; text-align: center; color: var(--muted); font-size: 0.9rem; }

/* ---------- Bouton hamburger ---------- */

.da-burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 38px;
  height: 34px;
  padding: 0 8px;
  flex: none;
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
}
.da-burger span {
  display: block;
  height: 2px;
  background: var(--muted);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.15s;
}
.da-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.da-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.da-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.da-backdrop {
  position: fixed;
  inset: 0;
  z-index: 34;
  background: rgba(12, 11, 10, 0.66);
  backdrop-filter: blur(2px);
}
.da-backdrop[hidden] { display: none; }

/* ---------- Mobile ----------
   Le panneau devient un tiroir hors-champ. Empile en pleine largeur, il
   occupait 711 px avant la premiere image sur un ecran de 847 : presque un
   ecran entier de categories avant de voir une seule illustration. */

@media (max-width: 860px) {
  .da-burger { display: flex; }
  /* `minmax(0, 1fr)` et non `1fr` : un element de grille a `min-width: auto`
     et refuse de descendre sous la largeur de son contenu. La colonne prenait
     483 px dans un conteneur de 362, et la mosaïque debordait a droite. */
  .da-layout { grid-template-columns: minmax(0, 1fr); }
  .da-brand { flex: 1; min-width: 0; }
  .da-brand h1 { font-size: 1.05rem; }
  .da-searchwrap { flex-basis: 100%; order: 3; }

  .da-side {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 35;
    width: min(300px, 84vw);
    max-height: none;
    padding: 18px 14px calc(var(--gl-footer-h, 44px) + 18px);
    background: var(--bg-panel);
    border-right: 1px solid var(--line-strong);
    box-shadow: 8px 0 34px rgba(0, 0, 0, 0.5);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
  }
  .da-side.open { transform: translateX(0); }

  .da-toolbar { gap: 8px; }
  .da-tools { width: 100%; margin-left: 0; }
  .da-tools .da-select { flex: 1; min-width: 0; }
  .da-cart { right: 10px; left: 10px; width: auto; }
}

/* Le tiroir n'a pas lieu d'etre au-dela : le panneau reprend sa colonne. */
@media (min-width: 861px) {
  .da-side.open { transform: none; }
  .da-backdrop { display: none; }
}

/* =========================================================
   MODE ADMIN
   Greffe sur le catalogue public : aucune de ces regles ne
   s'applique tant que js/admin-catalog.js n'a pas valide un
   jeton (il pose alors .admin-mode sur <body>).
   ========================================================= */

/* =========================================================
   Propre à Taillepierre
   ========================================================= */

/* Petite étiquette sur la vignette : nombre de pièces de la slab. */
.da-tile-pieces {
  position: absolute; right: 8px; top: 8px; z-index: 2;
  padding: 2px 7px; border-radius: 999px;
  background: rgba(14, 13, 11, 0.72); color: var(--text);
  font-size: 0.7rem; font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* Raccourci vers l'atelier : même place et même rôle que MagicGrid. */
.da-atelier { color: var(--text); }
.da-atelier:hover { color: var(--bronze); border-color: var(--bronze); }

/* Bascule Image / Plan dans la visionneuse. */
.da-lb-views {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 3;
  display: flex; gap: 2px; padding: 3px; border-radius: 999px;
  background: rgba(14, 13, 11, 0.8); border: 1px solid var(--line-strong);
}
.da-lb-views[hidden] { display: none; }
.da-lb-views button {
  border: 0; background: none; color: var(--muted); font: inherit; font-size: 0.78rem;
  padding: 5px 14px; border-radius: 999px; cursor: pointer;
}
.da-lb-views button.on { background: var(--accent-soft); color: var(--accent); }

.da-lb-desc { font-size: 0.82rem; color: var(--muted); line-height: 1.55; margin: 0 0 14px; }
.da-lb-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 14px; }
.da-code-info { font-size: 0.74rem; color: var(--muted-dim); margin: -6px 0 14px; }
.da-code-info.warn { color: #e0652b; }
.da-brand h1 { letter-spacing: 0.01em; }
.da-tools .da-count { font-size: 0.78rem; color: var(--muted); }
.da-tools input[type="range"] { accent-color: var(--accent); width: 110px; }
a.da-btn { text-decoration: none; display: inline-flex; align-items: center; }
