:root, [data-theme="light"] {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem; --space-5: 1.25rem;
  --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem;
  --radius-sm: .5rem; --radius-md: .75rem; --radius-lg: 1.25rem;

  /* Pierre calcaire + cyprès */
  --color-bg: #f6f1e7;
  --color-surface: #fcf9f3;
  --color-surface-2: #eee7da;
  --color-border: #ddd4c3;
  --color-divider: #e8e0d1;
  --color-text: #24231f;
  --color-text-muted: #6b685f;
  --color-text-faint: #667174;
  --color-primary: #1b434d;
  --color-primary-hover: #12323a;
  --color-primary-soft: #dde8e8;
  --color-on-primary: #f0e5d0;
  --color-route: #1f6d7b;
  --color-target: #a2462a;
  --color-warn-bg: #f3eadb;
  --color-warn-text: #6e4a1d;
  --shadow-sheet: 0 -8px 30px rgba(36, 35, 31, .12);
  --route-casing: #ffffff;
  --plan-filter: none;
  --font-display: 'Palatino', 'Palatino Linotype', 'P052', 'Book Antiqua', 'URW Palladio L', Georgia, serif;
  --font-body: 'Palatino', 'Palatino Linotype', 'P052', 'Book Antiqua', 'URW Palladio L', Georgia, serif;
  color-scheme: light;
}
[data-theme="dark"] {
  /* Direction artistique de la marque : bleu pétrole + crème (identique à l'écran d'accueil) */
  --color-bg: #0f2c34;
  --color-surface: #173c46;
  --color-surface-2: #0b232a;
  --color-border: #33606b;
  --color-divider: #224a54;
  --color-text: #f0e5d0;
  --color-text-muted: #d3cdbb;
  --color-text-faint: #a3b3b0;
  --color-primary: #f0e5d0;
  --color-primary-hover: #fff6e4;
  --color-primary-soft: #21505b;
  --color-on-primary: #0f2c34;
  --color-route: #f2c46d;
  --route-casing: #06171c;
  --color-target: #f08d6a;
  --color-warn-bg: #163a43;
  --color-warn-text: #e9d6ae;
  --shadow-sheet: 0 -10px 34px rgba(4, 18, 22, .5);
  --plan-filter: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--color-bg); color: var(--color-text);
  font-family: var(--font-body); font-size: var(--text-base); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.satellite-preview.satellite-unavailable { display: flex; align-items: center; justify-content: center; padding: 24px; }
.satellite-unavailable .notice { max-width: 42ch; line-height: 1.6; }
.missing-details { margin: 16px 0 24px; border: 1px solid var(--color-border); padding: 16px; border-radius: 12px; }
.missing-details summary { cursor: pointer; font-weight: 600; line-height: 1.5; }
.missing-details p { line-height: 1.6; font-size: 14px; }
.missing-form { display: grid; gap: 14px; margin-top: 16px; }
.missing-form label { display: grid; gap: 6px; }
.missing-form input, .missing-form select {
  width: 100%; min-width: 0; min-height: 48px; padding: 10px 12px;
  border: 1.5px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text); font: inherit;
}
.missing-form input:focus-visible, .missing-form select:focus-visible {
  outline: 2px solid var(--color-primary); outline-offset: 3px;
}

.app { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; background: var(--color-bg); }
@media (min-width: 761px) { .app { border-inline: 1px solid var(--color-border); } }

.bar {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-4); padding-top: max(var(--space-3), env(safe-area-inset-top));
  border-bottom: 1px solid var(--color-divider); background: var(--color-surface); z-index: 1001;
}
.brand { display: flex; align-items: center; gap: var(--space-3); text-decoration: none; color: var(--color-primary); flex: 1; min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); color: var(--color-text); }
.brand-sub { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
  border: 0; background: transparent; cursor: pointer; color: var(--color-text-muted);
}
.icon-btn:hover { background: var(--color-surface-2); color: var(--color-text); }
:focus-visible { outline: 2px solid var(--color-route); outline-offset: 2px; }

.view { flex: 1; overflow-y: auto; }

/* Recherche */
.search-head { padding: var(--space-8) var(--space-5) var(--space-4); }
h1 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); line-height: 1.15; margin: 0 0 var(--space-2); letter-spacing: -.01em; }
.lead { margin: 0 0 var(--space-6); color: var(--color-text-muted); max-width: 46ch; }
.search-box {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--color-surface); border: 1.5px solid var(--color-border); border-radius: var(--radius-md);
  padding: 0 var(--space-4); height: 56px; color: var(--color-text-muted);
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 4px var(--color-primary-soft); }
.search-box input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; font-size: var(--text-lg); color: var(--color-text); min-width: 0; }
.search-box input::placeholder { color: var(--color-text-faint); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.chip {
  border: 1px solid var(--color-border); background: transparent; border-radius: 999px;
  padding: var(--space-1) var(--space-3); font-size: var(--text-sm); color: var(--color-text-muted); cursor: pointer; min-height: 36px;
}
.chip:hover { border-color: var(--color-primary); color: var(--color-primary); }

.results { padding: 0 var(--space-5); }
.count { font-size: var(--text-sm); color: var(--color-text-muted); margin: var(--space-2) 0; }
.list { list-style: none; margin: 0; padding: 0; }
.item {
  width: 100%; display: flex; align-items: center; gap: var(--space-4); text-align: left;
  padding: var(--space-4); margin-bottom: var(--space-2); cursor: pointer;
  background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-md);
  transition: border-color .15s, transform .15s;
}
.item:hover { border-color: var(--color-primary); }
.item:active { transform: scale(.99); }
.item-main { flex: 1; min-width: 0; }
.item-name { font-weight: 600; }
.item-name .nom { font-variant: small-caps; letter-spacing: .03em; text-transform: lowercase; font-size: 1.08em; }
.item-meta { font-size: var(--text-sm); color: var(--color-text-muted); }
.item-num { text-align: center; min-width: 64px; }
.item-num span { display: block; font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .06em; }
.item-num strong { font-family: var(--font-display); font-size: var(--text-lg); color: var(--color-primary); font-variant-numeric: tabular-nums; }
mark { background: var(--color-primary-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.empty { padding: var(--space-8) 0; color: var(--color-text-muted); text-align: center; }
.empty strong { display: block; color: var(--color-text); margin-bottom: var(--space-1); }

.notice {
  margin: var(--space-6) var(--space-5) var(--space-8); padding: var(--space-4);
  background: var(--color-warn-bg); color: var(--color-warn-text); border-radius: var(--radius-md);
  font-size: var(--text-sm); line-height: 1.5;
}
.notice strong { display: block; margin-bottom: var(--space-1); }

/* Plan */
.map-view { position: relative; overflow: hidden; }
#map { position: absolute; inset: 0; background: var(--color-surface-2); }
.leaflet-container { font-family: var(--font-body); background: var(--color-surface-2); }
.plan-img { filter: var(--plan-filter); }
.map-tools { position: absolute; top: var(--space-3); right: var(--space-3); z-index: 900; display: flex; flex-direction: column; gap: var(--space-2); }
.tool {
  width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0,0,0,.12); color: var(--color-text);
}
.toast {
  position: absolute; top: var(--space-3); left: var(--space-3); right: 64px; z-index: 900;
  background: var(--color-text); color: var(--color-bg); padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md); font-size: var(--text-sm); box-shadow: 0 4px 16px rgba(0,0,0,.2);
}

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 950;
  background: var(--color-surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-sheet); max-height: 50%; display: flex; flex-direction: column;
  transition: max-height .3s cubic-bezier(.2,.8,.2,1);
}
.sheet.collapsed { max-height: 150px; }
.sheet.expanded { max-height: 86%; }
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }
.grip { border: 0; background: transparent; padding: var(--space-3) 0 var(--space-1); cursor: pointer; display: flex; justify-content: center; flex-shrink: 0; }
.grip span { width: 40px; height: 5px; border-radius: 99px; background: var(--color-border); }
.sheet-body { overflow-y: auto; padding: 0 var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom)); }
.who { margin-bottom: var(--space-4); }
.eyebrow { margin: 0; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--color-text-muted); font-weight: 600; }
h2 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); line-height: 1.15; margin: var(--space-1) 0; }
.dates { margin: 0; color: var(--color-text-muted); }
.grave {
  display: flex; gap: var(--space-4); align-items: center;
  padding: var(--space-4); border-radius: var(--radius-md); background: var(--color-primary-soft); margin-bottom: var(--space-4);
}
.grave-num { text-align: center; padding-right: var(--space-4); border-right: 1px solid color-mix(in oklab, var(--color-primary) 25%, transparent); }
.grave-num span { display: block; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--color-primary); font-weight: 600; }
.grave-num strong { font-family: var(--font-display); font-size: var(--text-xl); color: var(--color-primary); line-height: 1; font-variant-numeric: tabular-nums; }
.grave-pos { font-size: var(--text-sm); }
.also { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: var(--space-4); }
.also strong { color: var(--color-text); font-weight: 600; }
.start { margin-bottom: var(--space-4); }
.label { display: block; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--color-text-muted); font-weight: 600; margin-bottom: var(--space-2); }
.seg { display: flex; background: var(--color-surface-2); border-radius: var(--radius-sm); padding: 3px; }
.seg button {
  flex: 1; border: 0; background: transparent; padding: var(--space-2); border-radius: calc(var(--radius-sm) - 2px);
  font-size: var(--text-sm); font-weight: 500; cursor: pointer; color: var(--color-text-muted); min-height: 40px;
}
.seg button[aria-checked="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { position: relative; padding: 0 0 var(--space-4) var(--space-10); counter-increment: s; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: var(--text-xs); font-weight: 600;
  background: var(--color-surface-2); color: var(--color-text-muted);
}
.steps li::after { content: ""; position: absolute; left: 13.5px; top: 32px; bottom: 4px; width: 1px; background: var(--color-divider); }
.steps li:last-child::after { display: none; }
.steps li:last-child::before { background: var(--color-target); color: #fff; content: "✓"; }
.steps li:first-child::before { background: var(--color-route); color: var(--color-surface); }
.steps li b { font-weight: 600; }
.caveat { font-size: var(--text-xs); color: var(--color-text-faint); margin: var(--space-2) 0 0; }

/* Marqueurs */
.pin-target { position: relative; }
.pin-target .dot { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px; border-radius: 50%; background: var(--color-target); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.pin-target .pulse { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px; border-radius: 50%; background: var(--color-target); opacity: .5; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { to { transform: scale(3.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pin-target .pulse { animation: none; } }
.pin-start { display: grid; place-items: center; }
.pin-start span { font-family: var(--font-body); background: var(--color-route); color: var(--color-on-route, #fff); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 99px; white-space: nowrap; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.leaflet-control-zoom a { background: var(--color-surface) !important; color: var(--color-text) !important; border-color: var(--color-border) !important; }
.leaflet-control-attribution { font-size: 11px; background: color-mix(in oklab, var(--color-surface) 85%, transparent) !important; color: var(--color-text-muted); }

/* ---------- Multi-cimetières ---------- */
.step-tag { margin: 0 0 var(--space-2); font-size: var(--text-xs); letter-spacing: .04em; text-transform: uppercase; color: var(--color-text-muted); font-weight: 600; }
.link { border: 0; background: none; padding: 0; color: var(--color-primary); font-weight: 600; text-transform: none; letter-spacing: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
.item-go { flex: none; color: var(--color-text-faint); }
.notice-soft { background: var(--color-surface-2); color: var(--color-text-muted); }

/* ---------- Pays / canton / département ---------- */
.app { position: relative; }
.toast { top: 76px; left: var(--space-4); right: var(--space-4); z-index: 1200; max-width: 520px; margin: 0 auto; }
.filters { display: grid; grid-template-columns: 1fr; gap: var(--space-3); margin-bottom: var(--space-3); }
@media (min-width: 480px) { .filters { grid-template-columns: minmax(180px, 1fr) 1.4fr; } }
.seg.country button { font-size: var(--text-base); }
.select { position: relative; display: block; }
.select select {
  width: 100%; height: 46px; appearance: none; -webkit-appearance: none; cursor: pointer;
  border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface);
  color: var(--color-text); font: inherit; font-size: var(--text-sm); padding: 0 40px 0 var(--space-4);
}
.select select:focus { outline: 0; border-color: var(--color-primary); box-shadow: 0 0 0 4px var(--color-primary-soft); }
.select svg { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--color-text-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.group { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; color: var(--color-text-muted); margin: var(--space-4) 0 var(--space-2); }
.item-place { display: block; font-weight: 500; color: var(--color-primary); margin-top: 2px; }
.item-place .cp { color: var(--color-text-muted); font-weight: 400; font-variant-numeric: tabular-nums; }

/* ---------- Compte ---------- */
.acct-btn { position: relative; }
.acct-initial {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--color-primary); color: var(--color-on-primary); font-weight: 600; font-size: var(--text-sm);
}
.auth-providers { display: grid; gap: var(--space-3); }
.prov {
  display: flex; align-items: center; justify-content: center; gap: var(--space-3); height: 50px; cursor: pointer;
  border-radius: var(--radius-sm); font-weight: 600; font-size: var(--text-base); border: 1.5px solid var(--color-border);
}
.prov-apple { background: #000; color: #fff; border-color: #000; }
[data-theme="dark"] .prov-google { border-color: #fff; }
.prov-google { background: #fff; color: #1f1f1f; border-color: #dadce0; }
.prov:active { transform: scale(.99); }
.or { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-6) 0 var(--space-4); color: var(--color-text-faint); font-size: var(--text-sm); }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--color-divider); }
.tabs { display: flex; gap: var(--space-5); border-bottom: 1px solid var(--color-divider); margin-bottom: var(--space-4); }
.tabs button { border: 0; background: none; padding: var(--space-2) 0; cursor: pointer; color: var(--color-text-muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--color-text); border-bottom-color: var(--color-primary); }
.auth-form, #provForm { display: grid; gap: var(--space-3); }
.field { display: grid; gap: 4px; }
.field[hidden] { display: none !important; }
.field span { font-size: var(--text-sm); font-weight: 500; }
.field input {
  height: 48px; border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); padding: 0 var(--space-3);
  background: var(--color-surface); color: var(--color-text); font: inherit;
}
.field input:focus { outline: 0; border-color: var(--color-primary); box-shadow: 0 0 0 4px var(--color-primary-soft); }
.field small { color: var(--color-text-faint); font-size: var(--text-xs); }
.form-err { margin: 0; color: var(--color-target); font-size: var(--text-sm); font-weight: 500; }
.btn-primary, .btn-ghost, .btn-danger { height: 48px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; padding: 0 var(--space-5); }
.btn-primary { background: var(--color-primary); color: var(--color-on-primary); border: 0; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-ghost { background: transparent; border: 1.5px solid var(--color-border); color: var(--color-text); }
.btn-danger { background: transparent; border: 1.5px solid color-mix(in oklab, var(--color-target) 50%, transparent); color: var(--color-target); }
#skipAuth { width: 100%; margin-top: var(--space-3); border: 0; color: var(--color-text-muted); text-decoration: underline; text-underline-offset: 3px; }
.fine { font-size: var(--text-xs); color: var(--color-text-faint); margin: var(--space-4) 0 0; line-height: 1.5; }
.h-sub { font-size: var(--text-lg); margin: var(--space-6) 0 var(--space-3); }
.acct-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-6); }
.acct-actions button { flex: 1; min-width: 160px; }
#authIn .lead { margin-bottom: 0; }

.fav-btn {
  display: inline-flex; align-items: center; gap: var(--space-2); margin-top: var(--space-3); cursor: pointer;
  border: 1.5px solid var(--color-border); background: transparent; border-radius: 999px; padding: 6px var(--space-4);
  font-size: var(--text-sm); font-weight: 500; color: var(--color-text);
}
.fav-btn[aria-pressed="true"] { background: var(--color-primary-soft); border-color: var(--color-primary); color: var(--color-primary); }
.fav-btn[aria-pressed="true"] svg { fill: currentColor; }

.dlg-backdrop { position: absolute; inset: 0; z-index: 1300; background: rgba(20, 20, 18, .45); display: grid; place-items: end center; }
@media (min-width: 560px) { .dlg-backdrop { place-items: center; } }
.dlg { width: 100%; max-width: 440px; background: var(--color-surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: var(--space-6) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom)); }
@media (min-width: 560px) { .dlg { border-radius: var(--radius-lg); } }
.dlg h2 { font-size: var(--text-lg); margin-top: 0; }
.dlg .fine { margin: 0 0 var(--space-4); color: var(--color-text-muted); }
.dlg-actions { display: flex; gap: var(--space-3); margin-top: var(--space-2); }
.dlg-actions button { flex: 1; }
.acct-actions { flex-direction: column; }
.acct-actions button { flex: none; width: 100%; }
.dlg-actions { flex-direction: column-reverse; }

/* ---------- Marque (logo du client) ---------- */
:root { --brand-teal: #1b434d; --brand-cream: #f0e5d0; }
.logo { border-radius: 9px; display: block; }

/* ---------- Écran d'accueil ---------- */
.app.is-welcome .bar { display: none; }
.welcome {
  background: radial-gradient(140% 80% at 50% -10%, #2f6a77 0%, #1b434d 36%, #0f2c34 70%, #081c22 100%);
  color: var(--brand-cream); display: flex; flex-direction: column; justify-content: space-between;
  padding: max(var(--space-10), env(safe-area-inset-top)) var(--space-5) max(var(--space-6), env(safe-area-inset-bottom));
}
.welcome-top { text-align: center; padding-top: var(--space-6); }
.welcome-logo { width: clamp(112px, 34vw, 156px); height: auto; display: block; margin: 0 auto var(--space-5); }
.welcome-name { font-family: var(--font-display); font-weight: 600; font-size: clamp(2.25rem, 1.6rem + 3vw, 3rem); letter-spacing: .01em; margin: 0; color: var(--brand-cream); }
.welcome-tag { margin: var(--space-3) auto 0; max-width: 30ch; color: color-mix(in oklab, var(--brand-cream) 78%, transparent); font-size: var(--text-base); }
.welcome-card { width: 100%; max-width: 420px; margin: var(--space-8) auto 0; }
.welcome-q { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; text-align: center; margin: 0 0 var(--space-1); }
.welcome-why { text-align: center; font-size: var(--text-sm); color: color-mix(in oklab, var(--brand-cream) 72%, transparent); margin: 0 0 var(--space-5); }
.welcome .prov-apple { background: #000; color: #fff; border-color: #000; }
.welcome .prov-google { background: #fff; color: #1f1f1f; border-color: #fff; }
.prov-email { background: transparent; color: var(--color-text); }
.welcome .prov-email { color: var(--brand-cream); border-color: color-mix(in oklab, var(--brand-cream) 45%, transparent); }
.welcome-skip {
  width: 100%; margin-top: var(--space-4); height: 48px; border: 0; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--brand-cream); color: var(--brand-teal); font-weight: 600; font-size: var(--text-base);
}
.welcome-fine { text-align: center; font-size: var(--text-xs); color: color-mix(in oklab, var(--brand-cream) 60%, transparent); margin: var(--space-4) 0 0; }
.welcome :focus-visible { outline: 2px solid var(--brand-cream); outline-offset: 3px; }
@media (max-height: 720px) {
  .welcome { padding-top: max(var(--space-5), env(safe-area-inset-top)); }
  .welcome-top { padding-top: 0; }
  .welcome-logo { width: 96px; margin-bottom: var(--space-3); }
  .welcome-card { margin-top: var(--space-5); }
  .welcome-why { margin-bottom: var(--space-4); }
  .welcome .prov { height: 46px; }
}

/* ---------- Marque appliquée à toute l'application ---------- */
[data-theme="dark"] { --color-on-route: #0f2c34; }
[data-theme="dark"] .bar { background: rgba(10, 33, 40, .55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom-color: var(--color-divider); }
[data-theme="dark"] .brand { color: var(--color-text); }
[data-theme="dark"] .app { background: radial-gradient(140% 75% at 50% -10%, #2a6370 0%, #1b434d 32%, #0f2c34 68%, #081c22 100%); }
[data-theme="dark"] .view { background: transparent; }
[data-theme="dark"] .item { background: var(--color-surface); border-color: var(--color-divider); }
[data-theme="dark"] .item:hover { border-color: color-mix(in oklab, var(--color-primary) 60%, transparent); }
[data-theme="dark"] .search-box, [data-theme="dark"] .select select, [data-theme="dark"] .field input { background: var(--color-surface-2); border-color: var(--color-border); }
[data-theme="dark"] .search-box:focus-within, [data-theme="dark"] .field input:focus, [data-theme="dark"] .select select:focus { box-shadow: 0 0 0 4px rgba(240, 229, 208, .14); border-color: var(--color-primary); }
[data-theme="dark"] .seg { background: var(--color-surface-2); }
[data-theme="dark"] .seg button[aria-checked="true"] { background: var(--color-primary); color: var(--color-on-primary); }
[data-theme="dark"] .chip { border-color: var(--color-border); color: var(--color-text-muted); }
[data-theme="dark"] .chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
[data-theme="dark"] .notice { border: 1px solid var(--color-divider); }
[data-theme="dark"] .notice-soft { background: var(--color-surface-2); color: var(--color-text-muted); }
[data-theme="dark"] .grave { background: var(--color-surface-2); border: 1px solid var(--color-divider); }
[data-theme="dark"] .sheet { background: linear-gradient(180deg, #173c46 0%, #0f2c34 45%, #0b232a 100%); border-top: 1px solid var(--color-border); }
[data-theme="dark"] .toast { background: var(--color-primary); color: var(--color-on-primary); }
[data-theme="dark"] #map, [data-theme="dark"] .leaflet-container { background: #0a2128; }
[data-theme="dark"] .tool { background: var(--color-surface); border-color: var(--color-border); box-shadow: 0 2px 10px rgba(0,0,0,.3); }
[data-theme="dark"] .dlg { background: var(--color-bg); border: 1px solid var(--color-divider); }
[data-theme="dark"] .dlg-backdrop { background: rgba(6, 20, 24, .6); }
[data-theme="dark"] .acct-initial { background: var(--color-primary); color: var(--color-on-primary); }
[data-theme="dark"] .fav-btn[aria-pressed="true"] { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
[data-theme="dark"] .item-num strong, [data-theme="dark"] .grave-num strong, [data-theme="dark"] .grave-num span { color: var(--color-primary); }
[data-theme="dark"] .steps li::before { background: var(--color-surface); color: var(--color-text-muted); }
[data-theme="dark"] .steps li:first-child::before { background: var(--color-route); color: var(--color-on-route); }
[data-theme="dark"] .btn-danger { color: var(--color-target); }
[data-theme="dark"] .form-err { color: #ffb197; }
[data-theme="dark"] .item { background: linear-gradient(180deg, rgba(36, 86, 98, .55), rgba(23, 60, 70, .55)); }
[data-theme="dark"] .welcome { background: transparent; }

/* ---------- Demande de nettoyage ---------- */
.clean-cta {
  width: 100%; display: flex; align-items: center; gap: var(--space-3); text-align: left; cursor: pointer;
  margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4);
  background: var(--color-primary); color: var(--color-on-primary); border: 0; border-radius: var(--radius-md);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.clean-cta img { flex: none; width: 36px; height: 36px; border-radius: 8px; background: #1b434d; padding: 3px; }
.clean-cta-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.clean-cta-txt strong { font-size: var(--text-base); }
.clean-cta-txt span { font-size: var(--text-xs); opacity: .8; }
.clean-cta:active { transform: scale(.99); }
.clean-target {
  display: flex; gap: var(--space-4); align-items: center; padding: var(--space-4);
  background: var(--color-surface-2); border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.ct-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: var(--text-sm); color: var(--color-text-muted); }
.ct-main strong { font-family: var(--font-display); font-size: var(--text-lg); color: var(--color-text); font-weight: 600; }
.ct-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.ct-num { text-align: center; padding-left: var(--space-4); border-left: 1px solid var(--color-divider); }
.ct-num span { display: block; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--color-text-muted); font-weight: 600; }
.ct-num strong { display: block; font-family: var(--font-display); font-size: var(--text-xl); color: var(--color-primary); line-height: 1.1; }
.ct-num small { color: var(--color-text-faint); font-size: var(--text-xs); white-space: nowrap; }
.opts { display: grid; gap: var(--space-2); }
.opt {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); cursor: pointer;
  background: var(--color-surface); border: 1.5px solid var(--color-divider); border-radius: var(--radius-md);
}
.opt input { flex: none; width: 20px; height: 20px; accent-color: var(--color-primary); margin: 0; }
.opt-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.opt-body strong { font-weight: 600; font-size: var(--text-sm); }
.opt-body small { color: var(--color-text-muted); font-size: var(--text-xs); }
.opt-price { font-family: var(--font-display); font-weight: 600; white-space: nowrap; color: var(--color-primary); }
.opt:has(input:checked) { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.opt-best .opt-body strong::after { content: "Le plus complet"; margin-left: var(--space-2); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; padding: 2px 6px; border-radius: 99px; background: var(--color-route); color: var(--color-on-route, #fff); vertical-align: 2px; }
.opt-add { margin-top: var(--space-3); border-style: dashed; }
.opt-add.is-included { opacity: .75; cursor: default; }
.total { display: flex; justify-content: space-between; align-items: baseline; margin: var(--space-4) 0 0; padding-top: var(--space-3); border-top: 1px solid var(--color-divider); }
.total span { color: var(--color-text-muted); }
.total strong { font-family: var(--font-display); font-size: var(--text-xl); color: var(--color-primary); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.field em { font-style: normal; color: var(--color-text-faint); font-weight: 400; }
.field textarea {
  border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); padding: var(--space-3);
  background: var(--color-surface); color: var(--color-text); font: inherit; resize: vertical;
}
.field textarea:focus { outline: 0; border-color: var(--color-primary); box-shadow: 0 0 0 4px var(--color-primary-soft); }
[data-theme="dark"] .field textarea { background: var(--color-surface-2); border-color: var(--color-border); }
.check { display: flex; gap: var(--space-3); align-items: flex-start; font-size: var(--text-sm); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--color-primary); flex: none; }
.check .link { font-size: inherit; }
.cgv { max-height: 220px; overflow-y: auto; font-size: var(--text-xs); color: var(--color-text-muted); padding: var(--space-3) var(--space-4); border: 1px solid var(--color-divider); border-radius: var(--radius-sm); background: var(--color-surface-2); }
.cgv p { margin: 0 0 var(--space-2); }
.cgv b { color: var(--color-text); }
.clean-summary dl { margin: 0 0 var(--space-5); padding: var(--space-4); background: var(--color-surface-2); border: 1px solid var(--color-divider); border-radius: var(--radius-md); display: grid; grid-template-columns: auto 1fr; gap: var(--space-2) var(--space-4); font-size: var(--text-sm); }
.clean-summary dt { color: var(--color-text-muted); }
.clean-summary dd { margin: 0; }
.clean-summary .muted { color: var(--color-text-faint); }
.btn-link { display: flex; align-items: center; justify-content: center; text-decoration: none; width: 100%; margin-top: var(--space-3); }
.fine.center { text-align: center; margin-top: var(--space-2); }
#cleanF .btn-primary { margin-top: var(--space-2); }
.row2 > .field { min-width: 0; }
.field input, .field textarea { width: 100%; min-width: 0; }
.opt-best .opt-body strong::after { display: table; margin: 3px 0 1px; }

/* ---------- ORDINATEUR : fenêtre 16:9 horizontale (mobile inchangé) ---------- */
@media (min-width: 1024px) and (min-height: 540px) {
  body {
    min-height: 100vh; display: grid; place-items: center; overflow: hidden;
    background: radial-gradient(90% 90% at 50% 0%, #0c2830 0%, #04141a 70%);
  }
  .app {
    width: min(94vw, calc(86vh * 16 / 9)); aspect-ratio: 16 / 9; height: auto;
    max-width: none; margin: 0; border: 1px solid rgba(240, 229, 208, .14);
    border-radius: 22px; box-shadow: 0 30px 90px rgba(0, 0, 0, .55); overflow: hidden;
  }
  .bar { border-radius: 22px 22px 0 0; }
  .brand-name { font-size: var(--text-base); }

  /* Accueil : logo et nom à gauche, carte de connexion à droite */
  .welcome {
    flex-direction: row; align-items: center; justify-content: space-between;
    gap: clamp(32px, 6vw, 90px); padding: var(--space-8) clamp(40px, 7vw, 100px);
  }
  .welcome-top { text-align: center; padding-top: 0; display: flex; flex-direction: column; align-items: center; }
  .welcome-logo { margin: 0 0 var(--space-5); width: clamp(120px, 11vw, 168px); }
  .welcome-name { font-size: clamp(2.4rem, 3.4vw, 3.4rem); }
  .welcome-tag { margin: var(--space-3) 0 0; text-align: center; max-width: 34ch; }
  .welcome-card { max-width: 430px; margin-top: 0; }
  .welcome-q, .welcome-why { text-align: left; }
  .welcome-top .welcome-name { text-align: center; }

  /* Cimetières / recherche : recherche à gauche, résultats à droite */
  #cemView, #searchView { display: grid; overflow: hidden; grid-template-columns: minmax(300px, 400px) 1fr; grid-template-rows: 1fr auto; column-gap: 0; }
  #cemView .search-head, #searchView .search-head {
    grid-row: 1 / 3; padding: var(--space-8) var(--space-6); height: 100%;
    border-right: 1px solid var(--color-divider);
  }
  #cemView .results, #searchView .results { grid-column: 2; overflow-y: auto; padding: var(--space-8) var(--space-8) var(--space-4); align-content: start; }
  #cemView .notice, #searchView .notice { grid-column: 2; margin: 0 var(--space-8) var(--space-6); }

  /* Compte : colonne centrée */
  #accountView { display: block; }
  #authOut, #authIn { max-width: 460px; margin-inline: auto; }

  /* Nettoyage : prestations à gauche, coordonnées à droite */
  #cleanView { overflow-y: auto; }
  #cleanForm { display: grid; grid-template-columns: 1fr 1fr; gap: 0 clamp(28px, 4vw, 56px); align-content: start; max-width: 980px; margin: 0 auto; padding: var(--space-8) var(--space-6); }
  #cleanForm > .step-tag, #cleanForm > h1, #cleanForm > .lead, #cleanForm > .clean-target { grid-column: 1 / -1; }
  #cleanDone { max-width: 520px; margin: 0 auto; padding: var(--space-8) var(--space-5); }

  /* Fiche + plan : carte à gauche, fiche en panneau à droite */
  #map { right: 420px; bottom: 0 !important; }
  #mapView .sheet {
    left: auto; right: 0; top: 0; bottom: 0; width: 420px; max-height: none;
    border-radius: 0; border-left: 1px solid var(--color-border); box-shadow: none; height: auto;
  }
  #mapView .sheet.collapsed, #mapView .sheet.expanded { max-height: none; }
  #mapView .sheet-body { flex: 1; padding-bottom: var(--space-6); }
  #mapView .grip { display: none; }
}

/* Formulaire nettoyage : deux colonnes nettes sur PC */
@media (min-width: 1024px) and (min-height: 540px) {
  .clean-col { display: flex; flex-direction: column; }
  #cleanForm .clean-col:first-of-type { padding-right: clamp(28px, 4vw, 56px); border-right: 1px solid var(--color-divider); }
  #cleanForm .clean-col:last-of-type { padding-left: clamp(28px, 4vw, 56px); }
}

/* ---------- Liste complète + vue satellite ---------- */
.badge-plan {
  display: inline-block; vertical-align: 1px; margin-left: var(--space-2); padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  background: var(--color-primary); color: var(--color-on-primary);
}
[data-theme="dark"] .badge-plan { background: var(--color-route); color: var(--color-on-route); }
#satmap { position: absolute; inset: 0; background: var(--color-surface-2); }
#satmap .leaflet-container, #satmap { cursor: default; }
#satmap .leaflet-control-attribution { max-width: 100%; }
.leaflet-control-attribution { font-size: 10px; }

/* Saisie manuelle : colonne centrée sur PC */
@media (min-width: 1024px) and (min-height: 540px) {
  #manualView .search-head { max-width: 560px; margin: 0 auto; width: 100%; }
}

/* Satellite et saisie du proche sur la même page. */
.satellite-preview { position: relative; height: 280px; min-height: 240px; flex: none; }
.satellite-preview #satmap { inset: 0; cursor: grab; }
.satellite-recenter { position: absolute; top: 12px; right: 12px; z-index: 500; width: auto; padding: 0 12px; font-size: 14px; }
#manualView .search-head { padding-top: var(--space-5); }
@media (min-width: 1024px) and (min-height: 540px) {
  #manualView { display: grid; grid-template-columns: 1fr 440px; overflow: hidden; }
  #manualView .satellite-preview { height: 100%; min-height: 0; }
  #manualView .search-head { overflow-y: auto; height: 100%; max-width: none; margin: 0; padding: var(--space-6); border-left: 1px solid var(--color-divider); }
}

/* Parcours de devis : une décision à la fois, sans changer l'identité. */
.welcome-path { margin: var(--space-5) 0 0; font-size: 14px; color: var(--brand-cream); opacity: .9; }
.premium-logo { filter: drop-shadow(0 1px 0 rgba(255, 245, 216, .25)) drop-shadow(1px 3px 2px rgba(0, 0, 0, .44)); }
.welcome-logo.premium-logo { filter: drop-shadow(0 1px 0 rgba(255, 245, 216, .3)) drop-shadow(2px 7px 4px rgba(0, 0, 0, .4)); }
.welcome-name { text-shadow: 0 1px 0 rgba(255, 249, 224, .24), 1px 3px 2px rgba(0, 0, 0, .42); }
.preopening-label { display: inline-block; border: 1px solid rgba(241, 231, 207, .45); border-radius: 99px; margin-top: 18px; padding: 7px 13px; color: var(--brand-cream); font-size: 14px; line-height: 1.35; }
.coverage-note { border-left: 2px solid var(--color-primary); margin: 16px 0 24px; padding: 4px 0 4px 14px; font-size: 14px; line-height: 1.6; color: var(--color-text); }
.request-progress { list-style: none; display: flex; gap: 12px; padding: 0; margin: 0 0 24px; }
.request-progress li { display: flex; align-items: center; gap: 6px; color: var(--color-text-muted); font-size: 14px; }
.request-progress li > span { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border: 1px solid var(--color-border); border-radius: 50%; font-size: 13px; }
.request-progress li[aria-current="step"] { color: var(--color-primary); font-weight: 600; }
.request-progress li[aria-current="step"] > span { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.request-buttons { display: grid; gap: 10px; margin-top: 20px; }
.request-buttons button { height: auto; min-height: 48px; padding: 12px 16px; line-height: 1.35; }
#cleanForm .clean-col[hidden] { display: none !important; }
#editRequest { width: 100%; margin-top: 12px; }
.mail-fallback, .monument-details { margin: 12px 0; border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 12px; font-size: 15px; }
.mail-fallback summary, .monument-details summary { cursor: pointer; min-height: 26px; color: var(--color-primary); }
.mail-fallback[open] summary, .monument-details[open] summary { margin-bottom: 12px; }
.mail-fallback p { color: var(--color-text-muted); overflow-wrap: anywhere; }
.mail-fallback textarea { font-size: 14px; line-height: 1.55; }
.mail-fallback button { width: 100%; margin-top: 12px; }
.monument-details { margin: 0; }
.fine, .welcome-fine, .field small { font-size: 14px; line-height: 1.55; }
.fine { color: var(--color-text-muted); }
.welcome-fine { color: var(--brand-cream); opacity: .85; }
.welcome-card .welcome-fine { max-width: 40ch; margin-inline: auto; }
.notice { line-height: 1.6; }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 4px; }
h1:focus, h2:focus { outline: none; }
#cleanTarget { overflow-wrap: anywhere; }
.clean-summary dd { min-width: 0; overflow-wrap: anywhere; }
.review-comment { white-space: pre-wrap; }
@media (min-width: 1024px) and (min-height: 540px) {
  #cleanForm { grid-template-columns: minmax(230px, .8fr) minmax(360px, 1.2fr); grid-template-rows: auto auto auto auto minmax(0, 1fr); gap: 0 40px; max-width: 1050px; height: 100%; }
  #cleanForm > .request-progress { grid-column: 1 / -1; }
  #cleanForm > .clean-target { grid-column: 1; align-self: start; flex-direction: column; align-items: stretch; padding: 24px; margin-top: 24px; }
  #cleanForm > .monument-context { grid-column: 1; grid-row: 5; min-height: 0; overflow-y: auto; margin-top: 12px; }
  .monument-context .clean-target { flex-direction: column; align-items: stretch; padding: 24px; }
  #cleanTarget .ct-num { border-left: 0; border-top: 1px solid var(--color-divider); padding: 16px 0 0; text-align: left; }
  #cleanForm > .clean-col { grid-column: 2; grid-row: 5; padding: 0 !important; border: 0 !important; min-width: 0; min-height: 0; overflow-y: auto; }
  #cleanForm .clean-col > .h-sub { margin-top: 12px; }
  #cleanForm #servicePanel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; }
  #serviceChoices { overflow-y: auto; padding: 4px; scrollbar-gutter: stable; }
  #serviceFooter .fine { font-size: 13px; margin-top: 8px; }
  #serviceFooter .total { margin-top: 12px; }
  #serviceFooter .request-buttons { margin-top: 12px; }
}
@media (max-width: 380px) {
  .request-progress { gap: 8px; }
  .request-progress li { gap: 4px; font-size: 13px; }
}
@media (min-width: 1024px) and (min-height: 540px) {
  #cleanForm > .lead { max-width: none; }
  #serviceChoices { scrollbar-width: thin; scrollbar-color: var(--color-border) transparent; }
}
/* Une petite hauteur ne doit jamais réduire les choix à une bande illisible. */
@media (min-width: 1024px) and (min-height: 540px) and (max-height: 820px) {
  #cleanForm { height: auto; min-height: 100%; grid-template-rows: auto auto auto auto auto; padding-block: 20px; }
  #cleanForm #servicePanel { display: block; overflow: visible; }
  #cleanForm > .clean-col { overflow: visible; }
  #serviceChoices { overflow: visible; }
  #cleanForm > .request-progress { margin-bottom: 12px; }
  #cleanForm > .lead { margin-bottom: 12px; }
  #cleanForm > .monument-context { overflow: visible; }
}
