:root {
  color-scheme: light;
  --fond: #f4f3f0;
  --surface: #ffffff;
  --surface-2: #eceae5;
  --texte: #1d1c1a;
  --texte-2: #68655f;
  --bord: #dcd9d2;
  --accent: #2f5d50;
  --accent-texte: #ffffff;
  --damier: #e6e4df;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --fond: #171716;
    --surface: #201f1e;
    --surface-2: #2b2a28;
    --texte: #eeece7;
    --texte-2: #a19e96;
    --bord: #363431;
    --accent: #8cc2b0;
    --accent-texte: #14231e;
    --damier: #2b2a28;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button, input { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.invisible {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.entete {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--bord);
}

.marque {
  color: var(--texte);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.marque span { color: var(--texte-2); font-weight: 400; }

.stats { margin: 0 0 0 auto; color: var(--texte-2); font-size: 13px; text-align: right; }

.connexion {
  flex: none;
  padding: 6px 12px;
  border: 1px solid var(--bord);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.connexion:hover { background: var(--surface-2); }

.page {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  max-width: 1500px;
  margin: 0 auto;
}

.categories {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
  padding: 24px 16px 24px 24px;
}

.categories h2 {
  margin: 0 0 8px;
  padding: 0 10px;
  color: var(--texte-2);
  font-size: 12px;
  font-weight: 600;
}

.categories ul { margin: 0; padding: 0; list-style: none; }

.categories button {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  text-align: left;
  cursor: pointer;
}

.categories button:hover { background: var(--surface-2); }

.categories button[aria-current="true"] {
  background: var(--surface-2);
  font-weight: 600;
}

.categories .compte { color: var(--texte-2); font-size: 13px; font-weight: 400; }

main { min-width: 0; padding: 24px; }

.barre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.barre h1 { margin: 0; font-size: 22px; line-height: 1.2; overflow-wrap: anywhere; }

.recherche { flex: 0 1 300px; }

input[type="search"], input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--bord);
  border-radius: 6px;
  background: var(--surface);
}

.message { color: var(--texte-2); }

.grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.carte {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--bord);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.carte:hover { border-color: var(--texte-2); }

.vignette {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 16px;
  background: repeating-conic-gradient(var(--damier) 0 25%, transparent 0 50%) 0 0 / 16px 16px;
}

.vignette img { max-width: 100%; max-height: 100%; object-fit: contain; }

.carte-nom {
  display: block;
  padding: 8px 10px 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.carte-taille {
  display: block;
  padding: 0 10px 8px;
  color: var(--texte-2);
  font-size: 12px;
}

.apercu {
  width: min(760px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--bord);
  border-radius: 10px;
  background: var(--surface);
  color: var(--texte);
}

.apercu::backdrop { background: rgb(0 0 0 / 0.55); }

.apercu-image {
  display: grid;
  place-items: center;
  height: min(46vh, 380px);
  padding: 20px;
  background: repeating-conic-gradient(var(--damier) 0 25%, transparent 0 50%) 0 0 / 20px 20px;
}

.apercu-image img { max-width: 100%; max-height: 100%; object-fit: contain; }

.apercu-infos { padding: 18px 20px 20px; }

.apercu-infos h2 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }

.apercu-infos p { margin: 2px 0 14px; color: var(--texte-2); font-size: 13px; }

.apercu-infos label span {
  display: block;
  margin-bottom: 4px;
  color: var(--texte-2);
  font-size: 13px;
}

.dialogue-court { width: min(420px, calc(100vw - 32px)); }

.dialogue-court h2 { margin-bottom: 14px; }

.dialogue-court label { display: block; margin-bottom: 12px; }

input[type="password"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--bord);
  border-radius: 6px;
  background: var(--surface);
}

.apercu-infos .erreur-formulaire { margin: 8px 0 0; color: #b3402f; }

.erreur-formulaire:empty { display: none; }

@media (prefers-color-scheme: dark) {
  .apercu-infos .erreur-formulaire { color: #eb9a8c; }
}

.apercu-actions { display: flex; gap: 8px; margin-top: 14px; }

.apercu-actions button {
  padding: 8px 14px;
  border: 1px solid var(--bord);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.apercu-actions button:hover { background: var(--surface-2); }

.apercu-actions .principal {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-texte);
  font-weight: 600;
}

.apercu-actions .principal:hover { background: var(--accent); opacity: 0.88; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 10;
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--texte);
  color: var(--fond);
  font-size: 14px;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 0.15s;
  pointer-events: none;
}

.toast.visible { opacity: 1; }

.erreur {
  display: grid;
  place-content: center;
  min-height: 100vh;
  padding: 16px;
  text-align: center;
}

.erreur h1 { margin: 0 0 4px; font-size: 22px; }

.erreur p { margin: 0 0 12px; color: var(--texte-2); }

.erreur a { color: var(--accent); }

@media (max-width: 760px) {
  .entete { padding: 14px 16px; }

  .page { grid-template-columns: minmax(0, 1fr); }

  .categories {
    position: static;
    max-height: none;
    padding: 12px 16px 0;
    overflow-x: auto;
  }

  .categories h2 { display: none; }

  .categories ul { display: flex; gap: 6px; }

  .categories button { white-space: nowrap; }

  main { padding: 16px; }

  .barre { align-items: stretch; flex-direction: column; gap: 10px; }

  .recherche { flex: none; }

  .grille { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
