/* Layout : panneau de terrain à gauche (recherche, liste, fiche), carte plein cadre à droite ; empilés sur mobile */
:root {
  --bg: #eef0ea;
  --surface: #fbfcf8;
  --ink: #1d2620;
  --ink-2: #48554b;
  --muted: #6c786f;
  --line: #d5dacf;
  --accent: #2d6a49;
  --accent-ink: #ffffff;
  --obs: #17766a;
  --map-bg: #e3e7de;
  --dep-line: rgba(29, 38, 32, 0.38);
  --r0: #efe7d7; --r1: #e4d0a9; --r2: #d5b07a; --r3: #bf8b4f; --r4: #a1662f; --r5: #7a461b; --r6: #4e2a0e;
  --bar: #a1662f;
  --rain: #3f74b5; --tx: #c0562c; --tn: #4f8a8b;
  --go: #c2410c; --go-ink: #ffffff; --maybe: #e3a008; --maybe-ink: #2a1a00; --no: #7d877f; --no-ink: #ffffff;
  --f-display: "Alegreya", Georgia, "Times New Roman", serif;
  --f-body: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  --f-data: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121814; --surface: #19211c; --ink: #e5eae2; --ink-2: #b8c2b9; --muted: #8b978e; --line: #2c3730;
    --accent: #7cc49b; --accent-ink: #0d1a12; --obs: #63d2bf; --map-bg: #161d18; --dep-line: rgba(229, 234, 226, 0.32);
    --r0: #2b241d; --r1: #4a3622; --r2: #6e4c2a; --r3: #956634; --r4: #bc8545; --r5: #dca865; --r6: #f3cf94;
    --bar: #bc8545; --rain: #79a7e3; --tx: #ec8a5e; --tn: #7cc3c1; --go: #f27a3d; --go-ink: #1d0c02; --maybe: #f0c24b; --maybe-ink: #241700; --no: #6d786f; --no-ink: #f2f4f0; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121814; --surface: #19211c; --ink: #e5eae2; --ink-2: #b8c2b9; --muted: #8b978e; --line: #2c3730;
  --accent: #7cc49b; --accent-ink: #0d1a12; --obs: #63d2bf; --map-bg: #161d18; --dep-line: rgba(229, 234, 226, 0.32);
  --r0: #2b241d; --r1: #4a3622; --r2: #6e4c2a; --r3: #956634; --r4: #bc8545; --r5: #dca865; --r6: #f3cf94;
  --bar: #bc8545; --rain: #79a7e3; --tx: #ec8a5e; --tn: #7cc3c1; --go: #f27a3d; --go-ink: #1d0c02; --maybe: #f0c24b; --maybe-ink: #241700; --no: #6d786f; --no-ink: #f2f4f0; color-scheme: dark;
}
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45; }
.app { display: grid; grid-template-columns: minmax(340px, 400px) 1fr; height: 100%; }
.panel { overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line);
  padding-block: 20px 28px; padding-left: max(18px, env(safe-area-inset-left, 0px)); padding-right: max(18px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.mapwrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--map-bg); }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; }
  .mapwrap { height: 62vh; order: -1; }
  .panel { overflow: visible; border-right: 0; border-top: 1px solid var(--line); }
}
h1 { font-family: var(--f-display); font-weight: 800; font-size: 1.85rem; line-height: 1.05; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-family: var(--f-display); font-weight: 700; font-size: 1.15rem; margin: 0; text-wrap: balance; }
.lede { color: var(--ink-2); margin: 6px 0 0; }
.eyebrow { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 700; }
.num { font-variant-numeric: tabular-nums lining-nums; }
section { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* recherche */
.search { display: grid; grid-template-columns: 1fr auto; gap: 8px; position: relative; }
.search input, .search select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; min-width: 0; }
.search input:focus-visible, .search select:focus-visible, button:focus-visible, a:focus-visible, .row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.suggest { position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; z-index: 1200; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); list-style: none; padding: 4px; margin-block: 4px 0; }
.suggest li { padding: 7px 9px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--bg); }
.suggest .cp { color: var(--muted); font-variant-numeric: tabular-nums; }

/* liste des carreaux */
.list { display: flex; flex-direction: column; gap: 2px; }
.row { display: grid; grid-template-columns: 46px 1fr auto; gap: 10px; align-items: center; padding: 8px 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.row:hover { background: var(--bg); }
.row.on { border-color: var(--accent); background: var(--bg); }
.row .where { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .dist { color: var(--ink-2); font-size: 0.85rem; text-align: right; white-space: nowrap; }
.row > div { min-width: 0; }
.pill { display: inline-grid; place-items: center; min-width: 42px; height: 30px; border-radius: 15px; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.95rem; }

/* fiche */
.card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 14px; background: var(--surface); }
.card-head { display: flex; gap: 12px; align-items: center; }
.card-head .pill { min-width: 54px; height: 40px; border-radius: 20px; font-size: 1.2rem; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin: 0; }
.facts div { display: flex; flex-direction: column; }
.facts dt { font-size: 0.78rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.bars { display: flex; flex-direction: column; gap: 5px; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) 90px 36px; gap: 8px; align-items: center; font-size: 0.9rem; }
.bar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.bar .fill { height: 100%; border-radius: 4px; background: var(--bar); }
.bar .v { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tag { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); font-weight: 700; margin-left: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { font: inherit; font-weight: 700; font-size: 0.9rem; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--accent); color: var(--accent); background: transparent; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.note { font-size: 0.85rem; color: var(--muted); margin: 0; }
.empty { color: var(--muted); font-style: italic; margin: 0; }

/* légende & saison */
.legend { display: flex; flex-direction: column; gap: 6px; }
.ramp { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--r0), var(--r1), var(--r2), var(--r3), var(--r4), var(--r5), var(--r6)); }
.ticks { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--obs); box-shadow: 0 0 0 2px var(--surface); display: inline-block; }
.season { position: relative; }
.season svg { width: 100%; height: auto; display: block; overflow: visible; }
.season text { fill: var(--muted); font-family: var(--f-body); font-size: 11px; }
.season .now { fill: var(--ink); font-weight: 700; }
.season rect.b { fill: var(--bar); }
.season rect.hit { fill: transparent; cursor: default; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); font-size: 0.82rem; padding: 6px 9px; border-radius: 6px; white-space: nowrap; z-index: 1000; transform: translate(-50%, calc(-100% - 10px)); }
details { border-top: 1px solid var(--line); padding-top: 12px; }
details summary { cursor: pointer; font-family: var(--f-display); font-weight: 700; font-size: 1.05rem; }
details p, details li { color: var(--ink-2); font-size: 0.9rem; max-width: 65ch; }
details ul { padding-left: 18px; margin: 6px 0; }
.leaflet-container { background: var(--map-bg); font-family: var(--f-body); }
.leaflet-control-zoom a { background: var(--surface) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.leaflet-top.leaflet-left .leaflet-control { margin: max(14px, env(safe-area-inset-top, 0px)) 0 0 14px; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 85%, transparent) !important; color: var(--muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--ink-2) !important; }
.maptip { position: absolute; z-index: 800; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 0.85rem; box-shadow: 0 6px 18px rgba(0,0,0,.16); max-width: 240px; }
.maptip b { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); z-index: 900; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
.warn { margin: 0; padding: 9px 11px; border-radius: 8px; font-size: 0.88rem; color: var(--ink); background: var(--bg); border: 1px dashed var(--ink-2); }
.mapstatus { position: absolute; z-index: 850; left: 50%; transform: translateX(-50%); bottom: calc(26px + env(safe-area-inset-bottom, 0px)); background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 0.85rem; max-width: calc(100% - 32px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.wx svg { width: 100%; height: auto; display: block; overflow: visible; }
.wx text { font-family: var(--f-body); font-size: 10px; fill: var(--muted); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.wx .rain { fill: var(--rain); }
.wx .tx { stroke: var(--tx); fill: none; stroke-width: 1.6; }
.wx .tn { stroke: var(--tn); fill: none; stroke-width: 1.6; }
.wx .grid { stroke: var(--line); stroke-width: 1; }
.wx .fcbg { fill: var(--line); opacity: 0.35; }
.wx .sel { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 3; }
.wx .key { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.8rem; color: var(--ink-2); margin-top: 4px; }
.wx .key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

/* --- Cèpomètre : tunnel « ta zone » et thermomètre ------------------------------------------- */
.brand { display: flex; gap: 10px; align-items: center; }
.brand img { width: 46px; height: 46px; flex: none; }
.brand h1 { font-size: 1.7rem; }
.brand p { margin: 1px 0 0; color: var(--muted); font-size: 0.85rem; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 700; }
.step { gap: 14px; }
.hero { display: grid; grid-template-columns: 54px 1fr; gap: 14px; align-items: center; }
.hero-meter { width: 54px; height: auto; }
h2.big { font-size: 1.65rem; line-height: 1.1; }
.t-glass { fill: var(--bg); stroke: var(--line); stroke-width: 2; }
.t-merc { fill: var(--go); }
.anim { transform-box: fill-box; transform-origin: bottom; animation: rise 2.4s ease-in-out infinite alternate; }
@keyframes rise { from { transform: scaleY(0.45); } to { transform: scaleY(1.1); } }
@media (prefers-reduced-motion: reduce) { .anim { animation: none; } }
.cta { font: inherit; font-size: 1.08rem; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px 16px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.14); }
.cta svg { width: 20px; height: 20px; }
.cta[aria-busy="true"] { opacity: 0.7; cursor: progress; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.85rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.search { grid-template-columns: 1fr; }
.search input { padding: 12px 13px; font-size: 1rem; }
.pickhint { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ink-2); font-size: 0.95rem; }
.pickhint svg { width: 18px; height: 18px; color: var(--accent); flex: none; }

.zonebar { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.zname { font-family: var(--f-display); font-weight: 800; font-size: 1.3rem; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkbtn { font: inherit; font-weight: 700; color: var(--accent); background: none; border: 1px solid var(--accent); border-radius: 999px; padding: 6px 12px; cursor: pointer; flex: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { font: inherit; font-size: 0.85rem; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--ink-2); cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); font-weight: 700; }

/* le thermomètre */
.meter { display: grid; grid-template-columns: 112px 1fr; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px 12px 6px; background: var(--bg); }
.meter.go { border-color: var(--go); }
.meter.maybe { border-color: var(--maybe); }
.meter svg { width: 112px; height: auto; display: block; }
.meter svg text { font-family: var(--f-body); fill: var(--muted); font-size: 10px; }
.meter svg text.band { font-weight: 700; font-size: 10.5px; }
.meter svg text.val { font-family: var(--f-display); font-weight: 800; font-size: 17px; fill: #fff; }
.meter .tick { stroke: var(--muted); stroke-width: 1; }
.meter .merc { transition: height .6s ease, y .6s ease; }
.meter .big { font-family: var(--f-display); font-weight: 800; font-size: 1.7rem; line-height: 1.05; margin: 0 0 6px; }
.meter .why { margin: 0 0 6px; font-size: 1rem; line-height: 1.35; }
.meter .trend { margin: 0; font-weight: 700; color: var(--ink-2); font-size: 0.95rem; }
.meter .when { margin: 0 0 2px; }

.week { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.week button { font: inherit; border: 1px solid transparent; background: none; border-radius: 10px; padding: 6px 0 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 0.72rem; min-width: 0; }
.week button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); font-weight: 700; background: var(--bg); }
.week svg { width: 18px; height: 52px; }
.week b { font-size: 0.78rem; color: var(--ink); font-variant-numeric: tabular-nums; }

.chip { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.75rem; border-radius: 999px; padding: 4px 8px; white-space: nowrap; min-width: 62px; }
.chip.go { background: var(--go); color: var(--go-ink); }
.chip.maybe { background: var(--maybe); color: var(--maybe-ink); }
.chip.no { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.row { grid-template-columns: 96px minmax(0, 1fr) auto; }
.row > .chip, .row > .pill { justify-self: start; }
.row .dist b { color: var(--ink); }
.row .where { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.2; }
.listhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
section.sub { gap: 8px; }
details.priv { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; }
details.priv summary { font-size: 1rem; }
details#legend { display: flex; flex-direction: column; gap: 8px; }
details#legend[open] > *:not(summary) { margin-top: 8px; }

.maphint { position: absolute; z-index: 850; top: max(14px, env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: 0.92rem; box-shadow: 0 4px 14px rgba(0,0,0,.25); pointer-events: none; white-space: nowrap; }
.app[data-step="result"] .maphint { display: none; }
.app[data-step="zone"] .leaflet-container { cursor: crosshair; }
.basebtns { position: absolute; z-index: 850; right: 12px; bottom: calc(28px + env(safe-area-inset-bottom, 0px)); display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.basebtns button { font: inherit; font-size: 0.82rem; padding: 6px 10px; border: 0; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.basebtns button[aria-pressed="true"] { background: var(--ink); color: var(--surface); font-weight: 700; }
.stale { position: absolute; z-index: 860; top: 56px; left: 50%; transform: translateX(-50%); background: var(--maybe); color: var(--maybe-ink); border-radius: 8px; padding: 6px 12px; font-size: 0.85rem; font-weight: 700; max-width: calc(100% - 32px); box-shadow: 0 4px 14px rgba(0,0,0,.14); }
.mapstatus { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
.leaflet-popup-content-wrapper { background: var(--surface); color: var(--ink); border-radius: 10px; }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 10px 12px; font-family: var(--f-body); font-size: 0.92rem; }
.pickpop b { display: block; margin-bottom: 6px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 0.9rem; padding: 8px 10px; border: 0; background: var(--bg); color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.keys { display: flex; flex-direction: column; gap: 5px; font-size: 0.9rem; }
.keys span { display: flex; align-items: center; gap: 8px; }
.keys i { width: 22px; height: 12px; border-radius: 3px; flex: none; }
.keys i.dash { border: 1.5px dashed var(--ink-2); }
.keys i.ring { border: 1.5px solid var(--ink-2); }
.daystrip { display: flex; gap: 2px; }
.daystrip span { flex: 1; height: 10px; border-radius: 2px; }
.wxhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* fonds IGN : plan atténué ; en thème sombre, plan inversé et photo assombrie */
.base-plan .leaflet-tile-pane { filter: grayscale(0.8) contrast(0.92) brightness(1.04); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .base-plan .leaflet-tile-pane { filter: grayscale(0.8) invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9); }
  :root:not([data-theme="light"]) .base-photo .leaflet-tile-pane { filter: brightness(0.85); }
}
:root[data-theme="dark"] .base-plan .leaflet-tile-pane { filter: grayscale(0.8) invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9); }
:root[data-theme="dark"] .base-photo .leaflet-tile-pane { filter: brightness(0.85); }

@media (max-width: 860px) {
  /* téléphone : nom, étape du tunnel, puis la carte, puis le reste */
  .app { display: flex; flex-direction: column; gap: 16px; background: var(--surface); height: auto; }
  .panel { display: contents; }
  .panel > * { order: 5; margin-inline: max(16px, env(safe-area-inset-left, 0px)); }
  .panel > .brand { order: 1; margin-top: 14px; }
  .panel > .step { order: 2; }
  .panel > #detail { order: 4; }
  .panel > details:last-child { margin-bottom: 28px; }
  .mapwrap { order: 3; height: 50vh; border-block: 1px solid var(--line); }
  .app[data-step="zone"] .mapwrap { height: 46vh; }
  .brand h1 { font-size: 1.45rem; }
  .brand img { width: 40px; height: 40px; }
  h2.big { font-size: 1.45rem; }
  .meter { grid-template-columns: 92px 1fr; }
  .meter svg { width: 92px; }
  .meter .big { font-size: 1.45rem; }
}
