[hidden] { display: none !important; }
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f0f0f4;
  --text: #16161d;
  --muted: #6b6b78;
  --border: #e3e3ea;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --radius: 16px;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e12; --surface: #17171d; --surface-2: #202028; --text: #f2f2f6;
    --muted: #9a9aa8; --border: #2a2a34; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e12; --surface: #17171d; --surface-2: #202028; --text: #f2f2f6;
  --muted: #9a9aa8; --border: #2a2a34; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.45;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }

main { max-width: 560px; margin: 0 auto; padding: 8px 16px 24px; outline: none; }
h1 { font-size: 24px; margin: 8px 0 4px; }
h2 { font-size: 18px; margin: 20px 0 8px; }
.sub { color: var(--muted); margin: 0 0 16px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0;
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--border); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn[disabled] { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 140px; }
.stack { display: grid; gap: 10px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.note { font-size: 14px; color: var(--muted); }
.note.warn { color: inherit; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; }

/* Business card */
.bcard {
  --c: var(--accent);
  position: relative; overflow: hidden;
  border-radius: 20px; padding: 22px; color: #fff;
  background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 55%, #000));
  box-shadow: 0 12px 32px color-mix(in srgb, var(--c) 35%, transparent);
  aspect-ratio: 1.75 / 1; display: flex; flex-direction: column; justify-content: space-between;
}
.bcard.tall { aspect-ratio: auto; min-height: 220px; }
.bcard::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255,255,255,.10); pointer-events: none;
}
.bcard .head { display: flex; gap: 14px; align-items: center; position: relative; z-index: 1; }
.avatar {
  width: 64px; height: 64px; border-radius: 50%; flex: none; object-fit: cover;
  background: rgba(255,255,255,.2); display: grid; place-items: center; font-weight: 700; font-size: 22px;
  border: 2px solid rgba(255,255,255,.5);
}
.bcard .name { font-size: 22px; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.bcard .role { opacity: .9; font-size: 15px; overflow-wrap: anywhere; }
.bcard .lines { display: grid; gap: 3px; font-size: 14px; position: relative; z-index: 1; margin-top: 14px; }
.bcard .lines div { overflow-wrap: anywhere; opacity: .95; }

/* Contact detail list */
.details { list-style: none; margin: 16px 0 0; padding: 0; }
.details li { border-top: 1px solid var(--border); }
.details li:first-child { border-top: 0; }
.details a, .details span.item {
  display: flex; gap: 12px; align-items: center; padding: 12px 4px; color: var(--text); text-decoration: none; overflow-wrap: anywhere;
}
.details .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; flex: none; color: var(--accent); }
.details .ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.details small { display: block; color: var(--muted); font-size: 12px; }

/* Forms */
.form { display: grid; gap: 14px; }
label.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.field input, .field textarea, .field select, input.search {
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-height: 48px; width: 100%;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field textarea:focus, input.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.grid2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0; }
.swatch[aria-checked="true"] { border-color: var(--text); }
.photo-row { display: flex; align-items: center; gap: 14px; }
.photo-row .avatar { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.linkrow { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: 8px; }
.linkrow input { min-width: 0; }

/* Share */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { font: inherit; font-weight: 600; border: 0; border-radius: 9px; min-height: 40px; background: transparent; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.qrbox { background: #fff; border-radius: 20px; padding: 18px; display: grid; place-items: center; margin: 16px auto; max-width: 340px; }
.qrbox canvas { width: 100%; height: auto; image-rendering: pixelated; }
.qrcap { text-align: center; color: var(--muted); font-size: 14px; margin-top: -6px; }

/* Scanner */
.scanner { position: relative; border-radius: 20px; overflow: hidden; background: #000; aspect-ratio: 1; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .frame { position: absolute; inset: 15%; border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.scanner .msg { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; text-align: center; padding: 24px; }

/* Contacts */
.clist { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.clist a { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; color: var(--text); text-decoration: none; }
.clist .avatar { width: 44px; height: 44px; font-size: 16px; color: #fff; border: 0; }
.clist .meta { min-width: 0; }
.clist .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clist .meta small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty svg { width: 56px; height: 56px; fill: none; stroke: currentColor; stroke-width: 1.4; margin-bottom: 8px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); text-align: center; z-index: 20;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.hero { text-align: center; padding: 24px 8px 8px; }
.hero h1 { font-size: 26px; }
.received-banner { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }

/* ---------- Arrière-plan : clair et sobre (gris bleuté, lueur discrète, quadrillage fin) ; bleu nuit en mode sombre ---------- */
:root {
  --bg: #eef2f7;
  --on-bg: #0f1b2d;
  --on-bg-muted: #5a6577;
  --line: rgba(15, 27, 45, .14);
  --fill: rgba(15, 27, 45, .06);
  --glow-1: rgba(79, 70, 229, .10);
  --glow-2: rgba(14, 165, 233, .08);
  --grid: rgba(15, 27, 45, .035);
  --topbar: rgba(238, 242, 247, .85);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1422; --on-bg: #eef2f8; --on-bg-muted: #a7b2c5; --line: rgba(255,255,255,.18); --fill: rgba(255,255,255,.08);
    --glow-1: rgba(99, 102, 241, .22); --glow-2: rgba(14, 165, 233, .10); --grid: rgba(255,255,255,.03); --topbar: rgba(11, 20, 34, .82);
  }
}
:root[data-theme="dark"] {
  --bg: #0b1422; --on-bg: #eef2f8; --on-bg-muted: #a7b2c5; --line: rgba(255,255,255,.18); --fill: rgba(255,255,255,.08);
  --glow-1: rgba(99, 102, 241, .22); --glow-2: rgba(14, 165, 233, .10); --grid: rgba(255,255,255,.03); --topbar: rgba(11, 20, 34, .82);
}

body {
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 560px at 85% -8%, var(--glow-1), transparent 62%),
    radial-gradient(900px 520px at -15% 105%, var(--glow-2), transparent 60%),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
  background-attachment: fixed;
}
.topbar { background: var(--topbar); color: var(--on-bg); border-bottom: 1px solid var(--line); }
.topbar .btn.ghost { color: var(--on-bg); border-color: var(--line); }
.topbar .right { display: flex; gap: 8px; align-items: center; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.lang button { font: inherit; font-size: 13px; font-weight: 700; border: 0; background: transparent; color: var(--on-bg-muted); min-height: 34px; min-width: 40px; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--on-bg); color: var(--bg); }

/* Texte posé directement sur le fond */
main { color: var(--on-bg); }
main a:not(.btn) { color: var(--on-bg); }
.sub, .note, .qrcap, .empty { color: var(--on-bg-muted); }
main > .btn.ghost, .row > .btn.ghost, .stack > .btn.ghost, .field .btn.ghost, .linkrow .btn.ghost { color: var(--on-bg); border-color: var(--line); }
.row > .btn.danger { color: var(--danger); border-color: var(--line); }
.btn.secondary { background: var(--surface); color: var(--on-bg); border: 1px solid var(--line); }
.swatch[aria-checked="true"] { border-color: var(--on-bg); }
.photo-row .avatar { background: var(--fill); color: var(--on-bg-muted); border-color: var(--line); }
.badge { background: var(--fill); color: var(--on-bg); }
.form .field > span, .form label.field { color: var(--on-bg); }

/* Surfaces : texte normal */
.panel, .details, .clist a, .received-banner, .seg { color: var(--text); }
main .clist a, main .details a, main .details span.item { color: var(--text); }
.panel .note, .panel .sub { color: var(--muted); }
.panel .btn.ghost { color: var(--accent); border-color: var(--border); }
.panel a:not(.btn) { color: var(--accent); }
.seg { background: var(--surface); border: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.received-banner { background: var(--surface); border: 1px solid var(--line); }
.panel .badge { background: var(--surface-2); color: var(--muted); }
.qrbox { border: 1px solid var(--line); }

/* Carte de visite : texture fine et liseré */
.bcard {
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,.035) 0 2px, transparent 2px 10px),
    linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 50%, #000));
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 18px 40px rgba(15,27,45,.22);
}
.clist a { border-color: var(--line); }
#toast { background: var(--on-bg); color: var(--bg); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.acct { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--on-bg); display: grid; place-items: center; cursor: pointer; padding: 0; }
.acct svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.acct.signed { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.gwrap { display: grid; gap: 14px; margin-bottom: 14px; }
.gwrap[hidden] { display: none !important; }
.gbtn { display: flex; justify-content: center; min-height: 44px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--on-bg-muted); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Exemples de cartes (accueil) ---------- */
.showcase { margin: 22px auto 22px; max-width: 420px; }
.sc-stage { position: relative; aspect-ratio: 1.75 / 1; perspective: 1200px; cursor: pointer; }
.sc-slide { position: absolute; inset: 0; opacity: 0; transform: rotateY(-35deg) translateX(30px) scale(.92); transition: opacity .6s ease, transform .7s cubic-bezier(.2,.8,.2,1); pointer-events: none; }
.sc-slide.out { opacity: 0; transform: rotateY(35deg) translateX(-30px) scale(.92); }
.sc-slide.on { opacity: 1; transform: none; pointer-events: auto; }
.sc-slide.on > * { animation: floaty 5s ease-in-out infinite; }
.sc-slide > * { height: 100%; text-align: left; }
@keyframes floaty { 0%,100% { transform: translateY(0) rotateX(0) rotateZ(-.4deg); } 50% { transform: translateY(-6px) rotateX(3deg) rotateZ(.4deg); } }
.sc-slide .bcard { aspect-ratio: auto; }
.sc-dots { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.sc-dots button { font: inherit; font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--on-bg-muted); border-radius: 999px; padding: 6px 12px; min-height: 34px; cursor: pointer; }
.sc-dots button[aria-selected="true"] { background: var(--on-bg); color: var(--bg); border-color: var(--on-bg); }
@media (prefers-reduced-motion: reduce) { .sc-slide, .sc-slide.out { transition: opacity .3s; transform: none; } .sc-slide.on > * { animation: none; } }

.xcard { position: relative; overflow: hidden; border-radius: 14px; box-shadow: 0 18px 40px rgba(15,27,45,.22); }
/* Élégante : papier ivoire, lettrage fin et espacé */
.xcard.elegant {
  background: radial-gradient(120% 90% at 30% 20%, #f8f5ec, #ece6d6);
  color: #2b2a26; padding: 18px 20px; display: grid; grid-template-rows: auto 1fr auto;
  font-family: "Bodoni 72", "Didot", "Bodoni MT", "Libre Bodoni", Georgia, "Times New Roman", serif;
  border: 1px solid rgba(0,0,0,.06);
}
.xcard.elegant::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .35;
  background-image: repeating-linear-gradient(0deg, rgba(0,0,0,.018) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgba(0,0,0,.012) 0 1px, transparent 1px 4px); }
.el-top { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; }
.el-mid { align-self: center; text-align: center; }
.el-name { font-size: 22px; letter-spacing: .22em; text-transform: uppercase; font-weight: 400; }
.el-role { margin-top: 6px; font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: #55524a; }
.el-bot { text-align: center; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: #55524a; }
/* New York : noir, jaune taxi, typo condensée, skyline */
.xcard.ny { background: #111214; color: #fff; font-family: "Bebas Neue", "Oswald", Impact, "Arial Narrow Bold", "Helvetica Neue", sans-serif; }
.ny-stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 14px; background: repeating-linear-gradient(180deg, #f7c600 0 18px, #111214 18px 24px); }
.ny-body { position: relative; z-index: 1; padding: 16px 18px 0 34px; }
.ny-name { font-size: 34px; line-height: .92; letter-spacing: .02em; text-transform: uppercase; color: #f7c600; }
.ny-role { margin-top: 8px; font-family: system-ui, sans-serif; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.ny-lines { margin-top: 4px; font-family: system-ui, sans-serif; font-size: 11.5px; opacity: .75; }
.xcard.ny .sky { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 34%; fill: #26282d; }

/* Fenêtre d'aide à l'installation */
.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(10,16,28,.45); display: flex; align-items: flex-end; justify-content: center; padding: 16px max(16px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.sheet[hidden] { display: none !important; }
.sheet-card { background: var(--surface); color: var(--text); border-radius: 20px; padding: 20px; width: 100%; max-width: 480px; display: grid; gap: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.sheet-card p { margin: 0; color: var(--muted); }

/* Bouton Installer : mis en avant, avec une pulsation et un reflet tant qu'on ne l'a pas touché */
.topbar .btn.install { position: relative; overflow: hidden; background: var(--accent); color: #fff; border: 0; }
.btn.install.attn { animation: pulse 2.4s ease-out infinite; }
.btn.install.attn::after { content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 45%; transform: skewX(-20deg);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: shine 3.2s ease-in-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes shine { 0%, 55% { left: -60%; } 85%, 100% { left: 130%; } }
@media (prefers-reduced-motion: reduce) { .btn.install.attn, .btn.install.attn::after { animation: none; } }
