:root {
  --bg: #1f1a14;
  --panel: #2b241b;
  --panel-2: #362d22;
  --ink: #efe3c8;
  --muted: #a89a7c;
  --accent: #c8922f;
  --danger: #b3412f;
  --line: #4a3f30;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 15px;
}
.hidden { display: none !important; }
h1, h2 { margin: 0; font-weight: 600; }
a { color: var(--accent); }

.btn {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #231a0b; border-color: var(--accent); font-weight: 600; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: #ff8a73; min-height: 1.2em; margin: 6px 0 0; font-size: 14px; }

/* Connexion */
.login { height: 100%; display: grid; place-items: center; padding: 20px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 32px; max-width: 380px; text-align: center; }
.login-card h1 { margin-bottom: 12px; }
.login-card p { color: var(--muted); margin: 0 0 22px; }

/* Layout */
.app { display: flex; height: 100%; }
.sidebar {
  width: 320px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
}
.sidebar header { display: flex; flex-direction: column; gap: 4px; }
.sidebar h1 { font-size: 20px; }
.user { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.sidebar input[type=search] {
  width: 100%; padding: 8px 10px; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; font: inherit;
}
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.mini-actions { text-transform: none; letter-spacing: 0; }

.toggle, .slider { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.slider { color: var(--muted); font-size: 13px; }
.slider input { flex: 1; accent-color: var(--accent); }
.toggle input { accent-color: var(--accent); }

.filters, .list, .cat-list { list-style: none; margin: 0; padding: 0; }
.filters li label { display: flex; align-items: center; gap: 8px; padding: 4px 2px; cursor: pointer; }
.filters .dot { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; border: 2px solid #fff3; }
.filters .n { margin-left: auto; color: var(--muted); font-size: 13px; }
.list li { padding: 7px 8px; border-radius: 6px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.list li:hover { background: var(--panel-2); }
.list .priv { color: var(--muted); font-size: 12px; margin-left: auto; }

.mapwrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: #14100b; }
.burger { display: none; position: absolute; z-index: 1000; top: 10px; left: 10px; width: 38px; height: 38px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; font-size: 18px; cursor: pointer; }
.fab { position: absolute; z-index: 1000; right: 16px; bottom: 22px; box-shadow: 0 4px 14px #0008; }
.banner { position: absolute; z-index: 1000; top: 12px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #231a0b; padding: 8px 16px; border-radius: 6px; box-shadow: 0 4px 14px #0008; }
.banner .link { color: #231a0b; }
.adding #map { cursor: crosshair; }

/* Marqueurs */
.pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 2px 6px #000a;
}
.pin span { transform: rotate(45deg); font-size: 15px; line-height: 1; }
.pin.private { border-style: dashed; }
.leaflet-div-icon.pin-wrap { background: none; border: 0; }

/* Popups */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--ink); }
.leaflet-popup-content { margin: 12px 14px; font-family: Georgia, serif; max-width: 260px; }
.popup h3 { margin: 0 0 2px; font-size: 17px; }
.popup .meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.popup .desc { white-space: pre-wrap; word-break: break-word; margin-bottom: 10px; }
.popup .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Dialogs */
dialog { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: min(440px, 92vw); }
dialog::backdrop { background: #000a; }
dialog h2 { margin-bottom: 12px; }
dialog label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
dialog input, dialog select, dialog textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; font: inherit;
}
.field { margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.field .lbl { display: block; margin-bottom: 4px; }
.icon-row { display: flex; align-items: center; gap: 12px; }
.icon-btn { font-size: 22px; line-height: 1; padding: 6px 12px; }
.icon-btn.is-default { opacity: .65; }
.emoji-dialog { width: min(520px, 94vw); }
.emoji-dialog input { margin-bottom: 10px; font-size: 20px; }
.emoji-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.emoji-tabs button { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; padding: 3px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.emoji-tabs button.on { background: var(--accent); color: #231a0b; border-color: var(--accent); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 2px; max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; padding: 4px; background: var(--bg); }
.emoji-grid button { font-size: 22px; line-height: 1; padding: 6px 0; background: none; border: 0; border-radius: 6px; cursor: pointer; }
.emoji-grid button:hover { background: var(--panel-2); }
.mod-dialog { width: min(760px, 96vw); }
.mod-body { max-height: 56vh; overflow-y: auto; }
.mod-body > input[type=search] { margin-bottom: 6px; }
.mod-add { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.mod-add input { margin: 0; flex: 1 1 200px; width: auto; }
.mod-add select { margin: 0; width: auto; }
.mod-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); }
.mod-row .who { flex: 1 1 180px; min-width: 0; }
.mod-row .who small { display: block; color: var(--muted); word-break: break-all; }
.mod-row select { width: auto; margin: 0; }
.mod-row .meta { color: var(--muted); font-size: 13px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.audit-row { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.audit-row small { color: var(--muted); display: block; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.cat-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.cat-list .grow { flex: 1; }
.cat-form { display: flex; gap: 6px; margin-top: 14px; }
.cat-form input { margin: 0; }
.cat-form input[type=color] { width: 46px; padding: 2px; }

@media (max-width: 760px) {
  .sidebar { position: absolute; z-index: 1100; inset: 0 auto 0 0; width: min(86vw, 320px); transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 6px 0 24px #000a; }
  .burger { display: block; }
}
