:root {
  --bg: #07070b;
  --bg-2: #0e0e15;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #f5f5fa;
  --muted: #8d8da3;
  --accent: #b38bff;
  --accent-2: #5ea8ff;
  --pink: #ff6fb5;
  --green: #4fe3a1;
  --danger: #ff6b7d;
  --radius: 24px;
  --radius-sm: 14px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }

.bg-glow {
  position: fixed; inset: -20vh -20vw auto; height: 80vh; z-index: -1;
  background:
    radial-gradient(40% 50% at 25% 30%, rgba(124, 77, 255, 0.28), transparent 70%),
    radial-gradient(35% 45% at 75% 20%, rgba(255, 79, 163, 0.18), transparent 70%),
    radial-gradient(40% 50% at 55% 60%, rgba(46, 131, 255, 0.16), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
}

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: rgba(7, 7, 11, 0.7);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; font-size: 18px; letter-spacing: -0.02em; }
.topbar-actions { display: flex; gap: 8px; }

main { max-width: 1120px; margin: 0 auto; padding: 0 16px 40px; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px;
  border: 0; border-radius: 999px;
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
  cursor: pointer; user-select: none;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn.primary { background: #fff; color: #0a0a10; }
.btn.primary:hover { background: #e9e6ff; }
.btn.ghost { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.14); }
.btn.danger { color: var(--danger); }
.btn:focus-visible, .icon-btn:focus-visible, .goal:focus-visible, input:focus-visible + span {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, 0.08); cursor: pointer; font-size: 15px;
}

/* Hero */
.hero { text-align: center; padding: 48px 0 36px; }
.eyebrow { color: var(--muted); font-size: 14px; font-weight: 500; letter-spacing: 0.02em; }
.big-number {
  font-weight: 200; font-size: clamp(56px, 16vw, 104px);
  letter-spacing: -0.05em; line-height: 1.05; margin: 6px 0 10px;
  font-variant-numeric: tabular-nums;
}
.big-number .cur { font-size: 0.32em; font-weight: 300; letter-spacing: 0; margin-left: 0.3em; color: var(--muted); vertical-align: 0.9em; }
.hero-sub { color: var(--muted); max-width: 440px; margin: 0 auto; }
.hero-sub strong { color: var(--text); font-weight: 600; }
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 0 14px; }
.section-head h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }

/* Cartes coffre */
.goals { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .goals { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .goals { grid-template-columns: repeat(3, 1fr); } }

.goal {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  padding: 20px;
  min-height: 230px;
  display: flex; flex-direction: column; gap: 14px;
  background: var(--g);
  box-shadow: var(--shadow);
  cursor: pointer;
  isolation: isolate;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: cardIn 0.5s cubic-bezier(.2,.8,.2,1) both;
}
.goal:hover { transform: translateY(-3px); }
.goal.selected { box-shadow: 0 0 0 2px rgba(255,255,255,0.85), var(--shadow); }
.goal::before {
  /* reflet façon métal brossé */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(255,255,255,0.22), transparent 55%),
    repeating-linear-gradient(115deg, rgba(255,255,255,0.025) 0 2px, transparent 2px 6px);
}
.goal::after {
  /* poignée du coffre */
  content: ""; position: absolute; right: -50px; bottom: -50px; width: 170px; height: 170px; z-index: -1;
  border-radius: 50%;
  border: 14px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 0 0 22px rgba(255,255,255,0.04);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(0.98); } }

.goal-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.goal-name { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.goal-rate { font-size: 13px; color: rgba(255,255,255,0.75); }
.goal-badge {
  flex-shrink: 0;
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  background: rgba(0,0,0,0.25); backdrop-filter: blur(6px);
}
.goal-mid { display: flex; align-items: center; gap: 16px; }
.ring { width: 92px; height: 92px; flex-shrink: 0; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: rgba(255,255,255,0.18); }
.ring .bar { stroke: #fff; stroke-linecap: round; transition: stroke-dashoffset 1.1s cubic-bezier(.2,.8,.2,1); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 19px; font-weight: 300; letter-spacing: -0.03em; }
.goal-amount { font-weight: 200; font-size: 34px; letter-spacing: -0.04em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.goal-of { font-size: 13px; color: rgba(255,255,255,0.75); }
.goal-date { margin-top: auto; display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.goal-date .label { font-size: 12px; color: rgba(255,255,255,0.7); }
.goal-date .when { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.goal-date .in { font-size: 13px; color: rgba(255,255,255,0.8); }
.goal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.goal-actions .btn { min-height: 40px; padding: 0 14px; font-size: 13px; background: rgba(0,0,0,0.28); color: #fff; }
.goal-actions .btn:hover { background: rgba(0,0,0,0.4); }
.goal-actions .btn.deposit { background: #fff; color: #0a0a10; }
.goal.pulse { animation: pulse 0.7s ease; }
@keyframes pulse { 30% { transform: scale(1.03); } }

.empty {
  border: 1px dashed rgba(255,255,255,0.16); border-radius: var(--radius);
  padding: 36px 20px; text-align: center; color: var(--muted);
}
.empty strong { display: block; color: var(--text); font-size: 18px; margin-bottom: 6px; }

/* Panneaux */
.panel {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 14px;
}
.panel h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.detail { animation: cardIn 0.4s ease both; }
@media (min-width: 900px) {
  .detail { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
  .detail[hidden] { display: none; }
  .detail .section-head { grid-column: 1 / -1; }
  .detail .chart-panel { grid-column: 1 / -1; grid-row: 2; }
}

/* Et si */
.whatif output { color: var(--accent); font-weight: 600; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 34px; margin: 16px 0 8px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent) var(--p, 5%), rgba(255,255,255,0.12) var(--p, 5%));
}
input[type="range"]::-moz-range-track { height: 8px; border-radius: 99px; background: rgba(255,255,255,0.12); }
input[type="range"]::-moz-range-progress { height: 8px; border-radius: 99px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -10px; border-radius: 50%;
  background: #fff; border: 0; box-shadow: 0 4px 16px rgba(179, 139, 255, 0.6);
}
input[type="range"]::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 0; }
.whatif-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.whatif-grid .gain { grid-column: 1 / -1; padding-top: 12px; border-top: 1px solid var(--panel-border); }
.label { font-size: 12px; color: var(--muted); }
.value { font-size: 18px; font-weight: 500; letter-spacing: -0.01em; }
.value.accent { color: var(--accent); }
.gain-value { font-size: 34px; font-weight: 200; letter-spacing: -0.04em; color: var(--green); }

/* Graphique */
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 14px; height: 3px; border-radius: 2px; display: inline-block; background: var(--accent); }
.dot.dashed { background: repeating-linear-gradient(90deg, var(--accent-2) 0 4px, transparent 4px 7px); }
.chart { margin-top: 12px; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: rgba(255,255,255,0.07); }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke: url(#lineGrad); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .line.draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.2s cubic-bezier(.3,.7,.2,1) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.chart .proj { fill: none; stroke: var(--accent-2); stroke-width: 2; stroke-dasharray: 5 6; opacity: 0.8; }
.chart .target { stroke: var(--pink); stroke-dasharray: 2 5; stroke-width: 1.5; }
.chart .target-label { fill: var(--pink); font-size: 11px; font-weight: 600; font-family: var(--font); }
.chart .pt { fill: #fff; stroke: rgba(179,139,255,0.45); stroke-width: 6; }
.chart .pt-s { fill: rgba(255,255,255,0.55); }
.chart .pt-h { fill: var(--bg); stroke: #fff; stroke-width: 2.5; pointer-events: none; }
.chart .tip {
  position: absolute; pointer-events: none; transform: translate(-50%, -120%);
  background: #fff; color: #0a0a10; font-size: 12px; font-weight: 600;
  padding: 6px 10px; border-radius: 10px; white-space: nowrap; opacity: 0; transition: opacity 0.15s;
}
.chart .tip.show { opacity: 1; }

/* Historique */
.history { list-style: none; padding: 0; margin: 10px 0 0; max-height: 320px; overflow: auto; }
.history li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--panel-border); }
.history li:last-child { border-bottom: 0; }
.history .h-date { font-size: 14px; }
.history .h-note { font-size: 12px; color: var(--muted); }
.history .h-amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.history .h-amt.plus { color: var(--green); }
.history .h-amt.minus { color: var(--danger); }
.history .del { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; font-size: 13px; }
.history .del:hover { color: var(--danger); }

/* Explications */
.explain { margin-top: 48px; }
.explain h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 14px; }
.steps { display: grid; gap: 12px; }
@media (min-width: 760px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.steps article { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 20px; }
.steps h3 { font-size: 16px; font-weight: 600; margin: 10px 0 4px; }
.steps p { color: var(--muted); font-size: 14px; }
.step-n {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--pink)); font-weight: 600; font-size: 14px;
}
.privacy { margin-top: 16px; color: var(--muted); font-size: 14px; text-align: center; }

.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }

/* Fenêtres (bottom sheet sur mobile) */
.sheet {
  border: 0; padding: 0; color: var(--text);
  background: var(--bg-2);
  width: 100%; max-width: 520px;
  max-height: 92vh;
  margin: auto auto 0;
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -10px 60px rgba(0,0,0,0.6);
  border-top: 1px solid var(--panel-border);
}
.sheet[open] { animation: sheetIn 0.35s cubic-bezier(.2,.8,.2,1); }
@keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } }
.sheet::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
@media (min-width: 640px) {
  .sheet { margin: auto; border-radius: 28px; border: 1px solid var(--panel-border); }
}
.sheet form { padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.sheet-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; }
.sheet-actions .primary { flex: 1; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 6px; }
.field input:not([type="radio"]) {
  width: 100%; min-height: 50px; padding: 0 14px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--panel-border); border-radius: var(--radius-sm);
  font-size: 16px; outline: none; transition: border-color 0.2s, background 0.2s;
}
.field input:focus { border-color: var(--accent); background: rgba(179,139,255,0.08); }
.field.big input { min-height: 72px; font-size: 36px; font-weight: 200; letter-spacing: -0.03em; text-align: center; }
.seg-wrap { display: grid; grid-template-columns: 1fr 1fr; background: rgba(255,255,255,0.06); border-radius: var(--radius-sm); padding: 4px; min-height: 50px; }
.seg-wrap label { display: grid; }
.seg-wrap input { position: absolute; opacity: 0; pointer-events: none; }
.seg-wrap span { display: grid; place-items: center; border-radius: 10px; font-size: 14px; cursor: pointer; color: var(--muted); transition: background 0.2s, color 0.2s; }
.seg-wrap input:checked + span { background: #fff; color: #0a0a10; font-weight: 600; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches label { position: relative; }
.swatches input { position: absolute; opacity: 0; }
.swatches span { display: block; width: 40px; height: 40px; border-radius: 50%; background: var(--g); cursor: pointer; border: 3px solid transparent; transition: transform 0.15s; }
.swatches input:checked + span { border-color: #fff; transform: scale(1.1); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chips button { border: 1px solid var(--panel-border); background: rgba(255,255,255,0.06); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: 14px; }
.chips button:hover { background: rgba(255,255,255,0.12); }
.hint { font-size: 12px; color: var(--muted); text-align: center; }
.form-error { color: var(--danger); font-size: 14px; min-height: 0; }
.form-error:empty { display: none; }

/* Toast + effets */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: #fff; color: #0a0a10; font-weight: 600; font-size: 14px;
  padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow);
  transition: transform 0.3s ease, opacity 0.3s ease; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }
.noscript { text-align: center; padding: 20px; color: var(--danger); }

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