/* BikeLoop — design « Carte immersive » */
:root {
  --glass: rgba(255, 255, 255, .80);
  --glass-strong: rgba(255, 255, 255, .92);
  --text: #0f1f1c;
  --muted: #5b6b67;
  --line: rgba(15, 31, 28, .10);
  --soft: rgba(15, 31, 28, .06);
  --accent: #0f766e;
  --accent-2: #14b8a6;
  --accent-soft: rgba(15, 118, 110, .12);
  --danger: #c2410c;
  --water: #1c7ed6;
  --shadow: 0 10px 40px rgba(15, 31, 28, .18);
  --top: 16px;
  --gap: 16px;
  --col-w: 352px;
  --bar-h: 50px;
  font-synthesis: none;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #dfe7e4; color: var(--text); font: 14px/1.45 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- barre de défilement BikeLoop : rail discret + curseur en dégradé turquoise ---------- */
* { scrollbar-width: thin; scrollbar-color: #14b8a6 rgba(15, 31, 28, .06); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: rgba(15, 31, 28, .05); border-radius: 12px; margin: 18px 0; border: 4px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #2dd4bf, #0f766e); border-radius: 12px; border: 3px solid transparent; background-clip: padding-box; min-height: 40px; }
::-webkit-scrollbar-thumb:hover { border-width: 2px; background: linear-gradient(180deg, #14b8a6, #0b5e57); background-clip: padding-box; }
::-webkit-scrollbar-thumb:active { background: #0b5e57; background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ic.sm { width: 15px; height: 15px; }
.ic.xs { width: 13px; height: 13px; }
.ic.fill { fill: currentColor; stroke: none; }

#map { position: fixed; inset: 0; z-index: 0; background: #dfe7e4; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; background: rgba(255, 255, 255, .7) !important; border-radius: 8px 0 0 0; }
.leaflet-control-zoom { border: 0 !important; box-shadow: var(--shadow) !important; border-radius: 14px !important; overflow: hidden; }
.leaflet-control-zoom a { background: var(--glass-strong) !important; color: var(--text) !important; border-color: var(--line) !important; width: 38px !important; height: 38px !important; line-height: 38px !important; }
.leaflet-top.leaflet-right { top: calc(var(--top) + var(--bar-h) + 6px); right: calc(var(--gap) - 10px); }
.picking #map, .picking .leaflet-container { cursor: crosshair !important; }

.glass { background: var(--glass); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4); border: 1px solid rgba(255, 255, 255, .65); box-shadow: var(--shadow); }

/* ---------- barre du haut ---------- */
.top { position: fixed; top: var(--top); left: var(--gap); right: var(--gap); z-index: 600; display: flex; gap: 10px; align-items: center; pointer-events: none; }
.top > * { pointer-events: auto; }
.search { position: relative; width: var(--col-w); height: var(--bar-h); border-radius: 17px; display: flex; align-items: center; gap: 6px; padding: 0 6px 0 14px; }
.search > .ic { color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-weight: 500; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 0; display: grid; place-items: center; background: var(--soft); color: var(--text); flex-shrink: 0; }
.icon-btn.accent { background: var(--accent); color: #fff; }
.icon-btn.dark { background: var(--text); color: #fff; }
.icon-btn:hover { filter: brightness(.95); }
.mode-wrap, .tool-wrap { position: relative; }
.tool-wrap { margin-left: auto; display: flex; height: var(--bar-h); border-radius: 17px; overflow: visible; }
.tool-main, .tool-more { border: 0; background: none; display: grid; place-items: center; color: var(--text); }
.tool-main { width: 50px; border-radius: 16px 0 0 16px; }
.tool-more { width: 30px; border-radius: 0 16px 16px 0; border-left: 1px solid var(--line); color: var(--muted); }
.tool-main:hover, .tool-more:hover { background: var(--soft); }
.tool-main.on { color: var(--accent); }
.menu { position: absolute; top: calc(100% + 8px); right: 0; min-width: 220px; border-radius: 16px; padding: 6px; z-index: 700; }
.mode-wrap .menu { right: -6px; }
.menu .mh { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 6px 10px 4px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px; border: 0; background: none; border-radius: 10px; text-align: left; font-weight: 600; }
.menu button small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.menu button:hover { background: var(--soft); }
.menu button.on { color: var(--accent); background: var(--accent-soft); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.dropdown { position: absolute; top: calc(100% + 8px); left: 0; right: 0; border-radius: 16px; padding: 6px; z-index: 700; max-height: 300px; overflow-y: auto; }
.dropdown button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 10px; font-size: 13px; }
.dropdown button:hover, .dropdown button:focus { background: var(--soft); outline: 0; }
.dropdown small { display: block; color: var(--muted); }

/* ---------- colonne de gauche : réglages + résultats, l'un sous l'autre, sur toute la hauteur ---------- */
.side { position: fixed; top: calc(var(--top) + var(--bar-h) + 12px); bottom: var(--gap); left: var(--gap); width: var(--col-w); z-index: 500; display: flex; flex-direction: column; gap: 12px; pointer-events: none; }
.side > * { pointer-events: auto; }
.panel { flex: 0 1 auto; min-height: 0; border-radius: 22px; padding: 16px 12px 14px 16px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
body.has-sheet .panel { flex-shrink: 1; min-height: 140px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head b { font-size: 16px; }
.sec + .sec { margin-top: 12px; }
.lbl { font-size: 12px; font-weight: 700; color: var(--muted); margin: 0 0 6px; display: flex; align-items: center; gap: 6px; }
.lbl .grow { flex: 1; }
.info-btn { width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; padding: 0; }
.info-btn .ic { width: 13px; height: 13px; stroke-width: 2.6; }
.pill { display: flex; background: var(--soft); border-radius: 13px; padding: 3px; gap: 3px; }
.pill button { flex: 1; border: 0; background: none; padding: 6px 0; border-radius: 10px; font-weight: 600; color: var(--muted); }
.pill button.on { background: #fff; color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
.goal { display: flex; align-items: baseline; gap: 6px; margin: 6px 0 0; }
.goal b { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.goal span { color: var(--muted); font-weight: 600; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 4px 0 0; }
.select-wrap { position: relative; }
.select-wrap .ic { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); }
.big-select { width: 100%; appearance: none; -webkit-appearance: none; border: 1px solid var(--line); border-radius: 13px; background: rgba(255, 255, 255, .75); padding: 10px 36px 10px 12px; font-weight: 700; font-size: 14px; outline: 0; cursor: pointer; }
.big-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pdesc { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.sub { font-size: 12px; color: var(--muted); }
.opt-row { display: flex; align-items: center; gap: 10px; padding: 6px 0 2px; }
.opt-row .txt { flex: 1; font-size: 13px; font-weight: 600; }
.opt-row .txt small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: rgba(15, 31, 28, .18); border-radius: 11px; transition: .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { left: 19px; }
.switch input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 0; background: var(--soft); font-size: 13px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.chip select { border: 0; background: transparent; font-weight: 600; color: inherit; outline: 0; padding: 0; }
.water-box { margin-top: 6px; padding: 10px 12px; border-radius: 14px; background: rgba(28, 126, 214, .08); }
.water-box .lbl { color: var(--water); margin-bottom: 2px; }
.row2 { display: flex; gap: 8px; align-items: center; }
.row2 > * { flex: 1; }
.mini-select { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, .7); padding: 6px 8px; font-size: 13px; }
.points { list-style: none; margin: 0; padding: 0; }
.points li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; }
.points li .n { width: 22px; height: 22px; border-radius: 50%; background: var(--text); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 800; flex-shrink: 0; }
.points li .n.start { background: var(--accent); }
.points li .n.end { background: var(--danger); }
.points li .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.points li button { border: 0; background: none; color: var(--muted); padding: 3px; border-radius: 8px; display: grid; place-items: center; }
.points li button:hover { background: var(--soft); color: var(--text); }
.add-row { position: relative; display: flex; gap: 6px; margin-top: 4px; }
.add-row input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 11px; background: rgba(255, 255, 255, .7); padding: 7px 10px; font-size: 13px; outline: 0; }
.add-row input:focus { border-color: var(--accent); }
.add-row .icon-btn { width: 34px; height: 34px; border-radius: 11px; }
.add-row .icon-btn.on { background: var(--accent); color: #fff; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.cta { width: 100%; height: 48px; border-radius: 15px; border: 0; background: var(--text); color: #fff; font-weight: 700; font-size: 15px; margin-top: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.cta:disabled { opacity: .6; cursor: progress; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .8s linear infinite; display: inline-block; }
.spin.dark { border-color: rgba(15, 31, 28, .15); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* listes historique / favoris */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 10px; align-items: center; padding: 9px; border-radius: 14px; background: rgba(255, 255, 255, .55); cursor: pointer; }
.item:hover { background: #fff; }
.item .thumb { width: 46px; height: 46px; border-radius: 10px; background: var(--soft); flex-shrink: 0; }
.item .meta { flex: 1; min-width: 0; }
.item .meta b { display: block; font-size: 14px; }
.item .meta small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .act { border: 0; background: none; color: var(--muted); padding: 6px; border-radius: 10px; display: grid; place-items: center; }
.item .act:hover { background: var(--soft); color: var(--text); }
.item .act.fav { color: #d4a017; }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 6px; }

/* ---------- résultats (sous les réglages, même largeur) ---------- */
.sheet { flex: 0 0 auto; border-radius: 22px; padding: 12px 14px; max-height: 62vh; overflow-y: auto; }
.props { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.prop { min-width: 0; border: 0; border-radius: 13px; padding: 7px 9px; background: rgba(255, 255, 255, .55); text-align: left; position: relative; }
.prop.on { background: #fff; box-shadow: inset 0 0 0 2px var(--accent); }
.prop i { position: absolute; top: 6px; right: 7px; font-style: normal; font-size: 10px; font-weight: 800; color: var(--accent); }
.prop b { display: block; font-size: 14px; white-space: nowrap; }
.prop small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.prop.err small { color: var(--danger); white-space: normal; }
.stats { display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; gap: 6px; }
.stat b { font-size: 17px; font-weight: 800; display: flex; align-items: center; gap: 4px; line-height: 1.15; white-space: nowrap; }
.stat small { color: var(--muted); font-weight: 600; font-size: 11px; }
.stat .ic { color: var(--water); width: 15px; height: 15px; }
.act { display: flex; gap: 8px; margin-top: 10px; }
.act .btn { flex: 1; justify-content: center; }
.btn { height: 40px; padding: 0 14px; border-radius: 12px; border: 0; background: var(--soft); font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 7px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.fav-on { color: #b7860b; background: rgba(212, 160, 23, .14); }
.chart-wrap { position: relative; margin-top: 10px; }
svg.elev { width: 100%; height: 74px; display: block; border-radius: 12px; background: rgba(15, 31, 28, .03); }
.chart-cursor { position: absolute; top: 0; bottom: 0; width: 1.5px; background: var(--text); pointer-events: none; }
.chart-tip { position: absolute; top: -30px; transform: translateX(-50%); background: var(--text); color: #fff; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 8px; white-space: nowrap; pointer-events: none; z-index: 2; }
.legend { display: flex; gap: 4px 10px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- marqueurs carte ---------- */
.mk span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #fff; font: 800 12px 'Plus Jakarta Sans', sans-serif; border: 3px solid #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, .3); }
.mk-start span { background: var(--accent); }
.mk-via span { background: var(--text); }
.mk-end span { background: var(--danger); }
.mk-water svg { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .3)); }
.mk-water.stop svg path { stroke: #0f1f1c; stroke-width: 2.2; }
.mk-pos span { width: 14px; height: 14px; border: 3px solid #fff; background: var(--text); }
.wind-badge { position: fixed; bottom: calc(var(--gap) + 18px); right: var(--gap); z-index: 500; border-radius: 16px; padding: 9px 13px; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.wind-badge .arr { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.wind-badge small { display: block; color: var(--muted); font-size: 11px; }

/* ---------- fenêtre d'info (on voit la page derrière en transparence) ---------- */
.modal { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; background: rgba(15, 31, 28, .18); padding: 16px; }
.msheet { width: min(580px, 100%); max-height: 86vh; overflow-y: auto; border-radius: 24px; padding: 20px 22px; background: rgba(255, 255, 255, .74); }
.msheet h3 { margin: 0 0 8px; display: flex; align-items: center; justify-content: space-between; font-size: 18px; }
.pi { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.pi .ico { width: 36px; height: 36px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex-shrink: 0; }
.pi b { display: block; } .pi p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.pi-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 3000; background: var(--text); color: #fff; padding: 10px 16px; border-radius: 14px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.err { background: var(--danger); }

.grabber { display: none; }
.edit-btn { display: none !important; }

/* ---------- téléphone ---------- */
@media (max-width: 760px) {
  :root { --top: max(10px, env(safe-area-inset-top)); --gap: 10px; --col-w: auto; --bar-h: 48px; }
  ::-webkit-scrollbar { width: 6px; }
  ::-webkit-scrollbar-track { border-width: 1px; margin: 10px 0; }
  ::-webkit-scrollbar-thumb { border-width: 1px; }
  .search { flex: 1; width: auto; }
  .leaflet-control-zoom { display: none; }
  .side { top: auto; max-height: calc(100dvh - var(--top) - var(--bar-h) - 22px); right: var(--gap); width: auto; gap: 8px; }
  .panel { padding: 0 14px 14px; border-radius: 20px; }
  body.has-sheet .panel { display: none; }
  body.has-sheet.show-panel .panel { display: block; }
  body.has-sheet .edit-btn { display: inline-flex !important; }
  .sheet { padding: 0 12px 12px; border-radius: 20px; max-height: none; }
  .wind-badge { bottom: auto; top: calc(var(--top) + var(--bar-h) + 10px); right: var(--gap); }
  /* poignée : zone tactile sur toute la largeur, 44 px de haut minimum (recommandation Apple / Google) */
  .grabber { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: calc(100% + 28px); min-height: 44px; margin: 0 -14px; border: 0; background: none; padding: 12px 0 10px; position: sticky; top: 0; z-index: 2; touch-action: none; }
  .grabber span { width: 56px; height: 6px; border-radius: 3px; background: rgba(15, 31, 28, .25); }
  .grabber b { font-size: 12px; color: var(--muted); font-weight: 700; display: none; }
  .sheet .grabber { position: static; width: calc(100% + 24px); margin: 0 -12px; }
  body.sheet-min .sheet .props, body.sheet-min .sheet .chart-wrap, body.sheet-min .sheet .legend, body.sheet-min .sheet .note { display: none; }
  .cta-wrap { position: sticky; bottom: -14px; margin: 0 -14px -14px; padding: 4px 14px 14px; background: linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, .92) 35%); }
  .cta-wrap .cta { margin-top: 8px; }
  body.panel-min .panel { max-height: 132px; overflow: hidden; }
  body.panel-min .panel > div:not(.cta-wrap) { display: none; }
  body.panel-min .grabber b { display: block; }
  body.panel-min .cta-wrap { position: static; margin-top: 0; padding-top: 0; background: none; }
  .stat b { font-size: 16px; }
}
