:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --ink: #151515;
  --muted: #706f69;
  --line: #ddd7c9;
  --surface: #fffdf8;
  --accent: #b91c1c;
  --accent-ink: #ffffff;
  --focus: #0f766e;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--ink);
  color: white;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.button-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  border-radius: 6px;
  padding: 0 16px;
  border: 1px solid var(--line);
  text-decoration: none;
}

button.secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

a {
  color: inherit;
}

.user-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.logout-link {
  min-height: auto;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-decoration: underline;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(14px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 88%, white);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: grid;
  gap: 2px;
  width: 100%;
  text-align: center;
}

.brand strong {
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  letter-spacing: 0;
  text-transform: uppercase;

}

.brand span {
  color: var(--muted);
  font-size: 0.86rem;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(4px, 1.2vw, 14px);
  padding: clamp(4px, 1.2vw, 14px);
}

.active-filter {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  margin: 12px clamp(4px, 1.2vw, 14px) 0;
  border-radius: 999px;
  padding: 7px 10px 7px 14px;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.filter-clear {
  min-height: 28px;
  width: 28px;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 999px;
  padding: 0;
  background: transparent;
  color: white;
  line-height: 1;
}

@media (min-width: 900px) and (orientation: landscape) {
  .gallery {
    grid-template-columns: repeat(3, minmax(0, calc(100vw / 9)));
    justify-content: center;
  }
}

.tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  width: 100%;
  border: 0;
  padding: 0;
  overflow: hidden;
  background: #e8e1d3;
  color: white;
  cursor: zoom-in;
}

.tile.is-new {
  outline: 4px solid var(--accent);
  outline-offset: -4px;
}

.tile img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.tile-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 10px 10px;
  background: linear-gradient(transparent, rgb(0 0 0 / 0.68));
  font-size: clamp(0.78rem, 2.2vw, 1rem);
  overflow-wrap: anywhere;
}

.new-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.delete-button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  padding: 6px;
  border: 0;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.6);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.delete-button svg {
  display: block;
  width: 16px;
  height: 16px;
}

.delete-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 40%, transparent);
  outline-offset: 2px;
}

.gone-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  min-height: 0;
  border: 0;
  max-width: calc(100% - 16px);
  border-radius: 999px;
  padding: 6px 9px;
  background: rgb(0 0 0 / 0.78);
  color: white;
  font-size: clamp(0.7rem, 2vw, 0.9rem);
  font-weight: 800;
  text-transform: uppercase;
}

.gone-badge.is-clickable {
  cursor: pointer;
}

.gone-badge.is-clickable:disabled {
  cursor: wait;
}

.wall-heart {
  position: absolute;
  right: 8px;
  bottom: 8px;
  color: #dc2626;
  font-size: 1.25rem;
  line-height: 1;
  -webkit-text-stroke: 2px white;
  paint-order: stroke fill;
  text-shadow: 0 2px 8px rgb(0 0 0 / 0.45);
}

.heart-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgb(255 255 255 / 0.92);
  color: var(--ink);
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.18);
}

.heart-button:disabled {
  cursor: default;
  opacity: 1;
}

.heart-icon {
  color: #dc2626;
  font-size: 1rem;
}

.heart-count {
  min-width: 1ch;
  font-size: 0.82rem;
}

.lightbox-heart {
  position: static;
  justify-self: center;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(44px, 72px) minmax(0, 1fr) minmax(44px, 72px);
  grid-template-rows: minmax(0, 1fr);
  align-items: center;
  gap: clamp(10px, 2vw, 24px);
  padding: clamp(14px, 4vw, 42px);
  height: 100vh;
  height: 100dvh;
  background: rgb(0 0 0 / 0.9);
  touch-action: pan-y;
}

.lightbox-figure {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto auto;
  gap: 12px;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  justify-items: center;
}

.lightbox img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox figcaption {
  max-width: min(720px, 100%);
  color: white;
  text-align: center;
  overflow-wrap: anywhere;
}

.lightbox-close {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 21;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 999px;
  background: rgb(0 0 0 / 0.45);
  color: white;
  font-size: 1.9rem;
  line-height: 1;
}

.lightbox-nav {
  grid-row: 1;
  z-index: 21;
  display: none;
  width: 54px;
  min-height: 72px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 0.28);
  border-radius: 999px;
  background: rgb(0 0 0 / 0.42);
  color: white;
  font-size: 3rem;
  line-height: 1;
}

.lightbox-nav-prev {
  grid-column: 1;
  justify-self: end;
}

.lightbox-nav-next {
  grid-column: 3;
  justify-self: start;
}

@media (hover: hover) and (pointer: fine) {
  .lightbox-nav:not([hidden]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .lightbox-nav:hover,
  .lightbox-close:hover {
    background: rgb(0 0 0 / 0.65);
  }
}

.empty,
.admin-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 18px;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.panel {
  display: grid;
  gap: 18px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel h1,
.panel h2,
.panel p {
  margin: 0;
}

.panel p {
  color: var(--muted);
  line-height: 1.5;
}

.admin-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.92rem;
}

.tag-input-shell {
  position: relative;
}

.tag-input-shell input[type="text"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
}

.selected-tags,
.lightbox-tags,
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tag-chip {
  display: inline-flex;
  min-height: auto;
  align-items: center;
  gap: 6px;
  border: 0;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.08);
  color: var(--ink);
  font-size: 0.88rem;
}

.tag-chip-remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  padding: 0;
  line-height: 1;
}

.tag-suggestions,
.latest-tags {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.tag-suggestion,
.tag-list-item {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.tag-suggestion:hover,
.tag-list-item:hover,
.tag-chip-remove:hover {
  border-color: var(--focus);
}

.tag-list-title {
  color: var(--muted);
  font-size: 0.87rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lightbox-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.lightbox-tag {
  background: rgb(255 255 255 / 0.16);
  border: 1px solid rgb(255 255 255 / 0.32);
  color: white;
  cursor: pointer;
}

.lightbox-tag:hover {
  background: rgb(255 255 255 / 0.25);
}

.lightbox-admin-tags {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.lightbox-admin-tags-header {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: white;
}

.lightbox-tags-editor {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 24;
  width: min(92vw, 560px);
  max-height: min(78vh, 640px);
  overflow: auto;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  box-shadow: 0 18px 70px rgb(0 0 0 / 0.45);
}

.lightbox-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.check-field {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.check-field input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.check-field.compact {
  min-height: 32px;
}

input:focus-visible,
button:focus-visible,
.tile:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 40%, transparent);
  outline-offset: 2px;
}

.preview {
  display: none;
  width: min(100%, 360px);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.status {
  min-height: 22px;
  color: var(--muted);
}

.status.error {
  color: var(--accent);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 560px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .gallery {
    gap: 3px;
    padding: 3px;
  }

  .tile.is-new {
    outline-width: 3px;
  }

  .tile-title {
    padding: 24px 7px 7px;
  }

  .lightbox {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .lightbox-figure {
    grid-column: 1;
  }
}

/* Styles pour la modal de confirmation */
.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
}

.confirm-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 0.6);
}

.confirm-modal-panel {
  position: relative;
  z-index: 41;
  width: min(520px, 92%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.4);
}

.confirm-modal-panel h2 {
  margin: 0 0 8px 0;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.confirm-actions .secondary {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Affichage du numéro de version en haut à droite, rotation 90° collée à l'écran */
#version-badge-shell {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1000;
  display: block;
  padding: 12px 0 0 0;
  pointer-events: none;
}

#version-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: rgba(0, 0, 0, 0.22);
  writing-mode: vertical-rl;
  text-orientation: upright;
  background: rgba(255, 255, 255, 0.68);
  padding: 4px 8px;
  pointer-events: none;
  user-select: none;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 0 0 0 12px;
  opacity: 0.75;
}

@media (prefers-reduced-motion: reduce) {
  #version-badge {
    transition: none;
  }
}
