:root {
  --bg: #0a0d1c;
  --text: #f4f3fb;
  --muted: rgba(226, 228, 245, 0.62);
  --faint: rgba(226, 228, 245, 0.38);
  --line: rgba(255, 255, 255, 0.07);
  --famille: #ff5fa2;
  --amis: #4f8dff;
  --autres: #2fc79a;
  --accent: #ff5fa2;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --out: cubic-bezier(0.22, 1, 0.36, 1);
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: radial-gradient(120% 80% at 50% 30%, #121735 0%, var(--bg) 60%);
  background-color: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
}
button, input, a { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Fond : halos lents, discrets */
.aurora { position: fixed; inset: -20%; filter: blur(80px); opacity: 0.55; z-index: 0; pointer-events: none; }
.aurora i { position: absolute; border-radius: 50%; animation: drift 30s ease-in-out infinite alternate; }
.aurora i:nth-child(1) { width: 50vmax; height: 50vmax; left: -15%; top: -15%; background: radial-gradient(circle, #5b3bd6 0%, transparent 65%); }
.aurora i:nth-child(2) { width: 45vmax; height: 45vmax; right: -20%; top: 30%; background: radial-gradient(circle, #c2367a 0%, transparent 62%); animation-duration: 36s; animation-delay: -10s; }
.aurora i:nth-child(3) { width: 45vmax; height: 45vmax; left: 10%; bottom: -25%; background: radial-gradient(circle, #1d5bd6 0%, transparent 60%); animation-duration: 42s; animation-delay: -20s; }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(5vw, -3vh) scale(1.1); }
  100% { transform: translate(-4vw, 4vh) scale(0.95); }
}

/* En-tête centré */
.top {
  position: fixed; z-index: 5;
  top: calc(var(--safe-top) + 18px); left: 18px; right: 18px;
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
}
.title { text-align: center; }
.eyebrow { margin: 0; font-size: 14px; color: var(--muted); letter-spacing: 0.02em; }
h1 { margin: 4px 0 0; font-family: var(--serif); font-size: 36px; font-weight: 600; letter-spacing: -0.02em; font-variation-settings: "opsz" 144; }
h2 { margin: 0; font-family: var(--serif); font-size: 34px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; }
h3 { margin: 22px 0 6px; font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.14em; }

/* Boutons sans bordure : verre teinté et lueur */
.ghost-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 0 24px rgba(140, 150, 255, 0.12), inset 0 0 12px rgba(255, 255, 255, 0.04);
  transition: transform .4s var(--spring), box-shadow .3s;
}
.ghost-btn svg { width: 20px; height: 20px; }
.ghost-btn:active { transform: scale(0.88); }
.ghost-btn.small { width: 36px; height: 36px; background: rgba(255,255,255,0.05); box-shadow: none; }

/* Espace orbital */
#space { position: fixed; inset: 0; z-index: 1; touch-action: none; }
.rings, .thread { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.rings circle { fill: none; stroke: rgba(170, 180, 255, 0.2); stroke-width: 1; stroke-dasharray: 1.5 5; }
.labels rect { fill: rgba(14, 18, 41, 0.72); stroke: none; }
.labels text {
  fill: rgba(205, 210, 255, 0.72); stroke: none;
  font-size: 10px; font-weight: 500; letter-spacing: 0.04em;
  text-anchor: middle; dominant-baseline: middle;
}
.thread path { stroke-width: 1.6; fill: none; transition: opacity .4s; }
.thread circle { fill: #fff; stroke: none; }

.me {
  position: absolute; width: 58px; height: 58px; border-radius: 50%;
  transform: translate(-50%, -50%);
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 600; font-size: 19px;
  background: radial-gradient(circle at 50% 35%, #3a3f63, #1d2140 75%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 0 40px rgba(130, 120, 255, 0.25), inset 0 1px 10px rgba(255,255,255,0.08);
  z-index: 2;
}

.bubble {
  position: absolute; left: 0; top: 0;
  width: var(--s); height: var(--s); border-radius: 50%;
  will-change: transform;
  transition: opacity .4s;
}
.orb {
  --c: var(--amis);
  position: absolute; inset: 0; border-radius: 50%;
  display: grid; place-items: center; overflow: hidden;
  font-family: var(--serif); font-weight: 600; font-size: calc(var(--s) * 0.36);
  color: #fff;
  background: linear-gradient(150deg, color-mix(in srgb, var(--c) 92%, #fff) 0%, var(--c) 45%, color-mix(in srgb, var(--c) 60%, #0a0d1c) 100%);
  background-size: cover; background-position: center;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 85%, transparent), 0 0 18px color-mix(in srgb, var(--c) 45%, transparent);
  transition: transform .5s var(--spring), box-shadow .4s;
}
.orb.photo { color: transparent; }
.bubble:active .orb { transform: scale(0.88); }
.bubble.focus .orb {
  box-shadow: 0 0 0 2px var(--c), 0 0 26px var(--c), 0 0 60px color-mix(in srgb, var(--c) 55%, transparent);
  transform: scale(1.18);
}
.bubble.due .orb::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--c);
  animation: ping 2s var(--out) infinite;
}
.bubble.due::before {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--c); opacity: 0;
  animation: ping 2s var(--out) infinite;
}
@keyframes ping { 0% { transform: scale(1); opacity: 0.8; } 100% { transform: scale(1.9); opacity: 0; } }
.bubble.spawn .orb { animation: spawn .9s var(--spring) both; }
@keyframes spawn { from { transform: scale(0); } to { transform: scale(1); } }

.burst {
  position: absolute; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 2px var(--c), 0 0 30px var(--c);
  transform: translate(-50%, -50%);
  animation: burst 1s var(--out) forwards;
}
@keyframes burst { from { width: 30px; height: 30px; opacity: 1; } to { width: 200px; height: 200px; opacity: 0; } }

.legend {
  position: fixed; z-index: 3; left: 0; right: 0; margin: 0;
  display: flex; justify-content: center; align-items: center; gap: 10px;
  font-size: 13px; color: var(--muted);
}
.legend i { width: 7px; height: 7px; border-radius: 50%; background: var(--fc, var(--accent)); box-shadow: 0 0 10px var(--fc, var(--accent)); transition: background .4s; }

/* Carte du proche en focus */
.card {
  position: fixed; z-index: 4;
  left: 14px; right: 14px; bottom: calc(var(--safe-bottom) + 14px);
  max-width: 460px; margin: 0 auto;
  border-radius: 30px; padding: 22px 20px 20px;
  background:
    radial-gradient(90% 120% at 100% 100%, color-mix(in srgb, var(--fc, var(--accent)) 22%, transparent), transparent 60%),
    linear-gradient(160deg, rgba(60, 66, 110, 0.55), rgba(22, 26, 52, 0.55));
  backdrop-filter: blur(30px) saturate(160%); -webkit-backdrop-filter: blur(30px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), inset 0 0 0 1px rgba(255,255,255,0.05), 0 20px 60px rgba(0,0,0,0.45);
  transition: background .5s;
}
.card-inner { transition: opacity .25s, transform .35s var(--out); }
.card-inner.swap { opacity: 0; transform: translateY(8px); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.kicker { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.sub { margin: 8px 0 0; color: var(--muted); font-size: 15px; }
.actions { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 0.9fr); gap: 8px; margin-top: 20px; }

.pill {
  height: 50px; padding: 0 14px; border-radius: 25px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  text-decoration: none; font-size: 15px; font-weight: 500; white-space: nowrap;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 0 20px rgba(150, 160, 255, 0.06);
  transition: transform .4s var(--spring), box-shadow .3s, background .3s;
}
.pill svg { width: 20px; height: 20px; flex: none; }
.pill:active { transform: scale(0.94); }
.pill.primary {
  --pc: var(--fc, var(--accent));
  background: linear-gradient(180deg, color-mix(in srgb, var(--pc) 92%, #fff), color-mix(in srgb, var(--pc) 85%, #000));
  box-shadow: 0 0 28px color-mix(in srgb, var(--pc) 55%, transparent), 0 8px 24px color-mix(in srgb, var(--pc) 35%, transparent), inset 0 1px 0 rgba(255,255,255,0.3);
  font-weight: 600;
}
.pill.primary svg { fill: currentColor; stroke: none; }
.pill.primary svg path { fill: currentColor; }

/* Notification simulée */
.banner {
  position: fixed; z-index: 30;
  top: calc(var(--safe-top) + 10px); left: 10px; right: 10px;
  max-width: 420px; margin: 0 auto;
  border-radius: 24px; padding: 12px 14px;
  display: flex; gap: 12px; align-items: center;
  background: rgba(40, 44, 78, 0.72);
  backdrop-filter: blur(30px) saturate(170%); -webkit-backdrop-filter: blur(30px) saturate(170%);
  box-shadow: 0 0 40px rgba(255, 95, 162, 0.18), 0 16px 40px rgba(0,0,0,0.4);
  transform: translateY(-150%) scale(0.96);
  transition: transform .7s var(--spring);
  cursor: pointer;
}
.banner.show { transform: translateY(0) scale(1); }
.banner-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #2a2f55; }
.banner-body { flex: 1; min-width: 0; }
.banner-meta { margin: 0; display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.banner-meta b { color: var(--text); font-weight: 600; }
.banner-text { margin: 2px 0 0; font-size: 15px; line-height: 1.3; }

.toast {
  position: fixed; z-index: 30; left: 24px; right: 24px; margin: 0 auto; max-width: 380px;
  padding: 12px 16px; border-radius: 18px; text-align: center; font-size: 14px;
  background: rgba(40, 44, 78, 0.85);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 0 30px rgba(150,160,255,0.15);
  opacity: 0; transform: translateY(10px);
  transition: opacity .35s, transform .5s var(--spring);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Formulaire */
.scrim { position: fixed; inset: 0; z-index: 10; background: rgba(4, 5, 14, 0.55); opacity: 0; pointer-events: none; transition: opacity .4s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 11;
  left: 10px; right: 10px; bottom: calc(var(--safe-bottom) + 10px);
  max-width: 460px; margin: 0 auto;
  max-height: calc(100% - var(--safe-top) - 30px); overflow-y: auto;
  border-radius: 32px; padding: 10px 22px 22px;
  background: linear-gradient(160deg, rgba(46, 52, 92, 0.86), rgba(18, 21, 44, 0.9));
  backdrop-filter: blur(30px) saturate(160%); -webkit-backdrop-filter: blur(30px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 -10px 60px rgba(0,0,0,0.5);
  transform: translateY(115%);
  transition: transform .6s var(--spring);
}
.sheet.show { transform: translateY(0); }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.22); margin: 0 auto 16px; }
.sheet h2 { font-size: 28px; }

.field { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.field input {
  flex: 1; min-width: 0; height: 54px; padding: 0 18px; border-radius: 18px;
  font-family: var(--serif); font-size: 22px; font-weight: 600;
  background: rgba(255,255,255,0.07); border: 0; outline: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
  transition: box-shadow .3s;
  user-select: text; -webkit-user-select: text;
}
.field input:focus { box-shadow: inset 0 0 0 1px rgba(255,95,162,0.5), 0 0 24px rgba(255,95,162,0.2); }
.error { margin: 6px 4px 0; min-height: 18px; font-size: 13px; color: #ff7a8a; }

.chips { display: flex; gap: 8px; margin-top: 4px; }
.chip {
  padding: 9px 15px; border-radius: 999px; font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.06);
  transition: transform .4s var(--spring), background .3s, box-shadow .3s;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.chip[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 28%, transparent); box-shadow: 0 0 22px color-mix(in srgb, var(--c) 35%, transparent); }
.chip:active { transform: scale(0.94); }

.big { margin: 0 0 10px; font-family: var(--serif); font-size: 24px; font-weight: 600; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 34px; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--famille), #9a7bff, var(--amis)); box-shadow: 0 0 16px rgba(160, 120, 255, 0.35); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--famille), #9a7bff, var(--amis)); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -11px; border-radius: 50%;
  background: #fff; border: 0; box-shadow: 0 0 20px rgba(255,255,255,0.5), 0 4px 12px rgba(0,0,0,0.4);
}
input[type="range"]::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 0; }
.spread svg { width: 100%; height: 70px; display: block; margin-top: 4px; }
.spread .curve { fill: url(#bell); stroke: rgba(255,255,255,0.5); stroke-width: 1.5; }
.spread .mean { stroke: #fff; stroke-opacity: .7; stroke-dasharray: 3 4; }
.spread .sub { text-align: center; font-size: 14px; }

.clock-wrap { position: relative; width: 240px; height: 240px; margin: 6px auto 0; }
.clock { width: 240px; height: 240px; touch-action: none; }
.clock .track { stroke: rgba(255,255,255,0.07); stroke-width: 22; }
.clock .arc { stroke: url(#arcgrad); stroke-width: 22; stroke-linecap: round; filter: drop-shadow(0 0 10px rgba(255,95,162,0.55)); }
.clock .tick { stroke: rgba(255,255,255,0.22); stroke-width: 1.5; }
.clock text { fill: var(--faint); stroke: none; font-size: 11px; text-anchor: middle; dominant-baseline: middle; }
.clock .handle { fill: #fff; stroke: none; cursor: grab; filter: drop-shadow(0 0 8px rgba(255,255,255,0.6)); }
.hint-line { margin: -4px 0 0; font-size: 13px; }

.form-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; }
.form-actions .pill.primary { margin-left: auto; padding: 0 30px; --pc: var(--accent); }
.text-btn { font-size: 15px; font-weight: 500; color: var(--muted); }
.text-btn.danger { color: #ff7a8a; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
}
