:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --fg: #16201f;
  --muted: #5f6b69;
  --line: #e2e0d8;
  --accent: #0f5f5a;
  --accent-fg: #ffffff;
  --accent-soft: #e3f1ef;
  --ok: #2b8a3e; --ok-bg: #ebfbee;
  --warn: #b35c00; --warn-bg: #fff4e6;
  --bad: #c92a2a; --bad-bg: #fff5f5;
  --shadow: 0 6px 24px rgba(20, 30, 30, .16);
  --tabbar: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111716; --surface: #1a2221; --fg: #e8eeec; --muted: #9aa8a5; --line: #2c3634;
    --accent: #3fb8ad; --accent-fg: #06201e; --accent-soft: #173331;
    --ok: #69db7c; --ok-bg: #173522; --warn: #ffa94d; --warn-bg: #3a2a14; --bad: #ff8787; --bad-bg: #3b1b1b;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden; -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
h2 { font-size: 1.2rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
h4 { font-size: .9rem; margin: .8rem 0 .2rem; }
p { margin: .5rem 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.right { text-align: right; margin-left: auto; }
.grow { flex: 1; min-width: 0; }

main { position: fixed; inset: 0 0 calc(var(--tabbar) + var(--safe-b)) 0; }
#map { position: absolute; inset: 0; }

/* barre de recherche */
.topbar { position: fixed; z-index: 20; top: calc(10px + env(safe-area-inset-top, 0px)); left: 12px; right: 12px; max-width: 520px; }
.search {
  display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 14px;
  padding: 4px 6px 4px 12px; box-shadow: var(--shadow);
}
.search > svg { color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--fg); font: inherit; font-size: 16px; padding: 10px 0; outline: none; }
.icon-btn {
  position: relative; display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 10px; background: none; color: var(--fg); cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn.on { color: #f59f00; }
.icon-btn.on svg { fill: currentColor; }
.badge { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--accent); color: var(--accent-fg); font-size: 11px; line-height: 16px; }
.filters {
  margin-top: 8px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 12px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end;
}
.filters label { display: grid; gap: 4px; font-size: .82rem; color: var(--muted); }
.filters[hidden] { display: none; }
select, input[type=email], input[type=text], textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
label.check { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: .92rem; padding: 3px 0; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.map-tools { position: absolute; z-index: 5; right: 10px; top: 130px; display: grid; gap: 8px; }
.fab { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--surface); color: var(--fg); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; }
.maplibregl-ctrl-top-right { top: 70px; }

/* panneau : feuille glissante sur mobile, colonne à gauche sur grand écran */
.panel {
  position: absolute; z-index: 10; left: 0; right: 0; bottom: 0;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
  overflow-y: auto; overscroll-behavior: contain; padding: 0 16px 24px;
  transition: height .25s ease;
}
.panel[data-state=peek] { height: 172px; overflow: hidden; }
.slogan { margin: 0 0 8px; font-style: italic; font-weight: 600; color: var(--accent); line-height: 1.35; }
.panel[data-state=half] { height: 55%; }
.panel[data-state=full] { height: calc(100% - 76px); }
.grip { position: sticky; top: 0; height: 22px; margin: 0 -16px; background: var(--surface); cursor: pointer; z-index: 2; }
.grip::after { content: ""; position: absolute; left: 50%; top: 8px; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--line); }
.panel-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding-bottom: 6px; }
.detail-head { align-items: flex-start; }
.detail-head h2 { line-height: 1.25; }

@media (min-width: 900px) {
  .panel, .panel[data-state] { top: 76px; bottom: 12px; left: 12px; right: auto; width: 420px; height: auto; border-radius: 16px; overflow-y: auto; }
  .grip { display: none; }
  .panel-head { padding-top: 14px; }
  .maplibregl-ctrl-top-right { top: 12px; }
  .map-tools { right: 60px; top: 12px; display: flex; }
}

/* cartes de liste */
.cards { display: grid; gap: 8px; }
.card { display: block; text-decoration: none; color: inherit; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.card:hover { border-color: var(--accent); }
.card-top { display: flex; justify-content: space-between; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.chip { font-size: .78rem; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); white-space: nowrap; }
.chip.v1, .chip.v2 { background: var(--ok-bg); color: var(--ok); }
.chip.v3 { background: #e7f5ff; color: #1864ab; }
.chip.v4 { background: var(--warn-bg); color: var(--warn); }
.chip.v5, .chip.v6, .chip.v7, .chip.danger { background: var(--bad-bg); color: var(--bad); }
@media (prefers-color-scheme: dark) { .chip.v3 { background: #16283a; color: #74c0fc; } }
.stars { color: #f59f00; letter-spacing: 1px; font-size: .85rem; white-space: nowrap; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* fiche */
.times { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.times div { background: var(--bg); border-radius: 10px; padding: 8px; text-align: center; display: grid; font-size: .85rem; }
.block { border-top: 1px solid var(--line); padding: 14px 0 6px; }
.note { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 8px 10px; font-size: .9rem; }
.days { display: flex; gap: 6px; margin-bottom: 10px; }
.days button { flex: 1; border: 1px solid var(--line); background: none; color: var(--fg); border-radius: 999px; padding: 6px; font: inherit; font-size: .85rem; cursor: pointer; text-transform: capitalize; }
.days button[aria-selected=true] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.verdict { border-radius: 12px; padding: 10px 12px; }
.verdict ul { margin: 4px 0 0; padding-left: 18px; font-size: .9rem; }
.verdict.l0 { background: var(--ok-bg); color: var(--ok); }
.verdict.l1 { background: var(--warn-bg); color: var(--warn); }
.verdict.l2 { background: var(--bad-bg); color: var(--bad); }
.wx { display: flex; align-items: center; gap: 12px; margin: 12px 0; }
.wx-ic { font-size: 2rem; }
.flow { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.mb-widget { display: block; width: 100%; height: 300px; border: 0; margin-top: 12px; border-radius: 10px; background: #fff; }
.mb-links { margin: 2px 0 6px; }
.dc-link { width: 100%; flex-direction: column; gap: 2px; margin-top: 10px; }
.done-mark { color: var(--ok); }
.carnet-add { width: 100%; margin-top: 12px; border-color: var(--ok); color: var(--ok); }
.carnet-entry { margin-top: 12px; background: var(--ok-bg); border-radius: 12px; padding: 10px 12px; }
.carnet-top { display: flex; justify-content: space-between; gap: 8px; color: var(--ok); }
.carnet-note { white-space: pre-line; margin: 6px 0 0; }
.carnet-line { margin-top: 6px; font-size: .85rem; }
.carnet-actions { display: flex; justify-content: space-between; margin-top: 4px; }
.section-title { margin: 14px 0 8px; }
.rate { display: flex; flex-direction: row-reverse; justify-content: flex-end; }
.rate input { position: absolute; opacity: 0; pointer-events: none; }
.rate label { font-size: 1.8rem; line-height: 1; padding: 4px 5px; color: var(--line); cursor: pointer; display: inline; }
.rate input:checked ~ label, .rate label:hover, .rate label:hover ~ label { color: #f59f00; }
.rate input:focus-visible + label { outline: 2px solid var(--accent); border-radius: 4px; }
dialog input[type=date] { width: 100%; font: inherit; font-size: 16px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.spark { width: 100%; height: 56px; margin-top: 4px; }
.spark polyline { fill: none; stroke: #1c7ed6; stroke-width: 2; vector-effect: non-scaling-stroke; }
.pts { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.pts li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.pts code { grid-column: 1; font-size: .8rem; color: var(--muted); }
.pts a { grid-row: 1 / span 2; grid-column: 2; }
.src { font-size: .78rem; color: var(--muted); }
.warn { font-size: .8rem; color: var(--muted); border-left: 3px solid var(--warn); padding-left: 10px; margin-top: 16px; }

.premium { background: linear-gradient(135deg, var(--accent-soft), transparent); border: 1px solid var(--accent); border-radius: 14px; padding: 14px; margin: 14px 0 4px; }
.premium-head { display: flex; justify-content: space-between; align-items: baseline; }
.price { font-weight: 700; color: var(--accent); }
.locked { padding: 0; list-style: none; margin: 4px 0 12px; font-size: .9rem; }
.locked li { padding: 3px 0 3px 24px; position: relative; }
.locked li::before { content: "🔒"; position: absolute; left: 0; font-size: .8rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.sm { padding: 5px 10px; font-size: .82rem; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); width: 100%; }
.btn:disabled { opacity: .6; }
.link { border: 0; background: none; color: var(--accent); font: inherit; font-size: .9rem; cursor: pointer; padding: 4px; }

/* barre d'onglets */
.tabbar {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar button { flex: 1; display: grid; place-items: center; align-content: center; gap: 2px; border: 0; background: none; color: var(--muted); font: inherit; font-size: .72rem; cursor: pointer; }
.tabbar button.active { color: var(--accent); }

/* dialogue */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(440px, calc(100% - 32px)); background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form, .thanks { padding: 18px; display: grid; gap: 12px; }
dialog label { display: grid; gap: 4px; font-size: .9rem; }
dialog fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 0; }
dialog legend { font-size: .9rem; padding: 0 4px; }
.actions { display: flex; gap: 8px; }
.actions .btn { flex: 1; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(var(--tabbar) + 150px); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: .88rem; }
.maplibregl-ctrl-attrib { font-size: 10px; }
