:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #aeaeb2;
  --line: #d2d2d7;
  --fill: #f2f2f4;
  --accent: #8a1538;
  --accent-ink: #ffffff;
  --accent-soft: rgba(138, 21, 56, 0.09);
  --ok: #248a3d;
  --warn: #b25000;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --card: #1c1c1e; --text: #f5f5f7; --muted: #98989d; --faint: #636366;
    --line: #38383a; --fill: #2c2c2e; --accent: #e5577a; --accent-ink: #1c0710;
    --accent-soft: rgba(229, 87, 122, 0.14); --ok: #30d158; --warn: #ff9f0a;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --card: #1c1c1e; --text: #f5f5f7; --muted: #98989d; --faint: #636366;
  --line: #38383a; --fill: #2c2c2e; --accent: #e5577a; --accent-ink: #1c0710;
  --accent-soft: rgba(229, 87, 122, 0.14); --ok: #30d158; --warn: #ff9f0a;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--font); font-size: 17px; line-height: 1.4; letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
}
button, input { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
[hidden] { display: none !important; }

/* ---------- Typo ---------- */
.eyebrow { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -0.025em; }
h1 { font-size: clamp(32px, 6vw, 56px); font-weight: 700; line-height: 1.05; }
h2 { font-size: clamp(24px, 3.4vw, 34px); font-weight: 700; line-height: 1.1; }
h3 { font-size: 19px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- Layout ---------- */
.wrap { max-width: 720px; margin: 0 auto; padding: 24px 16px 120px; }
.wide { max-width: 1280px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap-row { flex-wrap: wrap; }
.spacer { flex: 1; }
.center { text-align: center; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.section-title { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.section-title .num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-size: 13px; font-weight: 700; display: inline-grid; place-items: center; flex: none; transform: translateY(-2px);
}

/* ---------- Boutons ---------- */
.btn {
  appearance: none; border: 0; border-radius: 999px; padding: 0 22px; height: 50px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 17px; cursor: pointer; background: var(--fill); color: var(--text);
  transition: transform .12s ease, opacity .2s, background .2s; white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .35; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--accent); padding: 0 12px; }
.btn.small { height: 36px; font-size: 15px; padding: 0 14px; }
.btn.block { width: 100%; }
.btn.icon { width: 44px; height: 44px; padding: 0; }
.btn svg { width: 20px; height: 20px; flex: none; }

/* ---------- Champs ---------- */
.field {
  width: 100%; height: 50px; border-radius: 12px; border: 0; background: var(--fill);
  padding: 0 14px; font-size: 17px; outline: none; transition: box-shadow .15s;
}
.field:focus { box-shadow: 0 0 0 3px var(--accent-soft), inset 0 0 0 1.5px var(--accent); }
.field.big { height: 58px; font-size: 20px; text-align: center; font-weight: 600; }
label.lbl { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 0; background: var(--fill); border-radius: 999px; height: 34px; padding: 0 14px;
  font-size: 15px; cursor: pointer; transition: background .15s, color .15s;
}
.chip:hover { background: var(--accent-soft); color: var(--accent); }
.chip.on { background: var(--accent); color: var(--accent-ink); }

/* Interrupteur iOS */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .2s; }
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .2s;
}
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }

/* Segmenté */
.seg { display: inline-flex; background: var(--fill); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button {
  border: 0; background: transparent; border-radius: 8px; padding: 6px 14px; font-size: 14px; font-weight: 500;
  cursor: pointer; color: var(--text);
}
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }

/* ---------- Listes ---------- */
.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; }
.list .idx { width: 26px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 15px; }
.list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .mini { border: 0; background: transparent; color: var(--faint); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 18px; }
.list .mini:hover { background: var(--fill); color: var(--text); }

/* ---------- Graphique ---------- */
.plot { width: 100%; display: block; user-select: none; -webkit-user-select: none; }
.plot.interactive { touch-action: none; cursor: crosshair; }
.plot .frame { fill: var(--fill); }
.plot .grid { stroke: var(--line); stroke-width: 1; opacity: .7; }
.plot .axis { stroke: var(--faint); stroke-width: 1.5; }
.plot .lbl { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.plot .ttl { fill: var(--text); font-size: 15px; font-weight: 600; font-family: var(--font); }
.plot .hint { fill: var(--muted); font-size: 15px; font-family: var(--font); }
.plot .dot { transition: cx .25s ease, cy .25s ease, opacity .3s; }
.plot .dot.draft { opacity: .45; }
.plot .me-ring { fill: none; stroke: var(--accent); stroke-width: 2; opacity: .35; }
.plot .wlabel { font-size: 12px; font-weight: 700; font-family: var(--font); fill: #fff; pointer-events: none; }
.plot .wname { font-size: 13px; font-weight: 600; font-family: var(--font); paint-order: stroke; stroke: var(--card); stroke-width: 3px; stroke-linejoin: round; stroke-opacity: .9; }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.plot .pop { transform-box: fill-box; transform-origin: center; animation: pop .3s cubic-bezier(.3,1.6,.6,1); }

/* ---------- Divers ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--fill); color: var(--muted); }
.badge.ok { background: rgba(36,138,61,.12); color: var(--ok); }
.badge.warn { background: rgba(178,80,0,.12); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; }

.trial-ribbon {
  position: absolute; top: calc(6px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 50;
  font-size: 11px; font-weight: 500; color: var(--muted); background: var(--card); box-shadow: var(--shadow);
  padding: 3px 10px; border-radius: 999px; pointer-events: none; white-space: nowrap;
}
.trial-ribbon.inline { position: static; transform: none; box-shadow: none; background: var(--fill); }
.conn {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); font-size: 14px; padding: 8px 16px; border-radius: 999px;
}
.toast {
  position: fixed; bottom: 70px; left: 50%; transform: translate(-50%, 20px); opacity: 0; z-index: 70;
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 14px; font-size: 15px;
  transition: opacity .25s, transform .25s; pointer-events: none; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.fade-in { animation: fade .35s ease backwards; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.empty-state { min-height: 70dvh; display: grid; place-items: center; text-align: center; padding: 24px; }
.empty-state .glyph { font-size: 64px; line-height: 1; margin-bottom: 18px; }
@keyframes breathe { 0%,100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.08); opacity: 1; } }
.breathe { animation: breathe 2.6s ease-in-out infinite; display: inline-block; }

@media print {
  .no-print { display: none !important; }
}
