/* ==========================================================================
   Boussole — thème sombre, mobile-first. Aucune dépendance externe.
   ========================================================================== */
:root {
  --bg: #0b1220;
  --bg2: #0f1a2e;
  --card: #14213a;
  --card2: #1b2b4a;
  --line: #26365c;
  --txt: #eef2ff;
  --txt-dim: #9fb0d0;
  --accent: #6366f1;
  --accent2: #818cf8;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

.app { max-width: 640px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }

/* --- Topbar --- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  background: linear-gradient(180deg, var(--bg2), rgba(15, 26, 46, 0.85));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .title { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.topbar .spacer { flex: 1; }
.topbar .sub { color: var(--txt-dim); font-size: 13px; }

.view { flex: 1; padding: 16px 16px 40px; }

/* --- Boutons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card2); color: var(--txt); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: transform .06s ease, background .15s ease; width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { width: auto; padding: 8px 12px; font-size: 13px; }
.btn.danger { color: var(--bad); border-color: rgba(248, 113, 113, .4); }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); color: var(--txt); font-size: 18px; display: grid; place-items: center; cursor: pointer; }

/* --- Cartes --- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.muted { color: var(--txt-dim); }
.small { font-size: 13px; }
.center { text-align: center; }

/* --- Formulaire --- */
label.field { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--txt-dim); font-weight: 600; }
input[type=text], input[type=date], input[type=password], textarea, select {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--txt); font-size: 16px; outline: none; font-family: inherit;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent2); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* --- Chips (choix multiples) --- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  padding: 9px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--txt); font-size: 14px; cursor: pointer; user-select: none;
}
.chip.on { background: rgba(99, 102, 241, .18); border-color: var(--accent2); color: #fff; }

/* --- Autocomplétion destination --- */
.autolist { margin-top: 6px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg2); }
.autolist .opt { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; gap: 10px; align-items: center; }
.autolist .opt:last-child { border-bottom: none; }
.autolist .opt:active { background: var(--card2); }

/* --- Liste de voyages (accueil) --- */
.trip-card { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.trip-card .emoji { font-size: 30px; }
.trip-card .grow { flex: 1; min-width: 0; }
.trip-card .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-card .meta { color: var(--txt-dim); font-size: 13px; }

/* --- Itinéraire --- */
.day { margin-top: 18px; }
.day-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.day-num { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 14px; flex: none; }
.day-title { font-weight: 700; }
.day-weather { margin-left: auto; font-size: 13px; color: var(--txt-dim); white-space: nowrap; }
.act { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; margin-bottom: 10px; }
.act-top { display: flex; align-items: flex-start; gap: 10px; }
.act-emoji { font-size: 20px; flex: none; }
.act-name { font-weight: 600; }
.act-place { color: var(--txt-dim); font-size: 13px; margin-top: 2px; }
.act-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 8px; font-size: 12.5px; color: var(--txt-dim); }
.act-tip { margin-top: 8px; font-size: 13px; color: var(--accent2); background: rgba(99,102,241,.1); padding: 8px 10px; border-radius: 10px; }

/* --- Badges de vérification --- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; margin-left: auto; flex: none; }
.badge.ok { background: rgba(52, 211, 153, .15); color: var(--ok); }
.badge.warn { background: rgba(251, 191, 36, .15); color: var(--warn); }
.badge.pending { background: rgba(159, 176, 208, .12); color: var(--txt-dim); }

.maplink { color: var(--accent2); text-decoration: none; }

/* --- Score de fiabilité --- */
.score { display: flex; align-items: center; gap: 12px; }
.score .big { font-size: 30px; font-weight: 800; }
.score .bar { flex: 1; height: 8px; border-radius: 999px; background: var(--bg2); overflow: hidden; }
.score .bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--warn), var(--ok)); }

/* --- Feuille modale --- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-width: 640px; margin: 0 auto;
  background: var(--bg2); border-radius: 20px 20px 0 0; border-top: 1px solid var(--line);
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 20px);
  max-height: 88vh; overflow-y: auto; box-shadow: 0 -10px 40px rgba(0,0,0,.5);
}
.sheet .grabber { width: 42px; height: 5px; border-radius: 999px; background: var(--line); margin: 6px auto 14px; }
.sheet h2 { margin: 0 0 4px; font-size: 19px; }

/* --- Toast --- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%);
  background: #101a30; color: var(--txt); border: 1px solid var(--line); padding: 12px 18px;
  border-radius: 12px; z-index: 60; box-shadow: var(--shadow); font-size: 14px; max-width: 90%; text-align: center;
}

/* --- Chargement --- */
.loader { display: grid; place-items: center; gap: 14px; padding: 40px 0; text-align: center; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent2); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.steps { color: var(--txt-dim); font-size: 14px; min-height: 22px; }

/* --- Empty state --- */
.empty { text-align: center; padding: 50px 20px; color: var(--txt-dim); }
.empty .big { font-size: 46px; margin-bottom: 10px; }

.hidden { display: none !important; }
.mt { margin-top: 14px; }
.mt2 { margin-top: 22px; }
a { color: var(--accent2); }
.tuto { counter-reset: step; padding-left: 0; list-style: none; margin: 10px 0 0; }
.tuto li { position: relative; padding: 6px 0 6px 34px; }
.tuto li::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 5px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; }
