/* Polices servies localement */
@font-face { font-family: 'Figtree'; src: url('/fonts/figtree/figtree-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Figtree'; src: url('/fonts/figtree/figtree-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Figtree'; src: url('/fonts/figtree/figtree-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Figtree'; src: url('/fonts/figtree/figtree-latin-800-normal.woff2') format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Bricolage'; src: url('/fonts/bricolage/bricolage-grotesque-latin-standard-normal.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }

/* Thèmes : choisis par l'utilisateur dans son profil */
:root, [data-theme="telecabine"] {
  --accent: #C8321D; --soft: #FFE3C7; --soft-text: #8A2A12; --ink: #1B1F3B; --pop: #FFC53D; --pop-text: #1B1F3B;
  --a1: #1B1F3B; --a2: #C8321D; --a3: #2F7D6D;
}
[data-theme="glacier"] {
  --accent: #2553D9; --soft: #D2F4EA; --soft-text: #0B5E4A; --ink: #0F1E3D; --pop: #3EE0B0; --pop-text: #0F1E3D;
  --a1: #0F1E3D; --a2: #2553D9; --a3: #0E7A5E;
}
[data-theme="retro"] {
  --accent: #B61FA8; --soft: #FFE0F4; --soft-text: #86107C; --ink: #2A1454; --pop: #1FD1C9; --pop-text: #2A1454;
  --a1: #2A1454; --a2: #B61FA8; --a3: #0F7F7F;
}
:root {
  --bg: #F3F1EC; --card: #FFFFFF; --line: #E2DED6; --line-strong: #D5D0C6; --muted: #56606B; --text-2: #3C4651; --well: #E7E3DB;
  --v: #15803D; --b: #1D4ED8; --r: #B91C1C; --n: #111827;
  --display: 'Bricolage', 'Figtree', Georgia, serif;
  --nav-h: 68px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Figtree', system-ui, -apple-system, sans-serif; font-size: 15px; line-height: 1.4;
  padding-top: env(safe-area-inset-top, 0px);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; position: relative; }
.screen { padding: 20px 20px calc(var(--nav-h) + 110px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 16px; }
.screen.no-nav { padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)); }
.loading { padding: 60px 20px; text-align: center; color: var(--muted); }

/* Typo */
.logo { font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: -0.5px; line-height: 1; }
.logo span { color: var(--accent); }
.sticker { font-size: 11px; font-weight: 800; padding: 4px 8px; border-radius: 8px; background: var(--pop); color: var(--pop-text); transform: rotate(-4deg); display: inline-block; }
.h1 { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1.1; }
.h-title { font-family: var(--display); font-weight: 600; font-size: 19px; line-height: 1.2; }
.section-label { font-size: 15px; font-weight: 700; color: var(--text-2); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* Cartes et champs */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.tight { padding: 4px 16px; gap: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; border: 1px solid var(--line-strong); border-radius: 12px; padding: 0 14px; background: #FAF9F6; font-size: 16px;
}
textarea.input { padding: 12px 14px; min-height: 90px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.check { display: flex; align-items: center; gap: 12px; cursor: pointer; min-height: 44px; }
.check input { width: 24px; height: 24px; accent-color: var(--accent); flex-shrink: 0; }
.error { background: #FDE8E6; color: #8A1C12; border-radius: 12px; padding: 10px 14px; font-size: 14px; font-weight: 600; }

/* Boutons */
.btn { min-height: 48px; border-radius: 14px; border: none; padding: 0 18px; font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn-primary { background: var(--accent); color: #FFFFFF; }
.btn-outline { background: #FFFFFF; color: var(--ink); border: 1px solid var(--ink); }
.btn-soft { background: var(--soft); color: var(--soft-text); }
.btn-ghost { background: transparent; color: var(--accent); padding: 0 8px; }
.btn-danger { background: #FFFFFF; color: #A1261A; border: 1px solid #E8B4AE; }
.btn-block { width: 100%; }
.btn-lg { min-height: 54px; font-size: 16px; border-radius: 16px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); flex-shrink: 0; text-decoration: none; }
.link-go { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; font-weight: 700; font-size: 13px; text-decoration: none; color: var(--accent); white-space: nowrap; }

/* Puces, onglets */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 0 20px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid var(--line-strong); background: #FFFFFF; font-weight: 600; font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--ink); color: #FFFFFF; border-color: var(--ink); }
.seg { display: flex; background: var(--well); border-radius: 12px; padding: 4px; }
.seg button { flex: 1; min-height: 40px; border: none; border-radius: 9px; background: transparent; font-weight: 600; font-size: 14px; color: var(--muted); position: relative; }
.seg button.on { background: #FFFFFF; color: var(--ink); font-weight: 700; }
.badge { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #FFFFFF; font-size: 12px; font-weight: 800; align-items: center; justify-content: center; }
.pistes-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.piste-btn { min-height: 64px; border-radius: 14px; border: 1px solid var(--line-strong); background: #FFFFFF; font-weight: 700; font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.piste-btn.on { border: 2px solid var(--ink); }
.papote-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.papote-btn { min-height: 72px; border-radius: 14px; border: 1px solid var(--line-strong); background: #FFFFFF; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.papote-btn b { font-family: var(--display); font-weight: 800; font-size: 17px; }
.papote-btn span { font-size: 12px; color: var(--muted); }
.papote-btn.on { border: 2px solid var(--accent); background: var(--soft); }
.papote-btn.on b, .papote-btn.on span { color: var(--soft-text); }
.theme-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.theme-btn { min-height: 84px; border-radius: 14px; border: 1px solid var(--line-strong); background: #FFFFFF; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 13px; }
.theme-btn.on { border: 3px solid var(--ink); }
.theme-btn .dots { display: flex; gap: 4px; }
.theme-btn .dots i { width: 22px; height: 22px; border-radius: 11px; display: block; }

/* Pastilles de piste et étiquettes */
.dot { width: 10px; height: 10px; border-radius: 5px; display: inline-block; flex-shrink: 0; }
.dot.verte { background: var(--v); } .dot.bleue { background: var(--b); } .dot.rouge { background: var(--r); } .dot.noire { background: var(--n); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 10px; background: var(--bg); }
.tag.pop { background: var(--pop); color: var(--pop-text); font-weight: 800; }
.tag.soft { background: var(--soft); color: var(--soft-text); font-weight: 800; }
.tag.dark { background: var(--ink); color: #FFFFFF; font-weight: 700; }
.card .tag { background: var(--bg); }
.card .tag.pop { background: var(--pop); } .card .tag.soft { background: var(--soft); } .card .tag.dark { background: var(--ink); }

/* Avatars */
.avatar { width: 40px; height: 40px; border-radius: 20px; color: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; flex-shrink: 0; text-decoration: none; }
.avatar.c1 { background: var(--a1); } .avatar.c2 { background: var(--a2); } .avatar.c3 { background: var(--a3); }
.avatar.lg { width: 60px; height: 60px; border-radius: 30px; font-size: 24px; font-family: var(--display); }
.avatar.sm { width: 30px; height: 30px; border-radius: 15px; font-size: 12px; }
.avatar.free { background: transparent; border: 2px dashed #B9B3A7; }

/* Accueil */
.station-btn { display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; background: #FFFFFF; border: 1px solid var(--line); border-radius: 16px; }
.station-btn .ico { width: 40px; height: 40px; border-radius: 12px; background: var(--pop); color: var(--pop-text); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.station-btn select { border: none; background: transparent; font-weight: 700; font-size: 16px; width: 100%; min-height: 28px; padding: 0; }
.station-btn input[type="date"] { border: none; background: transparent; font-size: 13px; color: var(--muted); padding: 0; min-height: 24px; width: 100%; }
.info-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.info-line svg { flex-shrink: 0; }
.sortie-card h3 a { color: inherit; text-decoration: none; }
.sortie-card h3 a::after { content: ''; position: absolute; inset: 0; }
.sortie-card { position: relative; }
.sortie-card .link-go, .sortie-card .above { position: relative; z-index: 1; }
.empty { text-align: center; padding: 28px 16px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.empty p { margin: 0; color: var(--text-2); max-width: 32ch; }
.fab { position: fixed; right: max(20px, calc(50% - 240px)); bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom, 0px)); height: 52px; padding: 0 20px; border-radius: 26px; background: var(--accent); color: #FFFFFF; display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 700; font-size: 15px; box-shadow: 0 6px 18px rgba(23,33,43,0.25); z-index: 20; }

/* Barre de navigation */
#nav { position: fixed; left: 0; right: 0; bottom: 0; background: #FFFFFF; border-top: 1px solid var(--line); z-index: 30; padding-bottom: env(safe-area-inset-bottom, 0px); }
#nav[hidden] { display: none; }
#nav .inner { max-width: 520px; margin: 0 auto; height: var(--nav-h); display: flex; justify-content: space-around; align-items: center; }
#nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 64px; min-height: 48px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; position: relative; }
#nav a.on { color: var(--accent); font-weight: 700; }
#nav a .badge { position: absolute; top: 0; right: 10px; min-width: 18px; height: 18px; font-size: 11px; }

/* Carte */
.map { width: 100%; height: 190px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line-strong); background: #EAF0F5; z-index: 0; }
.map.hero { height: 230px; border-radius: 0; border: none; }
.map-wrap { position: relative; margin: -20px -20px 0; }
.map-wrap .icon-btn { position: absolute; top: 14px; z-index: 500; box-shadow: 0 2px 8px rgba(23,33,43,0.15); border: none; }
.map-wrap .go { position: absolute; right: 14px; bottom: 14px; z-index: 500; height: 40px; padding: 0 14px; border-radius: 20px; background: var(--pop); color: var(--pop-text); display: flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 800; font-size: 13px; }
.pin span { display: block; width: 22px; height: 22px; border-radius: 11px; background: var(--accent); border: 3px solid #FFFFFF; box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 22%, transparent); }
.leaflet-container { font-family: inherit; }

/* Compatibilité, groupe */
.compat { background: var(--soft); color: var(--soft-text); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.compat b { font-size: 15px; }
.compat .row { font-size: 14px; }
.group { display: flex; gap: 10px; flex-wrap: wrap; }
.group .member { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 60px; font-size: 12px; font-weight: 600; text-align: center; text-decoration: none; color: inherit; }
.group .avatar { width: 52px; height: 52px; border-radius: 26px; }
.actions-bar { position: fixed; left: 0; right: 0; bottom: 0; background: #FFFFFF; border-top: 1px solid var(--line); padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 30; }
.actions-bar .inner { max-width: 480px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #EEEAE3; }
.list-row:last-child { border-bottom: none; }
.notice { display: flex; gap: 12px; align-items: flex-start; background: var(--soft); color: var(--soft-text); border-radius: 14px; padding: 14px; font-size: 13px; line-height: 1.45; }
.notice svg { flex-shrink: 0; }

/* Profil */
.hero-card { background: var(--ink); color: #FFFFFF; border-radius: 22px; padding: 20px; display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden; }
.hero-card .deco { position: absolute; right: -20px; bottom: -10px; opacity: 0.18; pointer-events: none; }
.hero-card .avatar.lg { background: var(--pop); color: var(--pop-text); }
.hero-card .quote { font-family: var(--display); font-size: 20px; font-weight: 600; line-height: 1.25; margin: 0; }
.hero-card .sub { font-size: 13px; color: #D5DAE3; }

/* Messagerie */
.conv-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-decoration: none; color: inherit; border-bottom: 1px solid #EEEAE3; }
.conv-row:last-child { border-bottom: none; }
.conv-row .last { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat { display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 520px; margin: 0 auto; }
.chat-head { background: #FFFFFF; border-bottom: 1px solid var(--line); padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.chat-head .icon-btn { border: none; }
.chat-pin { margin: 12px 16px 0; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-foot { background: #FFFFFF; border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; gap: 8px; }
.chat-foot .input { border-radius: 22px; min-height: 44px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 85%; }
.msg .who { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.bubble { background: #FFFFFF; border-radius: 16px 16px 16px 4px; padding: 10px 12px; font-size: 15px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; }
.msg.me .bubble { background: var(--accent); color: #FFFFFF; border-radius: 16px 16px 4px 16px; }
.msg .time { font-size: 11px; color: var(--muted); margin-top: 3px; }
.msg.me .time { text-align: right; }
.bubble.pos { border: 2px solid var(--pop); display: flex; align-items: center; gap: 10px; }
.msg.me .bubble.pos { background: #FFFFFF; color: var(--ink); }
.sys { align-self: center; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--well); padding: 5px 12px; border-radius: 10px; text-align: center; }

/* Fenêtres et notifications */
dialog.sheet { border: none; border-radius: 20px; padding: 20px; width: min(420px, calc(100vw - 32px)); color: var(--ink); }
dialog.sheet::backdrop { background: rgba(23, 33, 43, 0.45); }
dialog.sheet h2 { font-family: var(--display); font-size: 20px; margin-bottom: 8px; }
dialog.sheet p { margin: 0 0 12px; color: var(--text-2); }
dialog.sheet .stack { gap: 10px; margin-top: 12px; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top, 0px)); background: var(--ink); color: #FFFFFF; padding: 12px 16px; border-radius: 14px; font-weight: 600; font-size: 14px; z-index: 1000; max-width: calc(100vw - 32px); box-shadow: 0 6px 18px rgba(23,33,43,0.3); }
#toast[hidden] { display: none; }

/* Connexion */
.auth { min-height: 100vh; padding: 48px 24px 32px; display: flex; flex-direction: column; gap: 22px; max-width: 440px; margin: 0 auto; }
.auth .logo { font-size: 44px; }
.auth .pitch { font-family: var(--display); font-size: 22px; font-weight: 600; line-height: 1.25; margin: 0; }
.mountains { width: 100%; height: auto; display: block; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }

/* ---------- v0.2 : accueil public, amis, rendez-vous ---------- */
a.logo { color: var(--ink); text-decoration: none; display: inline-block; }
.seg button { font-size: 13px; padding: 0 4px; }
.landing { max-width: 520px; margin: 0 auto; padding: 20px 20px 40px; display: flex; flex-direction: column; gap: 22px; }
.hero { display: flex; flex-direction: column; gap: 10px; }
.hero-title { font-family: var(--display); font-weight: 800; font-size: 40px; line-height: 1.02; letter-spacing: -1px; }
.hero-sub { margin: 0; font-size: 17px; color: var(--text-2); line-height: 1.45; }
.search-card { border: 2px solid var(--ink); box-shadow: 6px 6px 0 var(--pop); }
.counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.counts div { background: var(--soft); color: var(--soft-text); border-radius: 14px; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; text-align: center; }
.counts b { font-family: var(--display); font-size: 28px; line-height: 1; }
.counts span { font-size: 12px; font-weight: 600; line-height: 1.25; }
#apercu { display: flex; flex-direction: column; gap: 10px; }
#apercu:empty { display: none; }
.teaser { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.features { gap: 12px; }
.feature { display: flex; gap: 12px; align-items: flex-start; background: #FFFFFF; border-radius: 16px; padding: 14px; border: 1px solid var(--line); }
.feature b { font-size: 16px; }
.feature p { margin: 4px 0 0; color: var(--text-2); font-size: 14px; line-height: 1.45; }
.f-ico { width: 42px; height: 42px; border-radius: 12px; background: var(--pop); color: var(--pop-text); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.invite-card { background: var(--soft); border-color: transparent; }
.look-dot { width: 16px; height: 16px; border-radius: 8px; display: inline-block; flex-shrink: 0; border: 2px solid var(--line-strong); }
.look-dot.empty { background: transparent; border-style: dashed; }
.swatches { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.swatch { height: 44px; border-radius: 12px; border: 2px solid var(--line-strong); }
.swatch.on { outline: 3px solid var(--ink); outline-offset: 2px; }
.bubble.photo { padding: 4px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; background: #FFFFFF; }
.msg.me .bubble.photo { background: var(--accent); color: #FFFFFF; }
.bubble.photo img { display: block; max-width: 240px; max-height: 280px; width: 100%; object-fit: cover; border-radius: 12px; }
.bubble.photo span { padding: 2px 8px 6px; font-size: 14px; }
.bubble.card-msg { display: flex; flex-direction: column; gap: 4px; border: 2px solid var(--pop); background: #FFFFFF; color: var(--ink); }
.msg.me .bubble.card-msg { background: #FFFFFF; color: var(--ink); }
.bubble.card-msg .small.muted { display: inline-flex; align-items: center; gap: 4px; }
.bubble.pos.arrived { border-color: var(--accent); }
.pin-more { border-top: 1px solid #EEEAE3; margin-top: 10px; padding-top: 8px; }
.pin-more summary { cursor: pointer; font-weight: 700; font-size: 13px; color: var(--accent); min-height: 28px; display: flex; align-items: center; }
.map-tools { display: flex; gap: 6px; }
.map-tools button { background: #FFFFFF; border: none; border-radius: 10px; min-width: 64px; height: 40px; font-weight: 700; font-size: 13px; box-shadow: 0 2px 8px rgba(23,33,43,0.2); color: var(--ink); }
.leaflet-bar a { width: 40px !important; height: 40px !important; line-height: 40px !important; font-size: 20px !important; }
.leaflet-touch .leaflet-bar { border: none; box-shadow: 0 2px 8px rgba(23,33,43,0.2); border-radius: 10px; overflow: hidden; }
.map { height: 240px; }
[hidden] { display: none !important; }
