:root {
  --bg: #f6efe4;          /* beige clair */
  --card: #fffcf7;
  --ink: #2c2a33;
  --muted: #6b6570;
  --line: #e9dccd;
  --accent: #a9cde8;      /* bleu clair : en-tête, boutons */
  --accent-ink: #1d3550;
  --accent-text: #2f6690; /* bleu lisible sur fond clair : liens, contours */
  --accent-soft: #f3d6d9; /* rose poudré : onglets, encadrés */
  --rose-text: #a5566b;   /* rose lisible : étiquettes */
  --danger: #b3261e;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1b19;
    --card: #2a2523;
    --ink: #f3ece2;
    --muted: #b0a69c;
    --line: #3d3532;
    --accent: #a9cde8;
    --accent-ink: #1d3550;
    --accent-text: #a9cde8;
    --accent-soft: #4a3338;
    --rose-text: #eab3bd;
    --danger: #f2867d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
  padding-bottom: env(safe-area-inset-bottom);
}

.wrap { max-width: 680px; margin: 0 auto; padding: 0 16px; }

a { color: var(--accent-text); }

/* ---------- en-tête ---------- */

.top {
  background: var(--accent);
  color: var(--accent-ink);
  padding: calc(28px + env(safe-area-inset-top)) 0 24px;
  margin-bottom: 20px;
}
.top h1 { font: 600 1.9rem/1.15 var(--serif); margin: 0; }
.subtitle { margin: 6px 0 0; opacity: .9; }
.whoami { margin: 12px 0 0; font-size: .9rem; opacity: .9; }

/* ---------- jours ---------- */

.day { margin: 28px 0 12px; display: flex; align-items: baseline; gap: 10px; }
.day h2 { font: 600 1.35rem/1.2 var(--serif); margin: 0; }
.day .date { color: var(--muted); font-size: .95rem; }

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

/* ---------- entrées ---------- */

.entry {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.entry-body { padding: 16px; }
.entry h3 { font: 600 1.2rem/1.3 var(--serif); margin: 0 0 8px; }
.entry .text p { margin: 0 0 .8em; }
.entry .text p:last-child { margin-bottom: 0; }
.entry .caption { font: italic 1.08rem/1.5 var(--serif); margin: 0; }
.meta { color: var(--muted); font-size: .85rem; margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.tag {
  display: inline-block; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--rose-text); margin-bottom: 6px; font-weight: 600;
}

/* grille photos : 1 grande, 2 côte à côte, puis mosaïque */
.photos { display: grid; gap: 2px; grid-template-columns: 1fr 1fr; }
.photos.n1 { grid-template-columns: 1fr; }
.photos.n3 > :first-child, .photos.odd > :first-child { grid-column: 1 / -1; }
.photo-cell { position: relative; }
.zoom {
  all: unset; cursor: zoom-in; display: block; width: 100%;
  aspect-ratio: 4 / 3; background: var(--line);
}
.zoom:focus-visible { outline: 3px solid var(--accent-text); outline-offset: -3px; }
.photos.n1 .zoom { aspect-ratio: auto; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos.n1 img { height: auto; max-height: 80vh; object-fit: contain; background: var(--line); }
.photo-del {
  position: absolute; top: 6px; right: 6px; border: 0; border-radius: 999px;
  background: rgba(0, 0, 0, .6); color: #fff; width: 32px; height: 32px; font-size: 18px;
}

/* ---------- commentaires ---------- */

.comments { border-top: 1px solid var(--line); padding: 4px 16px 12px; }
.comments summary {
  cursor: pointer; color: var(--accent-text); font-weight: 600; padding: 10px 0; list-style: none;
}
.comments summary::-webkit-details-marker { display: none; }
.comment { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.comment:last-of-type { border-bottom: 0; }
.comment .who { font-weight: 600; }
.comment .when { color: var(--muted); font-size: .8rem; margin-left: 6px; }
.comment p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- formulaires ---------- */

form { display: grid; gap: 10px; }
label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
input, textarea, select {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent-text); outline-offset: -1px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.btn {
  font: 600 1rem var(--sans); border: 0; border-radius: 999px; padding: 12px 20px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; min-height: 44px;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent-text); border: 1px solid var(--accent-text); }
.btn.small { padding: 6px 14px; min-height: 34px; font-size: .9rem; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.link-del { border: 0; background: none; color: var(--danger); font-size: .8rem; cursor: pointer; padding: 0 0 0 8px; }

/* ---------- éditeur des voyageurs ---------- */

#composer {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 8px;
}
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--accent-soft); border-radius: 999px; padding: 4px; margin-bottom: 14px; }
.tabs button {
  border: 0; background: none; font: 600 1rem var(--sans); color: var(--ink); padding: 10px; border-radius: 999px; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }

.picker {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px 12px; text-align: center;
  color: var(--muted); cursor: pointer;
}
.picker input { display: none; }
.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 6px; }
.previews div { position: relative; aspect-ratio: 1; }
.previews img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.previews button {
  position: absolute; top: 2px; right: 2px; border: 0; border-radius: 999px; width: 26px; height: 26px;
  background: rgba(0, 0, 0, .65); color: #fff; cursor: pointer;
}
.progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent-text); transition: width .2s; }
.notice { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin: 0; }

/* ---------- visionneuse ---------- */

.lightbox {
  position: fixed; inset: 0; background: rgba(10, 8, 6, .95); z-index: 50;
  display: flex; align-items: center; justify-content: center; touch-action: pan-y;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox button {
  position: absolute; border: 0; background: rgba(255, 255, 255, .12); color: #fff;
  width: 48px; height: 48px; border-radius: 999px; font-size: 28px; cursor: pointer;
}
.lb-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.lb-prev { left: 8px; top: 50%; translate: 0 -50%; }
.lb-next { right: 8px; top: 50%; translate: 0 -50%; }
.lb-caption {
  position: absolute; bottom: 0; left: 0; right: 0; margin: 0; color: #f1e9df; text-align: center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); font: italic 1rem var(--serif);
  background: linear-gradient(transparent, rgba(0, 0, 0, .7));
}

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); translate: -50% 0;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  z-index: 60; max-width: calc(100% - 32px); text-align: center; font-size: .95rem;
}

.foot { text-align: center; padding: 32px 16px 40px; font-size: .9rem; }
