:root {
  --bg: #171210;
  --bg-card: #211a15;
  --bg-hover: #2c231c;
  --text: #f3e9df;
  --muted: #b7a494;
  --accent: #d99a4e;
  --accent-strong: #eeb26b;
  --accent-soft: rgba(217, 154, 78, 0.14);
  --red: #e05c4f;
  --green: #7bc47f;
  --border: #38291e;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: #100c0a;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.5px;
  text-decoration: none;
}
.logo-img { height: 28px; width: auto; display: block; }

.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
}
.nav a:hover { color: var(--text); background: var(--bg-hover); }
.nav a.active { color: #14100c; background: var(--accent); }

.user-badge { margin-left: auto; display: flex; align-items: center; gap: 10px; }
#user-name { color: var(--muted); font-size: 0.9rem; }

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }

.hidden { display: none !important; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card.center { text-align: center; max-width: 460px; margin: 40px auto; }

h2 { margin-top: 0; }
h3 { margin: 0 0 6px; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--red); font-weight: 600; }

/* Boutons */
.btn {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  font-family: inherit;
}
.btn:hover { background: #3a2d22; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1a120b; font-weight: 700; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-big { font-size: 1.05rem; padding: 14px 30px; }
.btn-small { padding: 6px 14px; font-size: 0.85rem; }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(224, 92, 79, 0.15); }

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

/* Barre d'outils classement */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.toolbar select, .toolbar input[type='search'], .toolbar input[type='text'] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.92rem;
  font-family: inherit;
}
.toolbar select:focus, .toolbar input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.toolbar .search { flex: 1; min-width: 180px; }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 18px;
}
.stats strong { color: var(--accent); font-size: 1.05rem; }

/* Badge type de recette */
.tag { border-radius: 999px; padding: 2px 10px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.tag-trad { background: rgba(123, 196, 127, 0.15); color: var(--green); }
.tag-creation { background: var(--accent-soft); color: var(--accent); }

/* Carte d'entrée (classement) */
.entry-list { display: flex; flex-direction: column; gap: 14px; }
.entry {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 16px;
  align-items: start;
}
.entry .rank {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  text-align: center;
  line-height: 1.1;
}
.entry .rank small { display: block; font-size: 0.7rem; color: var(--muted); font-weight: 600; }
.entry .head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.entry .name { font-weight: 700; font-size: 1.08rem; }
.entry .place { color: var(--muted); font-size: 0.9rem; }
.entry .place button {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font: inherit; padding: 0; text-decoration: underline dotted;
}
.entry .meta { color: var(--muted); font-size: 0.85rem; display: flex; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.entry .note-box { text-align: right; }
.entry .note-value { font-weight: 800; font-size: 1.25rem; color: var(--accent); }
.entry .note-value small { color: var(--muted); font-weight: 600; font-size: 0.8rem; }

.stars { position: relative; display: inline-block; line-height: 0; }
.stars .row { display: inline-flex; gap: 2px; }
.stars .fg {
  position: absolute; inset: 0 auto 0 0; overflow: hidden; white-space: nowrap;
}
.stars svg { width: 16px; height: 16px; flex: none; }
.stars .bg svg { fill: #4a3a2c; }
.stars .fg svg { fill: var(--accent); }

.criteres { margin-top: 10px; display: grid; gap: 4px; max-width: 420px; }
.crit { display: grid; grid-template-columns: 150px 1fr 28px; align-items: center; gap: 10px; font-size: 0.82rem; color: var(--muted); }
.crit .bar { height: 7px; background: var(--bg-hover); border-radius: 999px; overflow: hidden; }
.crit .bar > div { height: 100%; background: var(--accent); border-radius: 999px; }
.crit .val { text-align: right; color: var(--text); font-weight: 600; }

.commentaire {
  margin-top: 10px;
  white-space: pre-wrap;
  color: var(--text);
  font-size: 0.92rem;
  border-left: 3px solid var(--accent);
  padding-left: 12px;
}

.entry .admin-actions { display: flex; gap: 8px; margin-top: 10px; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Formulaires */
.field { display: block; margin-bottom: 14px; font-size: 0.9rem; color: var(--muted); }
.field input, .field textarea, .field select {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field textarea { resize: vertical; min-height: 90px; }
.field .hint { font-size: 0.78rem; margin-top: 4px; display: block; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 0 0 18px;
  padding: 14px 16px;
}
legend { color: var(--muted); font-size: 0.9rem; padding: 0 6px; }

.crit-slider { display: grid; grid-template-columns: 150px 1fr 34px; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 0.9rem; }
.crit-slider input[type='range'] { width: 100%; accent-color: var(--accent); }
.crit-slider output { text-align: right; font-weight: 700; color: var(--accent); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .entry { grid-template-columns: 40px 1fr; } .entry .note-box { grid-column: 2; text-align: left; } }

/* Carte Leaflet */
#map, .minimap {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #0e0b09;
}
#map { height: 62vh; min-height: 380px; }
.minimap { height: 280px; cursor: crosshair; }
.map-wrap { position: relative; }
.map-caption { color: var(--muted); font-size: 0.88rem; margin: 10px 2px 18px; }

.tiramisu-pin { background: none; border: none; }

.leaflet-popup-content-wrapper { background: var(--bg-card); color: var(--text); border-radius: 10px; }
.leaflet-popup-content { margin: 12px 14px; font-family: inherit; line-height: 1.45; }
.leaflet-popup-tip { background: var(--bg-card); }
.leaflet-container { background: #0e0b09; font-family: inherit; }
.leaflet-bar a { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.leaflet-bar a:hover { background: var(--bg-hover); }

.popup-title { font-weight: 700; font-size: 1rem; }
.popup-place { color: var(--muted); font-size: 0.88rem; }
.popup-meta { color: var(--muted); font-size: 0.85rem; margin: 6px 0; display: flex; gap: 12px; flex-wrap: wrap; }
.popup-actions { margin-top: 8px; }

.mini-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 16px; }
.mini-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; text-align: left; color: var(--text); font-family: inherit;
}
.mini-card:hover { border-color: var(--accent); }
.mini-card .t { font-weight: 700; }
.mini-card .s { color: var(--muted); font-size: 0.83rem; margin-top: 2px; }
.mini-card .n { color: var(--accent); font-weight: 800; float: right; }

/* Connexion */
.login-error { margin-top: 12px; }

.loader {
  display: inline-block;
  width: 18px; height: 18px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.coords-readout { color: var(--muted); font-size: 0.85rem; margin-top: 8px; font-variant-numeric: tabular-nums; }
