:root {
  --bg: #faf6f0;
  --card: #ffffff;
  --text: #2f2a25;
  --muted: #7b7168;
  --line: #e8e0d5;
  --accent: #9a7b4f;
  --accent-dark: #7d6240;
  --accent-soft: #f3ece1;
  --ok: #4f7a55;
  --error: #b0463c;
  --radius: 16px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.page { max-width: 640px; margin: 0 auto; padding: 32px 16px 64px; }
.page.wide { max-width: 1200px; }

.hero { text-align: center; margin: 16px 0 32px; }
.ornament { width: 120px; height: 24px; fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
h1 { font: 400 clamp(2.2rem, 8vw, 3.4rem)/1.1 var(--serif); margin: 12px 0 8px; letter-spacing: .01em; }
h2 { font: 400 1.6rem/1.2 var(--serif); margin: 0 0 8px; }
.subtitle { color: var(--muted); font-size: 1.05rem; margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(60, 40, 20, .04);
}
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: .875rem; }
.center { text-align: center; }
.closed-card h2 { margin-top: 0; }
.closed-card p { margin-bottom: 0; }
.closes-info { text-align: center; margin: 0 0 12px; font-size: .95rem; color: var(--muted); }
.error { color: var(--error); margin: 0; min-height: 1.5em; }

label { font-weight: 600; }
input[type="text"], input:not([type]), input[type="password"], input[type="datetime-local"] {
  font: inherit;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
input:focus-visible, button:focus-visible, .button:focus-visible, .drop:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button, button {
  font: 600 1rem var(--sans);
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.button:hover, button:hover { background: var(--accent-dark); }
.button.secondary, button.secondary { background: var(--accent-soft); color: var(--accent-dark); }
.button.secondary:hover, button.secondary:hover { background: #ebe0cf; }
button.danger { background: #f6e3e0; color: var(--error); }
button.danger:hover { background: #f0d2cd; }
button.small, .button.small { padding: 6px 14px; font-size: .875rem; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.drop {
  margin-top: 8px;
  border: 2px dashed #d8c9b3;
  border-radius: var(--radius);
  background: var(--accent-soft);
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.drop.locked { opacity: .55; }
#guest-error:empty { display: none; }
.drop:hover, .drop.over { background: #efe4d3; border-color: var(--accent); }
.drop svg { width: 40px; height: 40px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.drop-title { font: 400 1.35rem var(--serif); color: var(--text); }
.drop .muted { font-weight: 400; font-size: .9rem; }
.tip { margin: 0; text-align: center; line-height: 1.45; }

.resume { border-color: #e6c98f; background: #fdf6e7; display: flex; flex-direction: column; gap: 10px; }
.resume p { margin: 0; line-height: 1.45; }
.resume-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.resume-list li { display: flex; justify-content: space-between; gap: 12px; }
.resume-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.resume-list .muted { white-space: nowrap; }
.summary-line { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.summary.done { border-color: #c9dccb; background: #f3f8f3; }
.summary p { margin: 8px 0 0; }

.bar { height: 6px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.done .bar > div, .item.done .bar > div { background: var(--ok); }

.queue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
}
.thumb {
  width: 56px; height: 56px; border-radius: 8px; background: var(--accent-soft);
  object-fit: cover; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.thumb svg { width: 24px; height: 24px; fill: none; stroke: var(--accent); stroke-width: 1.8; }
.item-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; }
.item-status { font-size: .85rem; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item.done .item-status { color: var(--ok); }
.item.failed .item-status { color: var(--error); }
.item.removed { opacity: .6; }
.item.removed .item-name { text-decoration: line-through; }
.item.removed .bar { visibility: hidden; }

/* --- Galerie des mariés --- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
select {
  font: inherit; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--text);
}
.stats { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.stat strong { display: block; font: 400 1.6rem/1.2 var(--serif); }
.stat span { color: var(--muted); font-size: .85rem; }
.link-box { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link-box code {
  flex: 1 1 260px; min-width: 0; background: var(--accent-soft); padding: 8px 12px; border-radius: 8px;
  overflow-wrap: anywhere; font-size: .875rem;
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.tile {
  position: relative; aspect-ratio: 1; padding: 0; border-radius: 10px; overflow: hidden;
  background: var(--accent-soft); border: 0; cursor: pointer; display: block; width: 100%;
}
.tile:hover { background: var(--accent-soft); }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .badge {
  position: absolute; left: 6px; bottom: 6px; right: 6px; display: flex; justify-content: space-between; gap: 4px;
  font: 500 .75rem var(--sans); color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); pointer-events: none;
}
.tile .badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 44px; height: 44px;
  border-radius: 50%; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.tile .play svg { width: 18px; height: 18px; fill: #fff; margin-left: 3px; }
.tile .fallback { color: var(--muted); font-size: .8rem; padding: 8px; display: flex; height: 100%; align-items: center; justify-content: center; text-align: center; overflow-wrap: anywhere; }

dialog.viewer {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: rgba(20, 16, 12, .96); color: #fff;
}
dialog.viewer::backdrop { background: rgba(20, 16, 12, .96); }
.viewer-inner { display: grid; grid-template-rows: auto 1fr auto; height: 100%; }
.viewer-top, .viewer-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; flex-wrap: wrap; }
.viewer-body { display: grid; grid-template-columns: 1fr; min-height: 0; position: relative; }
.viewer-body.with-details { grid-template-columns: 1fr 300px; }
.viewer-media { display: flex; align-items: center; justify-content: center; min-height: 0; min-width: 0; position: relative; }
.viewer-details {
  display: none; overflow-y: auto; padding: 4px 16px 16px; border-left: 1px solid rgba(255,255,255,.12);
  font-size: .875rem; color: #d9d0c5;
}
.viewer-body.with-details .viewer-details { display: block; }
.viewer-details h3 { margin: 16px 0 6px; font: 600 .75rem/1.2 var(--sans, inherit); letter-spacing: .06em; text-transform: uppercase; color: #a89c8e; }
.viewer-details dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.viewer-details dt { color: #a89c8e; }
.viewer-details dd { margin: 0; color: #fff; overflow-wrap: anywhere; }
.viewer-details a { color: #f0d9b5; }
.viewer-details .muted { color: #a89c8e; }
/* Téléphone : le panneau passe par-dessus le bas de l'image */
@media (max-width: 760px) {
  .viewer-body.with-details { grid-template-columns: 1fr; }
  .viewer-details {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 55%;
    background: rgba(20, 16, 12, .94); border-left: 0; border-top: 1px solid rgba(255,255,255,.15);
  }
}
.viewer-media img, .viewer-media video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-media .nav {
  position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); color: #fff;
  width: 44px; height: 44px; padding: 0; font-size: 1.4rem;
}
.viewer-media .nav:hover { background: rgba(255,255,255,.25); }
.viewer-media .prev { left: 12px; }
.viewer-media .next { right: 12px; }
.viewer .info { font-size: .875rem; color: #d9d0c5; }
.viewer .info strong { color: #fff; }
.viewer button.secondary, .viewer .button.secondary { background: rgba(255,255,255,.12); color: #fff; }
.viewer button.secondary:hover, .viewer .button.secondary:hover { background: rgba(255,255,255,.25); }

/* Tags dans la visionneuse : un bouton par tag, allumé s'il est attribué */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 500 .8125rem var(--sans); padding: 5px 11px; border-radius: 999px;
  background: rgba(255,255,255,.1); color: #d9d0c5; border: 1px solid rgba(255,255,255,.18);
}
.chip:hover { background: rgba(255,255,255,.2); }
.chip[aria-pressed="true"] { background: #f0d9b5; color: #2f2a25; border-color: #f0d9b5; }
.chip[aria-pressed="true"]::before { content: "✓ "; }
.tag-new { display: flex; gap: 6px; margin-top: 8px; }
.viewer .tag-new input {
  flex: 1; min-width: 0; padding: 6px 10px; font-size: .8125rem;
  background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.18); border-radius: 999px;
}
.viewer .tag-new input::placeholder { color: #a89c8e; }
.viewer-details .error { color: #f2a59b; font-size: .8125rem; min-height: 0; margin-top: 4px; }

/* Fenêtre des tags */
dialog.tags-dialog {
  width: min(520px, calc(100% - 32px)); max-height: calc(100dvh - 48px); padding: 20px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text);
  box-shadow: 0 12px 40px rgba(60, 40, 20, .25);
}
dialog.tags-dialog::backdrop { background: rgba(47, 42, 37, .45); }
.tags-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.tags-head h2 { margin: 0; font: 400 1.4rem var(--serif); }
.tags-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 50dvh; overflow-y: auto; }
.tag-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.tag-row:last-child { border-bottom: 0; }
.tag-row .tag-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tag-row input[type="text"] { padding: 6px 10px; }
.tag-row label { display: flex; align-items: center; gap: 10px; flex: 1; font-weight: 500; cursor: pointer; }
.tag-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.tags-dialog .link-box input { flex: 1 1 200px; width: auto; min-width: 0; padding: 8px 12px; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* Vue d'ensemble : statistiques et stockage à gauche, lien des invités à droite */
.overview { display: grid; gap: 0 16px; }
@media (min-width: 900px) { .overview { grid-template-columns: 3fr 2fr; } }

.uploads-state { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.uploads-state p { margin: 0; line-height: 1.45; }
.uploads-state .storage-line { width: 100%; margin-bottom: 0; }
.uploads-state .schedule { width: 100%; gap: 6px; }
.uploads-state input[type="datetime-local"] { flex: 1 1 200px; width: auto; min-width: 0; padding: 8px 10px; }
#uploads-error:empty { display: none; }
.state-pill { font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: #e3efe4; color: #2f6b3a; }
.state-pill.closed { background: #f6e0dc; color: #9b3b2e; }
.state-pill.scheduled { background: #fbeccd; color: #8a5a12; }
.state-pill.paused { background: #e4e6f3; color: #3c4a8a; }
.storage { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.storage-line { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.storage p { margin: 8px 0 0; }
.storage-bar { display: flex; height: 10px; }
.storage-bar > .used { background: var(--ok); }
.storage-bar > .reserved { background: #b9cfbb; }
.storage-bar.warn > .used { background: #c98a2e; }
.storage-bar.warn > .reserved { background: #e8cfa6; }
.storage-bar.full > .used { background: var(--error); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; }
.filters input[type="search"] {
  flex: 1 1 260px; font: inherit; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--text); background: #fff;
}
.filters select { flex: 0 1 auto; }

.dup-banner p { margin: 0; flex: 1 1 320px; line-height: 1.5; }
.tile .badge .dup-keep { font-weight: 700; }
.guest-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: var(--accent-soft); }

button:disabled, button:disabled:hover { opacity: .45; cursor: default; }

/* Sélection multiple */
.tile .check {
  position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(0,0,0,.25); display: none; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.4); pointer-events: none;
}
.tile .check svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.grid.selecting .tile .check { display: flex; }
.tile.selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile.selected img, .tile.selected video { opacity: .75; transform: scale(.94); border-radius: 6px; }
.tile img, .tile video { transition: transform .12s, opacity .12s; }
.tile.selected .check { background: var(--accent); }
.tile.selected .check svg { opacity: 1; }

.selection-bar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 10;
  width: min(1100px, calc(100% - 32px)); display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px;
  box-shadow: 0 8px 30px rgba(60, 40, 20, .18);
}
body.has-selection-bar .page { padding-bottom: 160px; }
