:root {
  --bg: #FBF7F0;
  --primary: #1F4B3F;
  --primary-dark: #153A2E;
  --primary-soft: #E4EEE9;
  --gold: #B8934A;
  --gold-soft: #F3E9D4;
  --rose: #B5697A;
  --rose-soft: #F5E6E9;
  --ink: #241F1A;
  --ink-soft: #6B6259;
  --line: #E4DCCB;
  --shadow-sm: 0 1px 2px rgba(31,75,63,0.06), 0 4px 14px -6px rgba(31,75,63,0.12);
  --shadow-md: 0 6px 24px -10px rgba(31,75,63,0.28);
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Inter", "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  animation: pageIn 0.28s ease-out both;
}
@keyframes pageIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Sur grand écran, le contenu reste étroit (façon appli) — motif de marque adouci autour. */
@media (min-width: 700px) {
  body {
    background-color: var(--bg);
    background-image: linear-gradient(rgba(251,247,240,0.72), rgba(251,247,240,0.72)), url("/logo-watermark.png");
    background-repeat: repeat;
    background-size: 100% 100%, 150px 180px;
    background-attachment: fixed;
    min-height: 100vh;
  }
  .wrap {
    background: var(--bg);
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 24px 80px -30px rgba(31,75,63,0.35);
    min-height: 100vh;
  }
}
.wrap { max-width: 480px; margin: 0 auto; padding: 22px 18px 70px; }

/* ---------- Typographie ---------- */
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; margin: 0 0 6px; letter-spacing: -0.2px; color: var(--primary-dark); }
h2 { font-size: 24px; }
h3 { font-size: 15.5px; margin-top: 22px; color: var(--ink); }
h3:first-child { margin-top: 0; }
.eyebrow { font-family: monospace; font-size: 11px; letter-spacing: 0.06em; color: var(--ink-soft); text-transform: uppercase; }
a { color: var(--primary); text-underline-offset: 2px; }
.muted { color: var(--ink-soft); font-size: 13px; }
.error { color: #B03A2E; font-size: 13px; margin-top: 8px; }

/* ---------- Navigation du haut : titre sur sa ligne, liens en pastilles dessous ---------- */
nav.top { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
nav.top h2 { display: flex; align-items: center; gap: 8px; }
nav.top > span, nav.top > div { font-size: 0; display: flex; flex-wrap: wrap; gap: 6px; }
nav.top > span > a, nav.top > div > a {
  font-size: 12.5px; font-weight: 600; text-decoration: none; color: var(--primary);
  background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 6px 11px;
  display: inline-flex; align-items: center; gap: 5px; line-height: 1.2;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
nav.top > span > a:hover, nav.top > div > a:hover { background: var(--primary-soft); border-color: #C9DCD3; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
nav.top > span > a[onclick*="logout"], nav.top > div > a[onclick*="logout"] { color: var(--ink-soft); background: transparent; border-color: transparent; }
nav.top > span > a[onclick*="logout"]:hover, nav.top > div > a[onclick*="logout"]:hover { background: #fff; border-color: var(--line); }
nav.top > span > a[href="/admin.html"], nav.top > div > a[href="/admin.html"] { color: #fff !important; background: var(--gold); border-color: var(--gold); }
nav.top > span > a[href="/admin.html"]:hover, nav.top > div > a[href="/admin.html"]:hover { background: #A5823E; border-color: #A5823E; }
nav.top a span { font-size: 11px; }

/* ---------- Cartes ---------- */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
  animation: cardIn 0.35s ease-out both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.discover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.discover-grid .card { margin-bottom: 0; }
.discover-grid .card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

/* ---------- Formulaires ---------- */
label { display: block; font-size: 13px; color: var(--ink-soft); margin: 12px 0 5px; font-weight: 500; }
input, textarea, select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,75,63,0.14); }
input::placeholder, textarea::placeholder { color: #A39B90; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6259' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }

/* ---------- Boutons ---------- */
button, .btn-primary, .btn-gold, .btn-rose, .btn-outline {
  cursor: pointer; border: none; border-radius: 12px; padding: 11px 16px;
  font-size: 14px; font-weight: 600; font-family: inherit; line-height: 1.2;
  transition: background 0.15s, transform 0.12s, box-shadow 0.15s, opacity 0.15s;
}
button:active, .btn-primary:active, .btn-gold:active, .btn-rose:active, .btn-outline:active { transform: translateY(1px) scale(0.99); }
button:focus-visible { outline: 3px solid rgba(31,75,63,0.25); outline-offset: 2px; }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -8px rgba(31,75,63,0.6); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-gold { background: var(--gold); color: #fff; box-shadow: 0 6px 16px -8px rgba(184,147,74,0.7); }
.btn-gold:hover { background: #A5823E; }
.btn-rose { background: var(--rose); color: #fff; }
.btn-rose:hover { background: #9E5666; }
.btn-outline { background: #fff; border: 1px solid var(--line); color: var(--ink-soft); }
.btn-outline:hover { border-color: #CFC5B4; color: var(--ink); background: #FDFBF7; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-family: monospace; letter-spacing: 0.01em; }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-gold { background: var(--gold-soft); color: #8F6F2E; }
.badge-rose { background: var(--rose-soft); color: var(--rose); }

/* ---------- Photos verrouillées ---------- */
.blur-box {
  position: relative; height: 140px; border-radius: 12px; overflow: hidden;
  background: linear-gradient(160deg, #d8d0c4, #c6bcae);
  display: flex; align-items: center; justify-content: center; color: #fff; font-family: monospace; font-size: 11px;
  margin-bottom: 10px; text-align: center; padding: 0 20px;
}
.blur-box.locked { backdrop-filter: blur(10px); filter: blur(4px); }
.blur-box-wrap { position: relative; }
.blur-box-wrap .lock-icon {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 42px; height: 50px; z-index: 2;
  background-image: url("/lock-overlay.png"); background-size: contain; background-repeat: no-repeat;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.45));
}

/* ---------- Messages ---------- */
.msg { padding: 9px 13px; border-radius: 14px; margin-bottom: 6px; max-width: 82%; font-size: 14px; line-height: 1.45; animation: cardIn 0.25s ease-out both; }
.msg.mine { background: var(--primary-soft); margin-left: auto; border-bottom-right-radius: 4px; }
.msg.theirs { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.blocked { background: #FBEAEA; color: #B03A2E; font-style: italic; }

/* ---------- Support RTL (arabe) ---------- */
body.rtl { direction: rtl; text-align: right; }
body.rtl .btn-row { flex-direction: row-reverse; }
body.rtl .msg.mine { margin-left: 0; margin-right: auto; }
body.rtl select, body.rtl input { text-align: right; }
body.rtl select { background-position: left 12px center; padding-right: 13px; padding-left: 34px; }
body.rtl .discover-grid { direction: rtl; }
body.rtl nav.top { align-items: flex-end; }

/* ---------- Admin ---------- */
.admin-search-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.admin-search-bar input { flex: 1; margin-bottom: 0; }
.admin-search-bar select { width: auto; margin-bottom: 0; }

/* Une carte vide (section non concernée) ne laisse pas un cadre blanc inutile. */
.card:empty { display: none; }
