/* Charte graphique issue du logo : orange #F09200, anthracite #232526, blanc */
:root {
  --accent: #F09200;
  --accent-ink: #A35F00;
  --accent-soft: rgba(240, 146, 0, 0.12);
  --on-accent: #232526;
  --me: #2563EB;
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F6F3EE;
  --text: #232526;
  --muted: #5F6061;
  --line: #ECE7DF;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.10);
  --map-h: 56vh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #F5A524;
    --accent-ink: #F5A524;
    --accent-soft: rgba(245, 165, 36, 0.14);
    --on-accent: #1A1B1C;
    --me: #60A5FA;
    --bg: #151413;
    --surface: #1D1C1A;
    --surface-2: #2A2825;
    --text: #F3F1EE;
    --muted: #ABA7A1;
    --line: #34312D;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.accent { color: var(--accent-ink); }

#app { position: fixed; inset: 0; }
#map { position: absolute; left: 0; right: 0; top: 0; height: calc(var(--map-h) + 28px); background: var(--surface-2); z-index: 0; }
.leaflet-control-attribution { display: none; }

/* Top bar */
.topbar {
  position: absolute; z-index: 500; left: 16px; right: 16px;
  top: calc(12px + var(--safe-top));
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.pill {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px 0 14px;
  border: 0; border-radius: 22px; background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  font-size: 15px; font-weight: 700; max-width: calc(100% - 60px);
}
.pill svg { color: var(--accent-ink); flex-shrink: 0; }
.pill .accent { font-weight: 600; white-space: nowrap; }
.round {
  width: 44px; height: 44px; border: 0; border-radius: 22px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.round.flat { box-shadow: none; background: transparent; }
.locate { position: absolute; z-index: 500; right: 16px; top: calc(var(--map-h) - 64px); width: 48px; height: 48px; border-radius: 24px; color: var(--me); }
.locate.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Times card */
.times {
  position: absolute; z-index: 600; left: 16px; right: 16px; top: calc(64px + var(--safe-top));
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 12px;
}
.times-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.times-grid div { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; border-radius: 12px; color: var(--muted); }
.times-grid div b { font-size: 15px; color: var(--text); }
.times-grid div span { font-size: 12px; font-weight: 600; }
.times-grid div.next { background: var(--accent); }
.times-grid div.next b, .times-grid div.next span { color: var(--on-accent); }
.times-meta { margin: 8px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

/* Sheet */
.sheet {
  position: absolute; z-index: 700; left: 0; right: 0; bottom: 0; top: var(--map-h);
  background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,0.10);
  padding: 4px 22px calc(20px + var(--safe-bottom)); overflow-y: auto; -webkit-overflow-scrolling: touch;
  transition: top 0.25s ease;
  display: flex; flex-direction: column; gap: 14px;
}
.sheet.expanded { top: calc(84px + var(--safe-top)); }
.sheet.dragging { transition: none; }
.handle { align-self: center; width: 80px; height: 24px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; touch-action: none; flex-shrink: 0; }
.handle span { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }

.eyebrow { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; }
.nearest { display: flex; flex-direction: column; gap: 6px; }
.near-name { margin: 0; font-size: 26px; font-weight: 800; line-height: 1.12; letter-spacing: -0.4px; }
.near-name small { display: block; font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-top: 2px; }
.near-meta { margin: 0 0 8px; font-size: 15px; color: var(--muted); }

.btn-primary, .btn-secondary {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px; padding: 0 18px;
  border-radius: 16px; border: 0; font-size: 17px; font-weight: 700; text-decoration: none; width: 100%;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary.small { min-height: 48px; font-size: 15px; border-radius: 12px; }
.btn-primary:disabled { opacity: 0.6; }
.btn-secondary { background: var(--surface-2); color: var(--text); }

.others { list-style: none; margin: 0; padding: 0; }
.others li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; border-top: 1px solid var(--line); }
.others .o-main { flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 8px 0; display: flex; flex-direction: column; gap: 2px; }
.others .o-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.others .o-sub { font-size: 13px; color: var(--muted); }
.others .o-right { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; flex-shrink: 0; }
.others .o-go { width: 44px; height: 44px; border-radius: 22px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--accent-ink); }
.others .o-note { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; min-height: 0; }

.status { background: var(--accent-soft); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; font-size: 15px; line-height: 1.4; }
.status p { margin: 0; }

.install { background: var(--surface-2); border-radius: 16px; padding: 14px 16px; font-size: 14px; line-height: 1.4; display: flex; gap: 12px; align-items: flex-start; }
.install p { margin: 0; flex: 1; }
.install button { border: 0; background: transparent; color: var(--muted); padding: 0; min-width: 32px; min-height: 32px; }
.install .btn-primary { min-height: 40px; width: auto; color: var(--on-accent); padding: 0 14px; font-size: 14px; margin-top: 8px; }

.link-btn { border: 0; background: transparent; color: var(--accent-ink); font-weight: 600; font-size: 15px; min-height: 44px; padding: 0; text-align: center; }
.link-btn.left { text-align: left; }
.brand { display: flex; align-items: center; gap: 10px; margin-top: -4px; }
.brand img { display: block; height: 32px; width: auto; flex-shrink: 0; }
.brand p { margin: 0; display: flex; flex-direction: column; font-size: 13px; color: var(--muted); line-height: 1.25; min-width: 0; }
.brand a { color: var(--accent-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; display: inline-flex; align-items: center; min-height: 28px; padding: 8px 0; margin: -8px 0; }
.brand b { font-size: 15px; color: var(--text); }
.brand.big { flex-direction: column; gap: 8px; text-align: center; margin-top: 0; }
.brand.big img { height: 72px; }
.brand.big p { align-items: center; }
.brand.big a { min-height: 44px; margin: -6px 0; padding: 0; }
.attrib { margin: auto 0 0; font-size: 11px; color: var(--muted); text-align: center; }

/* Map markers */
.me-dot { width: 18px; height: 18px; border-radius: 9px; background: var(--me); border: 3px solid #fff; box-shadow: 0 0 0 8px rgba(37, 99, 235, 0.2); }
.near-pin { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.near-pin i { width: 40px; height: 40px; border-radius: 20px; background: var(--accent); border: 3px solid #fff; display: flex; align-items: center; justify-content: center; color: var(--on-accent); box-shadow: var(--shadow); }
.near-pin b { font-size: 12px; background: var(--surface); color: var(--text); padding: 3px 8px; border-radius: 8px; box-shadow: var(--shadow); white-space: nowrap; }

/* Panels */
.panel { position: fixed; inset: 0; z-index: 1000; background: var(--bg); display: flex; flex-direction: column; animation: slidein 0.2s ease; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel-head { display: flex; align-items: center; gap: 4px; padding: calc(8px + var(--safe-top)) 12px 8px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 19px; font-weight: 800; }
.panel-body { flex: 1; overflow-y: auto; padding: 18px 22px calc(28px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 18px; max-width: 560px; width: 100%; margin: 0 auto; }
.group { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.group legend { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; padding: 0; margin-bottom: 10px; }
.help { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.45; }
.help.center { text-align: center; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 14px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--muted); text-align: center; padding: 0 4px; }
.seg.big span { min-height: 46px; font-size: 15px; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chips span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1.5px solid var(--line); font-size: 14px; font-weight: 600; color: var(--muted); }
.chips input:checked + span { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.switch-row, .check-row { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 16px; cursor: pointer; }
.switch-row { justify-content: space-between; }
.switch-row input, .check-row input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.field { display: flex; flex-direction: column; gap: 8px; font-size: 14px; font-weight: 600; }
.field em { font-weight: 400; color: var(--muted); font-style: normal; }
.field input, .field select { min-height: 50px; border-radius: 14px; border: 1.5px solid var(--line); padding: 0 14px; font-size: 16px; font-weight: 400; background: var(--surface); }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.pos-box { background: var(--accent-soft); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.pos-state { margin: 4px 0 0; font-size: 14px; color: var(--text); }
.pos-state.ok::before { content: "✓ "; color: var(--accent-ink); font-weight: 700; }
.error { margin: 0; color: #B42318; font-size: 14px; font-weight: 600; }
@media (prefers-color-scheme: dark) { .error { color: #FDA29B; } }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Picker */
.picker { position: fixed; inset: 0; z-index: 900; pointer-events: none; }
.crosshair { position: absolute; left: 50%; top: 45%; width: 36px; height: 36px; margin: -36px 0 0 -18px; }
.crosshair::before { content: ""; position: absolute; left: 50%; bottom: 0; width: 28px; height: 28px; margin-left: -14px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); transform-origin: center; background: var(--accent); border: 3px solid #fff; box-shadow: var(--shadow); }
.picker-bar { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 24px 24px 0 0; padding: 18px 22px calc(18px + var(--safe-bottom)); pointer-events: auto; box-shadow: 0 -6px 24px rgba(0,0,0,0.12); }
.picker-bar p { margin: 0 0 12px; font-size: 15px; text-align: center; }
.picker-bar .row { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; }
body.picking #map { height: 100%; }
body.picking .topbar, body.picking .locate, body.picking .sheet, body.picking .times { display: none; }

/* Toast */
.toast { position: fixed; z-index: 1200; left: 16px; right: 16px; bottom: calc(24px + var(--safe-bottom)); background: var(--text); color: var(--bg); padding: 14px 16px; border-radius: 14px; font-size: 15px; text-align: center; box-shadow: var(--shadow); }

@media (min-width: 720px) {
  :root { --map-h: 100vh; }
  #map { height: 100%; }
  .sheet { top: auto; left: 16px; right: auto; bottom: 16px; width: 380px; max-height: calc(100vh - 100px); border-radius: 24px; }
  .sheet.expanded { top: auto; }
  .handle { display: none; }
  .locate { top: auto; bottom: 24px; right: 24px; }
  .topbar { right: auto; left: 16px; width: 380px; }
  .times { right: auto; width: 380px; }
}
