:root {
  /* palette mariage sobre : noir chaud, ivoire, champagne */
  --bg: #14110e;
  --bg-raised: #201b16;
  --fg: #ece6da;
  --fg-dim: #a89e8e;
  --accent: #d6b98c;
  --danger: #e07a5f;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  /* un cliquer-glisser sur la grille déclenche la sélection DOM native :
     voile bleu sur toutes les vignettes, déroutant pour un invité */
  user-select: none;
}

input, select { user-select: text; }

.hidden { display: none !important; }

/* ---------------------------------------------------------------- login */

.login {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.login-box {
  text-align: center;
  display: flex; flex-direction: column; gap: .8rem;
  min-width: 260px;
}
.login-box h1 { margin: 0; font-weight: 400; letter-spacing: .06em; font-family: var(--serif); font-size: 2rem; }
.login-box p { margin: 0; color: var(--fg-dim); }
.login-box input, .login-box button {
  padding: .6rem .9rem;
  border-radius: 6px;
  border: 1px solid #3a332a;
  background: var(--bg-raised);
  color: var(--fg);
  font-size: 1rem;
}
.login-box button { cursor: pointer; background: var(--accent); color: #111; border: 0; }
.error { color: var(--danger); }

/* --------------------------------------------------------------- header */

header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #2b241c;
  padding: .5rem 1rem;
}
.head-row {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
header h1 { margin: 0; font-size: 1.15rem; font-weight: 400; letter-spacing: .05em; font-family: var(--serif); }
#filters { display: flex; gap: .25rem; }
#filters button, .head-actions button, .select-bar button, .select-bar select {
  background: none;
  border: 1px solid transparent;
  color: var(--fg-dim);
  padding: .35rem .7rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: .9rem;
}
#filters button:hover, .head-actions button:hover { color: var(--fg); }
#filters button.active { color: var(--fg); border-color: var(--accent); }
.head-actions { margin-left: auto; }
.head-actions button.active { color: #111; background: var(--accent); }

.select-bar {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  padding: .5rem 0 .2rem;
  color: var(--fg-dim);
}
.select-bar select {
  border: 1px solid #3a332a; background: var(--bg-raised); color: var(--fg);
  border-radius: 6px;
}
.select-bar button { border: 1px solid #3a332a; border-radius: 6px; }
.select-bar button.primary {
  background: var(--accent); color: #111; border: 0;
}
.select-bar button:disabled { opacity: .4; cursor: default; }

/* ----------------------------------------------------------------- grid */

main {
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
}
.day-header {
  margin: 1.6rem 0 .6rem;
  font-size: 1rem;
  font-weight: 400;
  font-family: var(--serif);
  font-style: italic;
  color: var(--fg-dim);
  text-transform: capitalize;
}
.day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}
.cell {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg-raised);
  cursor: pointer;
  padding: 0; border: 0;
}
.cell img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;                     /* fondu à l'arrivée : pas de pop brutal */
  transition: opacity .3s ease, transform .15s ease;
}
.cell img.loaded { opacity: 1; }
.cell:hover img { transform: scale(1.03); }
.badge {
  position: absolute; top: 6px; left: 6px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: .72rem;
  padding: .1rem .45rem;
  border-radius: 999px;
  pointer-events: none;
}
.badge-vote { top: auto; bottom: 6px; background: rgba(146, 44, 34, .82); }
#lb-vote.active { background: var(--danger); border-color: var(--danger); color: #111; }

.cell .check {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.8);
  background: rgba(0,0,0,.35);
  display: none;
  align-items: center; justify-content: center;
  color: #111; font-size: .8rem; font-weight: 700;
}
body.selecting .cell .check { display: flex; }
.cell.selected .check { background: var(--accent); border-color: var(--accent); }
.cell.selected img { outline: 3px solid var(--accent); outline-offset: -3px; }

.status { text-align: center; color: var(--fg-dim); padding: 2rem 0; }

/* ------------------------------------------------------------- lightbox */

.lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(8,8,9,.97);
  display: flex; flex-direction: column;
}
#lb-stage {
  flex: 1; margin: 0;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
  padding: .5rem;
}
#lb-stage img, #lb-stage video {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  border-radius: 3px;
  transition: opacity .22s ease;   /* fondu du noir vers l'image */
}
#lb-stage .fade-in { opacity: 0; }
#lb-stage img { cursor: zoom-in; }
#lb-stage:fullscreen { background: #000; padding: 0; }
#lb-stage:fullscreen img { cursor: zoom-out; border-radius: 0; }
.lb-btn {
  position: absolute; z-index: 51;
  background: rgba(0,0,0,.4);
  border: 0; color: #ddd;
  font-size: 1.6rem;
  width: 44px; height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lb-btn:hover { background: rgba(255,255,255,.15); }
.lb-close { top: 12px; right: 12px; font-size: 1.1rem; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lb-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1rem;
  color: var(--fg-dim);
  font-size: .9rem;
}
.lb-controls { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.lb-bar button, .lb-bar select, .lb-bar a {
  background: var(--bg-raised);
  border: 1px solid #3a332a;
  color: var(--fg);
  padding: .3rem .7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .85rem;
  text-decoration: none;
}
.lb-bar button.active { background: var(--accent); color: #111; border-color: var(--accent); }
.lb-download { display: flex; gap: .4rem; }

/* ------------------------------------------------------------ inspecteur */

.inspector {
  position: fixed; inset: 0; z-index: 60;   /* au-dessus de la lightbox */
  background: rgba(8, 8, 9, .98);
  display: flex; flex-direction: column;
  gap: .4rem;
  padding: .5rem;
}
.insp-main {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
.insp-main img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  border-radius: 3px;
}
.insp-bar {
  display: flex; align-items: center; gap: .6rem;
  padding: 0 .5rem;
  color: var(--fg-dim);
  font-size: .9rem;
}
.insp-bar input[type="range"] { flex: 1; accent-color: var(--accent); }
.insp-bar input[type="number"] {
  width: 5.5rem;
  background: var(--bg-raised); color: var(--fg);
  border: 1px solid #3a332a; border-radius: 6px;
  padding: .25rem .5rem;
}
.insp-bar button {
  background: var(--bg-raised); color: var(--fg);
  border: 1px solid #3a332a; border-radius: 6px;
  width: 34px; height: 30px; cursor: pointer;
}
.insp-bar button.active { background: var(--accent); border-color: var(--accent); color: #111; }
.spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(17, 17, 17, .25);
  border-top-color: #111;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#insp-pos { min-width: 15rem; text-align: center; font-variant-numeric: tabular-nums; }
.insp-strip {
  display: flex; gap: 3px;
  overflow-x: auto;
  padding: 2px .5rem;
  min-height: 66px;
}
.insp-thumb {
  height: 60px; aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 3px;
  background: var(--bg-raised);
  cursor: pointer;
  flex: none;
  opacity: .75;
}
.insp-thumb:hover { opacity: 1; }
.insp-thumb.current { outline: 2px solid var(--accent); opacity: 1; }
.insp-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 0 .5rem .2rem;
  color: var(--fg-dim); font-size: .85rem;
}
.insp-buttons { display: flex; gap: .4rem; flex-wrap: wrap; }
.insp-actions a, .insp-actions button {
  background: var(--bg-raised); color: var(--fg);
  border: 1px solid #3a332a; border-radius: 6px;
  padding: .3rem .7rem; cursor: pointer;
  font-size: .85rem; text-decoration: none;
}
#insp-zip { background: var(--accent); color: #111; border: 0; }

@media (max-width: 600px) {
  .day-grid { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 3px; }
  .lb-prev, .lb-next { display: none; }  /* swipe au tactile */
  #insp-pos { min-width: 0; }
}
