:root {
  --blue: #0A84FF;
  --blue-dark: #0060df;
  --ink: #0b0f17;
  --ink-soft: #5b6474;
  --line: rgba(10, 15, 23, 0.08);
  --bg: #f4f6fb;
  --card: #ffffff;
  --shadow: 0 10px 40px rgba(10, 15, 23, 0.12), 0 2px 8px rgba(10, 15, 23, 0.06);
  --radius: 22px;
  --radius-sm: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(10, 132, 255, 0.10), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.card-wrap {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 14px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Carte (portrait 3:4) ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card__photo {
  position: relative;
  aspect-ratio: 3 / 4;
  /* On borne la hauteur pour garder les boutons principaux visibles sans scroller. */
  max-height: min(46dvh, 520px);
  width: 100%;
  background:
    linear-gradient(160deg, #1a2233, #0b0f17 70%),
    var(--blue);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Repli tant qu'aucune photo n'est fournie */
.card__initials {
  font-size: clamp(64px, 22vw, 120px);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 2px;
}
.card__photo.has-photo .card__initials { display: none; }

.card__body {
  padding: 15px 20px 17px;
}

.card__name {
  margin: 0;
  font-size: clamp(24px, 6.5vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card__title {
  margin: 4px 0 0;
  font-size: 15px;
  color: var(--blue);
  font-weight: 600;
}

.card__location {
  margin: 10px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--ink-soft);
}

.card__tagline {
  margin: 12px 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-soft);
}
.card__tagline:empty { display: none; }

/* ---------- Boutons ---------- */
.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 14px 14px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(10, 15, 23, 0.04);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
  min-width: 0; /* autorise le rétrécissement dans la grille (évite le débordement) */
}
.btn:active { transform: scale(0.97); }

.btn .ic { flex: 0 0 auto; }
.btn span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Bouton principal (pleine largeur, mis en avant) */
.btn--primary {
  grid-column: 1 / -1;
  background: var(--blue);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px rgba(10, 132, 255, 0.28);
  font-size: 16px;
  padding: 16px;
  justify-content: center;
}
.btn--primary:active { background: var(--blue-dark); }

/* Boutons secondaires "solo" en pleine largeur (ex. installer) */
.btn--wide { grid-column: 1 / -1; justify-content: center; }

.foot {
  margin-top: auto;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding-top: 6px;
}

/* ---------- Icônes ---------- */
.ic {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ic--sm { width: 15px; height: 15px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 22px);
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}
.toast[data-show] {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast .ic { color: #34c759; }

/* ---------- Feuille (instructions) ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 23, 0.4);
  backdrop-filter: blur(2px);
}
.sheet__panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(var(--safe-bottom) + 26px);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
  animation: rise 0.28s ease;
}
@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet__close {
  position: absolute;
  top: 14px; right: 14px;
  border: none;
  background: var(--bg);
  color: var(--ink-soft);
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.sheet__body h2 { margin: 0 0 6px; font-size: 18px; }
.sheet__body p { margin: 0 0 14px; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }
.sheet__steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.sheet__steps li { display: flex; gap: 12px; align-items: center; font-size: 15px; }
.sheet__steps .n {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.sheet__steps .ic { color: var(--blue); }

/* ---------- Mode sombre ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2f4f8;
    --ink-soft: #9aa3b2;
    --line: rgba(255, 255, 255, 0.12);
    --bg: #0b0f17;
    --card: #151a24;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
  }
  body {
    background:
      radial-gradient(1200px 600px at 50% -10%, rgba(10, 132, 255, 0.16), transparent 60%),
      var(--bg);
  }
}
