/* ==========================================================================
   Prism v2 — design system « Liquid Glass v2 » (sombre natif, CSS pur)
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #05060a;
  --text: #f5f7fb;
  --muted: #a1a9ba;
  --faint: #6c7486;

  --glass-top: rgba(255, 255, 255, 0.09);
  --glass-bottom: rgba(255, 255, 255, 0.035);
  --glass-fill: rgba(255, 255, 255, 0.06);
  --glass-hover: rgba(255, 255, 255, 0.11);
  --glass-solid: rgba(14, 17, 26, 0.62);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.24);
  --highlight: rgba(255, 255, 255, 0.3);
  --well: rgba(0, 0, 0, 0.32);

  --ok: #3ddc84;
  --warn: #ffb547;
  --err: #ff5e6c;
  --info: #7cc4ff;
  --spectrum: linear-gradient(90deg, #ff4d5e, #ff9f1c, #ffe14d, #3ddc84, #3aa0ff, #9b5cff);

  --r-xl: 26px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;

  --shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.75), 0 2px 8px rgba(0, 0, 0, 0.35);
  --blur: blur(28px) saturate(175%);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.2, 1.2, 0.3, 1);

  --topbar-h: 58px;
  --gutter: 14px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { background: var(--bg); height: 100%; }

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font: 14.5px/1.5 var(--font);
  color: var(--text);
  background: transparent; /* le fond vient de <html> : il ne doit pas masquer les dégradés (z-index:-1) */
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--info); outline-offset: 3px; }
[hidden] { display: none !important; }

.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;
}

kbd {
  font: 11px var(--mono);
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--glass-fill);
  color: var(--muted);
}

/* --- Fond : aurore sous le verre ---------------------------------------------
   Performance : dégradés radiaux (aucun filter: blur, aucun mode de fusion), peints une fois.
   Ils ne dérivent que canvas vide ; dès la première carte, fond immobile : les panneaux de verre
   (backdrop-filter) n'ont plus à re-flouter leur arrière-plan à chaque image. */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; }
.b1 { width: 60vmax; height: 60vmax; left: -20vmax; top: -26vmax; background: radial-gradient(closest-side, rgba(42, 82, 255, 0.5), rgba(42, 82, 255, 0.22) 55%, transparent); }
.b2 { width: 56vmax; height: 56vmax; right: -22vmax; bottom: -28vmax; background: radial-gradient(closest-side, rgba(143, 54, 255, 0.46), rgba(143, 54, 255, 0.2) 55%, transparent); }
.b3 { width: 36vmax; height: 36vmax; left: 40%; top: 26%; background: radial-gradient(closest-side, rgba(255, 61, 139, 0.2), rgba(255, 61, 139, 0.08) 55%, transparent); }
.b4 { width: 32vmax; height: 32vmax; right: 10%; top: -10vmax; background: radial-gradient(closest-side, rgba(0, 194, 199, 0.2), rgba(0, 194, 199, 0.08) 55%, transparent); }
.b5 { width: 30vmax; height: 30vmax; left: 6%; bottom: -8vmax; background: radial-gradient(closest-side, rgba(255, 159, 28, 0.13), rgba(255, 159, 28, 0.05) 55%, transparent); }
body.is-empty .b1 { animation: float-a 34s var(--ease) infinite alternate; }
body.is-empty .b2 { animation: float-b 41s var(--ease) infinite alternate; }
body.is-empty .b3 { animation: float-c 29s var(--ease) infinite alternate; }
body.is-empty .b4 { animation: float-b 47s var(--ease) infinite alternate-reverse; }
body.is-empty .b5 { animation: float-a 53s var(--ease) infinite alternate-reverse; }
.grain {
  position: absolute; inset: 0;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@keyframes float-a { to { transform: translate(14vmax, 9vmax) scale(1.12); } }
@keyframes float-b { to { transform: translate(-12vmax, -10vmax) scale(0.9); } }
@keyframes float-c { 50% { transform: translate(-10vmax, 8vmax) scale(1.25); } to { transform: translate(8vmax, -6vmax) scale(0.85); } }

/* --- Matériau verre ------------------------------------------------------- */
.glass {
  position: relative;
  background: linear-gradient(180deg, var(--glass-top), var(--glass-bottom));
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: inset 0 1px 0 var(--highlight), inset 0 -1px 0 rgba(255, 255, 255, 0.04), var(--shadow);
}
/* Liseré lumineux : l'arête haute-gauche capte la lumière. */
.glass::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0) 70%, rgba(255, 255, 255, 0.18));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* --- Pastilles d'état ------------------------------------------------------ */
.dot {
  width: 8px; height: 8px; flex: none;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}
[data-state="live"] .dot,
[data-state="ready"] .dot { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
[data-state="mock"] .dot,
[data-state="warn"] .dot { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
[data-state="error"] .dot { background: var(--err); box-shadow: 0 0 10px var(--err); }
[data-state="loading"] .dot,
[data-state="busy"] .dot,
[data-state="pending"] .dot { background: var(--info); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.75); } }

/* --- Boutons ---------------------------------------------------------------- */
.tool {
  padding: 6px 11px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--glass-fill);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
}
.tool:hover:not(:disabled) { background: var(--glass-hover); color: var(--text); border-color: var(--line-strong); }
.tool:active:not(:disabled) { transform: scale(0.97); }
.tool:disabled { opacity: 0.4; }
.tool[aria-pressed="true"] { color: var(--text); background: rgba(124, 196, 255, 0.18); border-color: rgba(124, 196, 255, 0.45); }
.tool.danger:hover:not(:disabled) { color: #ffc9ce; border-color: rgba(255, 94, 108, 0.5); background: rgba(255, 94, 108, 0.12); }
.tool.icon { width: 30px; padding: 5px 0; font-size: 15px; line-height: 1; }

.icon-btn {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  font-size: 18px; line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  transition: background 0.2s, color 0.2s;
}
.icon-btn:hover { background: var(--glass-hover); color: var(--text); }

/* Bouton d'action lumineux : halo spectral derrière un cœur en verre clair. */
.cta {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 10px 20px 10px 16px;
  font-weight: 650;
  color: #0a0c12;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #dde6ff);
  box-shadow: inset 0 1px 0 #fff, inset 0 -2px 6px rgba(80, 100, 180, 0.25), 0 10px 30px -8px rgba(124, 196, 255, 0.75);
  transition: transform 0.2s var(--ease), box-shadow 0.3s, opacity 0.2s;
  white-space: nowrap;
}
.cta::after {
  content: "";
  position: absolute; inset: -3px; z-index: -1;
  border-radius: inherit;
  background: var(--spectrum);
  filter: blur(14px);
  opacity: 0.55;
  transition: opacity 0.3s;
}
.cta:hover:not(:disabled) { transform: translateY(-1px); }
.cta:hover:not(:disabled)::after { opacity: 0.95; }
.cta:active:not(:disabled) { transform: translateY(1px) scale(0.98); }
.cta:disabled { opacity: 0.45; }
.cta:disabled::after { opacity: 0.15; }
.cta-icon { width: 12px; height: 12px; background: var(--spectrum); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.cta-small { padding: 8px 16px; font-size: 13px; }

.chip {
  flex: none;
  padding: 5px 11px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--glass-fill);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s var(--spring);
}
.chip:hover { background: var(--glass-hover); color: var(--text); border-color: var(--line-strong); transform: translateY(-1px); }
.chip-file::before { content: "📎 "; }

/* --- Barre du haut ------------------------------------------------------------ */
.topbar {
  position: fixed;
  top: var(--gutter); left: var(--gutter); right: var(--gutter);
  z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 10px 0 9px;
  border-radius: var(--r-lg);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; border-radius: var(--r-sm); }
.logo {
  width: 38px; height: 38px;
  padding: 3px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: transform 0.4s var(--spring);
}
.brand:hover .logo { transform: rotate(-8deg) scale(1.06); }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.brand-version {
  align-self: center;
  padding: 2px 7px;
  font: 600 11px/1.2 var(--mono);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass-fill);
  white-space: nowrap;
}
.tagline { color: var(--muted); font-size: 13px; white-space: nowrap; }
.card-count { color: var(--faint); font-size: 12.5px; white-space: nowrap; }
.spacer { flex: 1; }
.canvas-tools { display: flex; align-items: center; gap: 4px; }
.zoom-level { min-width: 58px; font-variant-numeric: tabular-nums; }
.engine {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--glass-fill);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.engine:hover { color: var(--text); border-color: var(--line-strong); background: var(--glass-hover); }

/* --- Canvas --------------------------------------------------------------------- */
.workspace {
  position: fixed; inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.075) 1px, transparent 0);
  background-size: var(--grid-size, 28px) var(--grid-size, 28px);
  background-position: var(--grid-x, 0) var(--grid-y, 0);
}
body.is-panning .workspace { cursor: grabbing; }
body.is-panning .world { will-change: transform; }
/* Pendant un glisser, les iframes ne doivent pas capter le pointeur. */
body.is-panning iframe,
body.is-dragging iframe { pointer-events: none; }
body.is-dragging { cursor: grabbing; user-select: none; }

.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.world.is-arranging .card { transition: left 0.45s var(--ease), top 0.45s var(--ease); }

.canvas-empty {
  position: fixed;
  left: 50%; top: 46%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 48px));
  text-align: center;
  pointer-events: none;
  animation: fade-up 0.8s var(--ease) both;
}
.canvas-empty img { filter: drop-shadow(0 12px 34px rgba(58, 160, 255, 0.4)); animation: bob 6s ease-in-out infinite; }
.empty-title { margin: 14px 0 6px; font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.empty-sub { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.empty-hint { margin: 0; color: var(--faint); font-size: 12.5px; }
@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes fade-up { from { opacity: 0; transform: translate(-50%, calc(-50% + 16px)); } }

/* --- Reflet des bords : la lumière vient du pointeur (--mx, --my, --glow : reflections.js) ---
   Dans le fond de la carte (sous sa bordure semi-transparente et autour du corps), jamais en
   couche AU-DESSUS de l'iframe : une superposition, même sans pointer-events, ralentit l'aiguillage
   des clics vers une iframe isolée et en faisait perdre dans des rafales. */
.card {
  --glint: color-mix(in srgb, color-mix(in srgb, var(--card-accent) 60%, #fff) calc(var(--glow, 0) * 60%), transparent);
}
.card-bar { background: radial-gradient(220px circle at var(--mx, 50%) var(--my, 0), rgba(255, 255, 255, calc(var(--glow, 0) * 0.07)), transparent 70%); }

/* --- Liaisons du bus d'évènements (SVG sous les cartes, coordonnées du monde) ------------ */
.links { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; z-index: 0; }
/* Épaisseur et pointillés en pixels d'écran : la liaison reste lisible à 20 % de zoom. */
.link-line { fill: none; stroke: rgba(166, 107, 255, 0.6); stroke-width: 2; stroke-dasharray: 6 6; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.link-arrow { fill: rgba(166, 107, 255, 0.75); }
.link-glow {
  fill: none;
  stroke: #9fd8ff;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 14 100;
  stroke-dashoffset: 114;
  opacity: 0;
}
.link-glow.is-pulsing { animation: link-pulse 0.85s var(--ease); }
@keyframes link-pulse {
  0% { stroke-dashoffset: 114; opacity: 1; }
  85% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
.link.is-muted .link-line { stroke: rgba(255, 255, 255, 0.14); }
.link.is-muted .link-glow { display: none; }

/* --- Cartes ----------------------------------------------------------------------- */
/* Pas de backdrop-filter sur les cartes : le corps (opaque) en couvre presque toute la surface, et
   chaque déplacement du canvas obligeait à re-flouter l'arrière-plan de chaque carte à chaque image.
   Verre fumé quasi opaque à la place : même rendu, coût nul. */
.card {
  --card-accent: #7cc4ff;
  position: absolute;
  display: flex; flex-direction: column;
  border-radius: var(--r-lg);
  background:
    radial-gradient(300px circle at var(--mx, 50%) var(--my, 0), var(--glint), transparent 70%) border-box,
    linear-gradient(180deg, rgba(30, 35, 50, 0.92), rgba(13, 15, 22, 0.94)) border-box;
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 24px 60px -22px rgba(0, 0, 0, 0.8);
  transition: box-shadow 0.3s var(--ease), border-color 0.3s, translate 0.3s var(--ease);
  cursor: default;
}
.card:hover { border-color: var(--line-strong); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 30px 70px -20px rgba(0, 0, 0, 0.85), 0 0 0 1px color-mix(in srgb, var(--card-accent) 25%, transparent); }
.card.is-selected {
  border-color: color-mix(in srgb, var(--card-accent) 70%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 0 1px color-mix(in srgb, var(--card-accent) 55%, transparent),
    0 30px 80px -20px color-mix(in srgb, var(--card-accent) 35%, rgba(0, 0, 0, 0.8));
}
.card.is-moving { translate: 0 -3px; box-shadow: 0 40px 90px -20px rgba(0, 0, 0, 0.9), 0 0 0 1px color-mix(in srgb, var(--card-accent) 60%, transparent); }
.card.is-entering { animation: card-in 0.55s var(--ease) both; }
.card.is-flash { animation: card-flash 1s var(--ease); }
@keyframes card-flash { 30% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--card-accent) 80%, transparent), 0 0 60px -6px var(--card-accent); } }
.card.is-leaving { animation: card-out 0.25s ease-in both; pointer-events: none; }
@keyframes card-in { from { opacity: 0; transform: scale(0.92) translateY(14px); } }
@keyframes card-out { to { opacity: 0; transform: scale(0.94); } }

.card-bar {
  flex: none;
  height: 38px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 6px 0 12px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.card-bar:focus-visible { outline-offset: -2px; }
.card.is-moving .card-bar { cursor: grabbing; }
/* V5 · fusion : Engramme tenu au-dessus d'un autre, puis retour à sa place une fois la fusion proposée. */
.card.is-fusion-target { box-shadow: 0 0 0 2px #e879f9, 0 0 60px -6px rgba(232, 121, 249, 0.75); animation: fusion-pull 0.5s ease-in-out infinite alternate; }
.card.is-fusion-source { opacity: 0.82; }
.card.is-returning { transition: left 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes fusion-pull { from { scale: 1; } to { scale: 1.015; } }
@media (prefers-reduced-motion: reduce) { .card.is-fusion-target { animation: none; } .card.is-returning { transition: none; } }
.card-title { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { flex: none; max-width: 40%; font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-actions { display: flex; gap: 2px; opacity: 0.55; transition: opacity 0.2s; }
.card:hover .card-actions,
.card.is-selected .card-actions,
.card-bar:focus-within .card-actions { opacity: 1; }
.card-btn {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.card-btn svg { width: 16px; height: 16px; }
.card-btn:hover { background: var(--glass-hover); color: var(--text); }
.card-btn[data-action="close"]:hover { background: rgba(255, 94, 108, 0.16); color: #ffc9ce; }

.card-body {
  position: relative;
  flex: 1; min-height: 0;
  margin: 0 5px 5px;
  border-radius: calc(var(--r-lg) - 6px);
  overflow: hidden;
  background: #0b0d12;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
/* L'iframe reste invisible tant que le widget n'a pas signalé « ready » (chargé et stylé),
   puis fondu enchaîné avec le squelette. */
.card-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #0b0d12; transition: opacity 0.4s var(--ease); }
.card-body[data-frame="pending"] .card-frame { opacity: 0; transition: none; }

.card-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px;
  text-align: center;
  background: #0b0d12;
  overflow: hidden;
  transition: opacity 0.4s var(--ease), display 0.4s allow-discrete;
}
.card:not([data-state="loading"]):not([data-state="busy"]) .card-overlay { pointer-events: none; }
.card:not([data-state="loading"]):not([data-state="busy"]) .card-body:not([data-frame="pending"]) .card-overlay { display: none; opacity: 0; }
.card:not([data-state="loading"]):not([data-state="busy"]) .card-status { display: none; }
.card[data-state="busy"] .card-overlay { background: rgba(6, 7, 11, 0.62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }

/* --- Squelette holographique : silhouette de la future carte, balayée par un reflet irisé.
   Seuls transform et opacity sont animés : tout tourne sur le compositeur, rien sur le fil principal. */
.holo {
  position: absolute; inset: 0;
  display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); gap: 12px;
  padding: 22px 20px 20px;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 0% 0%, color-mix(in srgb, var(--card-accent) 16%, transparent), transparent 60%),
    radial-gradient(90% 60% at 100% 100%, rgba(166, 107, 255, 0.13), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 4px),
    #0b0d12;
}
.holo-bone {
  display: block;
  border-radius: 10px;
  background: linear-gradient(115deg, rgba(124, 196, 255, 0.11), rgba(166, 107, 255, 0.08) 45%, rgba(255, 94, 138, 0.07));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.holo-title { width: 58%; height: 18px; }
.holo-sub { width: 36%; height: 11px; margin-top: -4px; }
.holo-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.holo-tiles .holo-bone { height: 54px; border-radius: 14px; }
.holo-panel { display: flex; align-items: flex-end; gap: 6%; min-height: 0; padding: 16px 18px; border-radius: 16px; }
.holo-panel i {
  flex: 1;
  height: var(--h, 50%);
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--card-accent) 80%, transparent), color-mix(in srgb, #a66bff 22%, transparent));
  box-shadow: 0 0 18px -4px color-mix(in srgb, var(--card-accent) 60%, transparent);
  opacity: 0.7;
  transform-origin: bottom;
  animation: holo-bar 1.4s var(--ease) infinite alternate;
}
.holo-panel i:nth-child(1) { --h: 38%; animation-delay: -0.1s; }
.holo-panel i:nth-child(2) { --h: 62%; animation-delay: -0.5s; }
.holo-panel i:nth-child(3) { --h: 48%; animation-delay: -0.9s; }
.holo-panel i:nth-child(4) { --h: 80%; animation-delay: -0.3s; }
.holo-panel i:nth-child(5) { --h: 56%; animation-delay: -1.1s; }
.holo-panel i:nth-child(6) { --h: 70%; animation-delay: -0.7s; }
.holo-panel i:nth-child(7) { --h: 44%; animation-delay: -1.3s; }
.holo::after {
  content: "";
  position: absolute; top: -20%; bottom: -20%; left: 0;
  width: 55%;
  background: linear-gradient(100deg, transparent, rgba(124, 196, 255, 0.14) 30%, rgba(166, 107, 255, 0.24) 50%, rgba(255, 94, 138, 0.14) 70%, transparent);
  transform: translateX(-110%) skewX(-14deg);
  animation: holo-sweep 2.4s var(--ease) infinite;
  pointer-events: none;
}
@keyframes holo-bar { from { transform: scaleY(0.7); opacity: 0.35; } }
@keyframes holo-sweep { to { transform: translateX(260%) skewX(-14deg); } }
/* Refactorisation : le widget actuel reste visible, flouté ; seul le reflet le balaie. */
.card[data-state="busy"] .holo { background: transparent; }
.card[data-state="busy"] .holo > * { visibility: hidden; }

.card-status {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  max-width: 100%;
  padding: 14px 18px 12px;
  border-radius: 16px;
  background: rgba(8, 10, 16, 0.8);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 14px 34px -14px rgba(0, 0, 0, 0.85);
}
.card-overlay-text { margin: 0; color: var(--text); font-size: 13.5px; font-weight: 550; }
.card-elapsed { margin: 0 0 8px; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }

.card-error {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 20px;
  text-align: center;
  background: #0b0d12;
}
.card-error-text { margin: 0; color: #ffc9ce; font-size: 13px; overflow-wrap: anywhere; max-height: 70%; overflow: auto; scrollbar-width: none; }

.card-code {
  position: absolute; inset: 0; z-index: 1;
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  scrollbar-width: none;
  font: 12px/1.6 var(--mono);
  color: #d7deea;
  background: rgba(5, 6, 10, 0.96);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}
.card-code::-webkit-scrollbar { display: none; }

.card-resize {
  position: absolute; right: 2px; bottom: 2px; z-index: 3;
  width: 22px; height: 22px;
  cursor: nwse-resize;
  touch-action: none;
  border-radius: 0 0 var(--r-lg) 0;
  background:
    linear-gradient(135deg, transparent 58%, var(--line-strong) 58% 63%, transparent 63% 72%, var(--line-strong) 72% 77%, transparent 77%);
  opacity: 0;
  transition: opacity 0.2s;
}
.card:hover .card-resize,
.card.is-selected .card-resize,
.card.is-resizing .card-resize { opacity: 1; }

/* --- Dock de saisie ------------------------------------------------------------------- */
.dock {
  position: fixed;
  left: 50%; bottom: max(var(--gutter), env(safe-area-inset-bottom));
  z-index: 40;
  width: min(760px, calc(100vw - 2 * var(--gutter)));
  translate: -50% 0;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px;
  border-radius: var(--r-xl);
  transition: left 0.35s var(--ease), box-shadow 0.3s, scale 0.25s var(--spring);
}
body.has-inspector .dock { left: calc((100vw - 380px) / 2); }
.dock.is-invalid { animation: shake 0.45s ease; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

.examples { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 0; }
.examples::-webkit-scrollbar { display: none; }

.attachment {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 8px;
  border: 1px solid color-mix(in srgb, var(--info) 35%, transparent);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--info) 9%, transparent);
  animation: fade-in 0.3s var(--ease);
}
.file-badge {
  flex: none;
  min-width: 42px; padding: 4px 6px;
  font: 700 10.5px/1 var(--mono);
  text-align: center;
  border-radius: 7px;
  color: #0a0c12;
  background: var(--info);
}
.attachment[data-kind="csv"] .file-badge { background: #3ddc84; }
.attachment[data-kind="csv"] .file-badge::before { content: "CSV"; }
.attachment[data-kind="json"] .file-badge { background: #ffb547; }
.attachment[data-kind="json"] .file-badge::before { content: "JSON"; }
.attachment[data-kind="txt"] .file-badge { background: #a6b4ff; }
.attachment[data-kind="txt"] .file-badge::before { content: "TXT"; }
/* Analyse en cours dans le Web Worker. */
.attachment[data-state="reading"] .file-badge { background: rgba(255, 255, 255, 0.14); color: var(--muted); }
.attachment[data-state="reading"] .file-badge::before { content: "···"; }
.attachment[data-state="reading"] .file-info span { animation: breathe 1.2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.4; } }
.file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.file-info strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info span { font-size: 11.5px; color: var(--muted); }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } }

.composer { display: flex; align-items: flex-end; gap: 8px; }
.attach {
  flex: none;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  color: var(--muted);
  background: var(--glass-fill);
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: background 0.2s, color 0.2s, transform 0.3s var(--spring);
}
.attach svg { width: 19px; height: 19px; }
.attach:hover { background: var(--glass-hover); color: var(--text); transform: rotate(-12deg); }
.dock.has-file .attach { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); }
#prompt {
  flex: 1; min-width: 0;
  min-height: 40px; max-height: 168px;
  padding: 9px 4px;
  resize: none;
  font: 15px/1.45 var(--font);
  color: var(--text);
  background: transparent;
  border: 0;
  outline: none;
  scrollbar-width: none;
}
#prompt::placeholder { color: var(--faint); }
.dock:focus-within { box-shadow: inset 0 1px 0 var(--highlight), var(--shadow), 0 0 0 1px rgba(124, 196, 255, 0.35), 0 0 40px -10px rgba(124, 196, 255, 0.45); }
.dock-hint { margin: 0; text-align: center; font-size: 11.5px; color: var(--faint); }

.dropzone {
  position: absolute; inset: -1px; z-index: 5;
  display: none; place-items: center;
  border-radius: inherit;
  border: 2px dashed rgba(124, 196, 255, 0.6);
  background: rgba(20, 40, 80, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-weight: 600;
  pointer-events: none;
}
body.is-dropping .dropzone { display: grid; animation: fade-in 0.2s ease; }
body.is-dropping .dock { scale: 1.02; }
.dock.is-drop-target .dropzone { border-color: #fff; background: rgba(40, 80, 160, 0.8); }

/* --- Inspecteur ------------------------------------------------------------------------------ */
.inspector {
  position: fixed;
  top: calc(var(--topbar-h) + 2 * var(--gutter));
  right: var(--gutter);
  bottom: var(--gutter);
  z-index: 45;
  width: 350px;
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 16px 18px;
  overflow-y: auto;
  scrollbar-width: none;
  border-radius: var(--r-xl);
  animation: slide-in 0.4s var(--ease);
}
.inspector::-webkit-scrollbar { display: none; }
@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } }
.insp-head { display: flex; align-items: center; gap: 10px; }
.insp-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 16px; letter-spacing: -0.01em; overflow-wrap: anywhere; outline: none; }
.insp-meta { margin: 2px 0 6px; font-size: 12px; color: var(--faint); }
.insp-section { padding: 12px 0 4px; border-top: 1px solid rgba(255, 255, 255, 0.07); }
.insp-section h3 { margin: 0 0 8px; font-size: 11.5px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.insp-section textarea {
  display: block;
  width: 100%;
  min-height: 70px;
  padding: 10px 12px;
  resize: vertical;
  font: 13.5px/1.45 var(--font);
  color: var(--text);
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.insp-section textarea:focus { outline: none; border-color: rgba(124, 196, 255, 0.55); box-shadow: 0 0 0 4px rgba(124, 196, 255, 0.14); }
.insp-section textarea:disabled { opacity: 0.5; }
.row { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.row.wrap { flex-wrap: wrap; }
.fine { margin: 8px 0 0; font-size: 12px; color: var(--faint); }
.fine.warn { color: #ffe2b3; }
.insp-prompt { margin: 0; font-size: 13px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9em; overflow: auto; scrollbar-width: none; }
#refactor-settings { margin-top: 8px; }
.bus-topics { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.bus-topics:empty { display: none; }
.bus-topics li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 12.5px; }
.bus-dir { padding: 1px 7px; font-size: 11px; font-weight: 650; border-radius: 999px; color: #0a0c12; background: var(--info); }
.bus-topics li[data-dir="listens"] .bus-dir { background: #c9a8ff; }
.bus-topics code { font: 12px var(--mono); color: var(--text); overflow-wrap: anywhere; }
.bus-last { flex-basis: 100%; min-width: 0; font: 11.5px var(--mono); color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  position: relative;
  width: 30px; height: 30px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: var(--swatch, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.25s var(--spring), box-shadow 0.2s;
}
.swatch:hover { transform: scale(1.12); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px #0b0d12, 0 0 0 4px var(--swatch, #fff); }
.swatch.is-default { background: conic-gradient(#ff4d5e, #ff9f1c, #ffe14d, #3ddc84, #3aa0ff, #9b5cff, #ff4d5e); }
.swatch.is-default[aria-checked="true"] { box-shadow: 0 0 0 2px #0b0d12, 0 0 0 4px #fff; }
.swatch-custom { display: grid; place-items: center; overflow: hidden; cursor: pointer; background: var(--glass-fill); }
.swatch-custom::after { content: "+"; position: absolute; font-size: 16px; color: var(--muted); pointer-events: none; }
.swatch-custom input { position: absolute; inset: -8px; width: 46px; height: 46px; opacity: 0; cursor: pointer; }

/* --- Toast ------------------------------------------------------------------------------ */
.toast {
  position: fixed;
  top: calc(var(--topbar-h) + 2 * var(--gutter));
  left: 50%;
  translate: -50% 0;
  z-index: 60;
  display: flex; align-items: center; gap: 12px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 9px 10px 9px 16px;
  font-size: 13px;
  border-radius: 999px;
  background: rgba(18, 22, 34, 0.86);
  border: 1px solid var(--line-strong);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  animation: toast-in 0.35s var(--spring);
}
.toast[data-tone="error"] { border-color: rgba(255, 94, 108, 0.55); color: #ffd5d9; }
.toast span { overflow: hidden; text-overflow: ellipsis; }
.toast button { flex: none; padding: 4px 12px; font-size: 12.5px; font-weight: 600; border-radius: 999px; border: 0; color: #0a0c12; background: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(0.96); } }

/* --- Dialogue des réglages ------------------------------------------------------------------ */
.dialog {
  position: fixed; /* .glass impose relative : on rétablit le centrage natif du <dialog> modal */
  inset: 0;
  width: min(500px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-x: hidden;
  overflow-y: auto;
  margin: auto;
  padding: 26px;
  color: var(--text);
  background: linear-gradient(180deg, rgba(34, 38, 54, 0.86), rgba(14, 16, 24, 0.92));
}
.dialog::before { inset: 0; }
.dialog::backdrop { background: rgba(3, 4, 8, 0.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.dialog h2 { margin: 0 0 8px; font-size: 19px; letter-spacing: -0.02em; }
.dialog .hint { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.dialog a { color: var(--info); }
.dialog code { font: 12px var(--mono); padding: 1px 6px; border-radius: 6px; background: var(--glass-fill); border: 1px solid var(--line); }
.field-label { display: block; margin: 16px 0 6px; font-size: 13px; color: var(--muted); }
.dialog input[type="password"],
.dialog input[type="email"],
.dialog input[type="text"] {
  width: 100%;
  padding: 11px 14px;
  font: 14px var(--mono);
  color: var(--text);
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.dialog input[type="password"]:focus,
.dialog input[type="email"]:focus,
.dialog input[type="text"]:focus { outline: none; border-color: rgba(124, 196, 255, 0.55); box-shadow: 0 0 0 4px rgba(124, 196, 255, 0.14); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--info); }
.advanced { margin-top: 14px; font-size: 13px; color: var(--muted); }
.advanced summary { cursor: pointer; }
.dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 24px; flex-wrap: wrap; }

/* --- Compte : anneau de Sparks et menu ----------------------------------------------------- */
.account { display: flex; align-items: center; }
.sparks {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 13px 3px 4px;
  font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--glass-fill);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  transition: border-color 0.2s, background 0.2s;
}
.sparks:hover { border-color: var(--line-strong); background: var(--glass-hover); }
.ring { width: 30px; height: 30px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.5; }
.ring-track { stroke: rgba(255, 255, 255, 0.12); }
.ring-value {
  stroke: url(#ring-grad);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.9s var(--ease), stroke 0.3s;
}
.sparks[data-level="low"] .ring-value { stroke: var(--warn); }
.sparks[data-level="empty"] .ring-value { stroke: var(--err); }
.sparks[data-level="empty"] { border-color: rgba(255, 94, 108, 0.45); }
.sparks-unit { color: var(--muted); font-weight: 500; }
.sparks-delta {
  position: absolute; right: 8px; top: -6px;
  font-size: 12px; font-weight: 750;
  opacity: 0;
  pointer-events: none;
}
.sparks-delta[data-sign="down"] { color: #ffc2ca; }
.sparks-delta[data-sign="up"] { color: var(--ok); }
.sparks-delta.is-shown { animation: delta-float 1.4s var(--ease) both; }
@keyframes delta-float {
  0% { opacity: 0; transform: translateY(8px); }
  20% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-16px); }
}

.account-menu {
  position: fixed; inset: auto; /* popover : positionné sous l'anneau par account-ui.js */
  margin: 0;
  width: 280px;
  padding: 16px;
  overflow: visible; /* le popover natif impose overflow:auto ; le liseré du verre déborde d'1 px */
  color: var(--text);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(34, 38, 54, 0.92), rgba(14, 16, 24, 0.95));
}
.account-menu:popover-open { animation: fade-in 0.22s var(--ease); }
.menu-email { margin: 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.menu-balance { margin: 6px 0 0; font-size: 22px; letter-spacing: -0.02em; }
.account-menu .fine { margin-top: 4px; }
.account-menu .row { margin-top: 14px; }

/* --- Connexion / inscription --------------------------------------------------------------- */
.auth-dialog { width: min(420px, calc(100vw - 32px)); }
.auth-dialog input { font-family: var(--font) !important; }
.auth-hero { margin-bottom: 18px; text-align: center; }
.auth-hero img { filter: drop-shadow(0 10px 28px rgba(58, 160, 255, 0.45)); }
.auth-hero h2 { margin: 10px 0 4px; }
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--well);
  border: 1px solid var(--line);
}
.segmented button {
  padding: 7px 10px;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}
.segmented button[aria-selected="true"] { color: var(--text); background: var(--glass-hover); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.auth-gift,
.auth-error { margin: 14px 0 0; padding: 9px 12px; font-size: 13px; border-radius: var(--r-md); }
.auth-gift {
  color: #eadfff;
  background: linear-gradient(90deg, rgba(124, 196, 255, 0.12), rgba(166, 107, 255, 0.15), rgba(255, 94, 138, 0.1));
  border: 1px solid rgba(166, 107, 255, 0.32);
}
.auth-gift::before { content: "✦ "; }
.auth-error { color: #ffd5d9; background: rgba(255, 94, 108, 0.1); border: 1px solid rgba(255, 94, 108, 0.35); }

/* --- Spotlight (Ctrl/Cmd + K) -------------------------------------------------------------- */
.spot-open { display: inline-flex; align-items: center; gap: 7px; }
.spot-open svg { width: 15px; height: 15px; }
.spotlight {
  position: fixed; inset: 0;
  margin: 14vh auto auto;
  width: min(640px, calc(100vw - 32px));
  max-height: min(560px, 76vh);
  display: flex; flex-direction: column;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, rgba(34, 38, 54, 0.92), rgba(14, 16, 24, 0.95));
}
.spotlight:not([open]) { display: none; }
.spotlight[open] { animation: spot-in 0.22s var(--spring); }
.spotlight::before { inset: 0; }
.spotlight::backdrop { background: rgba(3, 4, 8, 0.45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
@keyframes spot-in { from { opacity: 0; transform: translateY(-10px) scale(0.98); } }
.spot-field { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.spot-field img { flex: none; }
.spot-field input { flex: 1; min-width: 0; font: 500 17px var(--font); color: var(--text); background: transparent; border: 0; outline: none; }
.spot-field input::placeholder { color: var(--faint); }
.spot-list { flex: 1; min-height: 0; margin: 0; padding: 6px; list-style: none; overflow-y: auto; scrollbar-width: thin; }
.spot-list:empty { display: none; }
.spot-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.spot-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; cursor: pointer; }
.spot-item[aria-selected="true"] { background: var(--glass-hover); box-shadow: inset 0 0 0 1px var(--line); }
.spot-icon { flex: none; width: 28px; height: 28px; display: grid; place-items: center; font-size: 14px; border-radius: 9px; background: rgba(255, 255, 255, 0.07); }
.spot-item[data-kind="generate"] .spot-icon { color: #0a0c12; background: var(--spectrum); }
.spot-label { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spot-hint { flex: none; font-size: 12px; color: var(--faint); }
.spot-empty { margin: 18px; color: var(--muted); text-align: center; }
.spot-foot { margin: 0; padding: 9px 16px; font-size: 12px; color: var(--faint); border-top: 1px solid rgba(255, 255, 255, 0.08); }

/* --- Mon Hub ------------------------------------------------------------------------------- */
.account { gap: 8px; }
.hub-open { display: inline-flex; align-items: center; gap: 6px; }
.hub-open svg { width: 15px; height: 15px; }
.hub-dialog { width: min(1040px, calc(100vw - 32px)); height: min(760px, calc(100vh - 32px)); display: flex; flex-direction: column; padding: 22px 22px 16px; }
.hub-dialog:not([open]) { display: none; }
.hub-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.hub-head h2 { margin: 0; }
.hub-head .fine { margin: 2px 0 0; }
.hub-dialog input[type="search"] {
  width: min(280px, 40vw);
  padding: 9px 14px;
  font: 13.5px var(--font);
  color: var(--text);
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.hub-dialog input[type="search"]:focus { outline: none; border-color: rgba(124, 196, 255, 0.55); box-shadow: 0 0 0 4px rgba(124, 196, 255, 0.14); }
.hub-grid {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-content: start; gap: 14px;
  overflow-y: auto;
  padding: 2px 2px 8px;
  scrollbar-width: thin;
}
.hub-item {
  position: relative;
  display: flex; flex-direction: column;
  border-radius: var(--r-lg);
  background: var(--glass-fill);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: border-color 0.2s, transform 0.25s var(--ease), opacity 0.2s;
  content-visibility: auto; /* grande bibliothèque : seules les vignettes visibles sont rendues */
  contain-intrinsic-size: auto 250px;
}
.hub-item:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.hub-item.is-busy { opacity: 0.6; pointer-events: none; }
.hub-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 11;
  padding: 0;
  border: 0;
  background: #0b0d12;
  overflow: hidden;
}
.hub-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.hub-placeholder {
  display: grid; place-items: center;
  width: 100%; height: 100%;
  font-size: 42px; font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  background:
    radial-gradient(90% 80% at 20% 10%, color-mix(in srgb, var(--accent, #7cc4ff) 40%, transparent), transparent 70%),
    radial-gradient(80% 70% at 90% 100%, rgba(166, 107, 255, 0.3), transparent 70%),
    #0b0d12;
}
.hub-badge {
  position: absolute; left: 8px; top: 8px;
  padding: 3px 9px;
  font-size: 11px; font-weight: 650;
  color: #0a0c12;
  border-radius: 999px;
  background: var(--ok);
}
.hub-info { padding: 10px 12px 2px; min-width: 0; }
.hub-title { margin: 0; font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hub-meta { margin: 3px 0 0; font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hub-actions { display: flex; gap: 6px; padding: 10px 12px 12px; }
.hub-actions .tool.is-armed { color: #ffc9ce; border-color: rgba(255, 94, 108, 0.6); background: rgba(255, 94, 108, 0.16); }
.hub-empty { margin: 40px auto; max-width: 420px; text-align: center; color: var(--muted); }
.hub-foot { display: flex; justify-content: center; padding-top: 8px; }
.hub-foot .tool[hidden] { display: none; }
/* Chargement : squelettes de vignettes, même reflet que les cartes. */
.hub-dialog[data-state="loading"] .hub-grid:empty::before,
.hub-dialog[data-state="loading"] .hub-grid:empty::after {
  content: "";
  height: 250px;
  border-radius: var(--r-lg);
  background: linear-gradient(115deg, rgba(124, 196, 255, 0.08), rgba(166, 107, 255, 0.07) 45%, rgba(255, 94, 138, 0.05));
  border: 1px solid var(--line);
  animation: breathe 1.4s ease-in-out infinite;
}

/* --- Prism Pro ----------------------------------------------------------------------------- */
.pro-dialog { width: min(460px, calc(100vw - 32px)); }
.pro-hero { text-align: center; }
.pro-badge {
  display: inline-block;
  padding: 5px 13px;
  font: 800 12px/1 var(--font);
  letter-spacing: 0.16em;
  color: #0a0c12;
  border-radius: 999px;
  background: var(--spectrum);
  box-shadow: 0 8px 26px -8px rgba(166, 107, 255, 0.85);
}
.pro-hero h2 { margin: 14px 0 6px; font-size: 22px; }
.pro-perks { display: grid; gap: 8px; margin: 18px 0 4px; padding: 0; list-style: none; }
.pro-perks li {
  position: relative;
  display: grid; gap: 2px;
  padding: 11px 14px 11px 40px;
  border-radius: var(--r-md);
  background: var(--glass-fill);
  border: 1px solid var(--line);
}
.pro-perks li::before {
  content: "✦";
  position: absolute; left: 15px; top: 10px;
  background: var(--spectrum);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.pro-perks strong { font-size: 14px; }
.pro-perks span { font-size: 12.5px; color: var(--muted); }

/* --- Responsive ------------------------------------------------------------------------------ */
@media (max-width: 1600px) {
  .tagline { display: none; } /* décoratif : la place va aux commandes (compte, mode spatial…) */
}
@media (max-width: 720px) {
  :root { --gutter: 8px; --topbar-h: 52px; }
  .card-count, #zoom-in, #zoom-out, .dock-hint, .sparks-unit, .spot-open-label, #spot-kbd { display: none; }
  .brand-name { font-size: 18px; }
  .engine { padding: 6px 10px; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; }
  .canvas-tools .tool { padding: 6px 8px; }
  .zoom-level { min-width: 0; }
  .inspector {
    top: auto; left: var(--gutter); right: var(--gutter); bottom: var(--gutter);
    width: auto; max-height: 72vh;
    animation-name: sheet-in;
  }
  body.has-inspector .dock { left: 50%; }
  .card-actions { opacity: 1; }
  .card-resize { opacity: 0.8; width: 28px; height: 28px; }
}
@media (max-width: 480px) {
  .brand-name { display: none; }
  .brand-version { display: none; }
  #arrange { display: none; }
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(30px); } }
@media (hover: none) {
  .card-actions { opacity: 1; }
  .card-resize { opacity: 0.8; }
}

/* --- V4 : Engramme cognitif, filtre ADN, zoom fractal, incantation --------------------------- */
.chip-engram {
  border-color: rgba(125, 249, 255, 0.35);
  background: linear-gradient(120deg, rgba(34, 211, 238, 0.14), rgba(168, 85, 247, 0.16));
}

/* Filtre ADN actif (bulle d'un Engramme choisie) : la prochaine demande passe par ce trait. */
.dna {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 10px;
  border: 1px solid rgba(125, 249, 255, 0.35);
  border-radius: var(--r-md);
  background: linear-gradient(120deg, rgba(34, 211, 238, 0.1), rgba(168, 85, 247, 0.1));
  animation: fade-in 0.3s var(--ease);
}
.dna-orb {
  flex: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ecfeff, #22d3ee 55%, #0e7490);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.8);
}
.dna[data-category="core"] .dna-orb { background: radial-gradient(circle at 35% 35%, #fff, #dbeafe 60%, #93c5fd); box-shadow: 0 0 14px rgba(219, 234, 254, 0.9); }
.dna[data-category="shadow"] .dna-orb {
  background: radial-gradient(circle, #0b0512 35%, #a855f7);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.85);
  animation: dna-glitch 2.6s steps(1) infinite;
}
.dna[data-category="artifact"] .dna-orb { width: 12px; height: 12px; margin: 3px; background: radial-gradient(circle at 35% 35%, #fffbeb, #fbbf24); box-shadow: 0 0 12px rgba(251, 191, 36, 0.9); }
@keyframes dna-glitch { 0%, 88%, 100% { translate: 0; filter: none; } 90% { translate: -2px 0; filter: hue-rotate(70deg); } 94% { translate: 2px 0; } }
.dock.has-dna { box-shadow: inset 0 1px 0 var(--highlight), var(--shadow), 0 0 0 1px rgba(125, 249, 255, 0.28), 0 0 44px -12px rgba(34, 211, 238, 0.55); }

/* Carte qui émerge d'un point (zoom fractal, incantation). */
.card.is-emerging { animation: card-emerge 0.6s var(--ease) both; }
@keyframes card-emerge {
  from { opacity: 0; transform: translate(var(--from-dx, 0), var(--from-dy, 0)) scale(0.04); }
  45% { opacity: 1; }
}

/* Zoom fractal : proposition affichée au point du double-clic. */
.fractal {
  position: fixed; left: 0; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 2px;
  padding: 4px;
  border-radius: 999px;
  animation: fractal-in 0.28s var(--spring);
}
.fractal-go {
  display: flex; align-items: center; gap: 8px;
  max-width: 380px;
  padding: 6px 12px 6px 7px;
  font-size: 13px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(124, 196, 255, 0.24), rgba(166, 107, 255, 0.24));
  transition: background 0.2s;
}
.fractal-go:hover { background: linear-gradient(120deg, rgba(124, 196, 255, 0.4), rgba(166, 107, 255, 0.4)); }
.fractal-go strong { display: inline-block; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; font-weight: 600; }
.fractal-icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); }
@keyframes fractal-in { from { opacity: 0; transform: scale(0.6); } }

/* Incantation : orbe d'écoute au pointeur, dont la taille et le halo suivent la voix (--organic). */
.incantation {
  position: fixed; left: 0; top: 0; z-index: 70;
  display: flex; align-items: flex-start; gap: 14px;
  pointer-events: none;
}
.inc-orb {
  position: relative; flex: none;
  width: 54px; height: 54px;
  margin: -27px 0 0 -27px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  pointer-events: auto;
  background: radial-gradient(circle at 35% 30%, #fff, #7cc4ff 45%, #6d28d9 92%);
  box-shadow: 0 0 calc(24px + var(--organic, 0) * 70px) rgba(124, 196, 255, calc(0.45 + var(--organic, 0) * 0.55));
  scale: calc(1 + var(--organic, 0) * 0.5);
  transition: scale 0.08s linear;
}
.inc-orb::before,
.inc-orb::after {
  content: "";
  position: absolute; inset: -10px;
  border-radius: 50%;
  border: 1px solid rgba(124, 196, 255, 0.55);
  animation: inc-ring 1.6s var(--ease) infinite;
}
.inc-orb::after { animation-delay: 0.8s; }
@keyframes inc-ring { from { transform: scale(0.8); opacity: 0.9; } to { transform: scale(1.9); opacity: 0; } }
.inc-text {
  margin: -24px 0 0;
  max-width: min(420px, 60vw);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 14px; line-height: 1.4;
}
.inc-text.is-placeholder { color: var(--muted); font-style: italic; }

/* Paramètres (roue dentée) : compte, mes écrits, moteur, à propos. */
.btn-try { border-color: rgba(125, 249, 255, 0.4); background: linear-gradient(120deg, rgba(34, 211, 238, 0.14), rgba(166, 107, 255, 0.14)); }
.prefs-open svg { width: 18px; height: 18px; transition: rotate 0.5s var(--ease); }
.prefs-open:hover svg { rotate: 60deg; }
.prefs-dialog { width: min(560px, calc(100vw - 2 * var(--gutter))); }
.prefs-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.prefs-head h2 { margin: 0; }
.prefs-tabs { margin-bottom: 12px; }
.prefs-body { display: flex; flex-direction: column; gap: 8px; max-height: min(60vh, 520px); overflow-y: auto; scrollbar-width: thin; }
.prefs-fact { display: flex; justify-content: space-between; gap: 12px; margin: 0; padding: 7px 0; border-bottom: 1px solid var(--line); }
.prefs-label { color: var(--muted); }
.prefs-fact strong { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.prefs-sub { margin: 8px 0 0; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.prefs-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.prefs-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--glass-fill);
}
.prefs-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.prefs-item-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prefs-item-text span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prefs-links { display: flex; gap: 14px; margin: 6px 0 0; }
.prefs-links a { color: var(--info); }

/* « Discuter avec … » : panneau de conversation (même place que l'inspecteur, l'un ou l'autre). */
.chat {
  position: fixed;
  top: calc(var(--topbar-h) + 2 * var(--gutter));
  right: var(--gutter);
  bottom: var(--gutter);
  z-index: 45;
  width: 380px;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px;
  border-radius: var(--r-xl);
  animation: slide-in 0.4s var(--ease);
}
body.has-chat .dock { left: calc((100vw - 400px) / 2); }
.chat-head { display: flex; align-items: center; gap: 10px; }
.chat-orb {
  flex: none;
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  font-weight: 700; color: #1b1030;
  background: radial-gradient(circle at 35% 30%, #fff, #fbcfe8 45%, #fb7185 80%);
  box-shadow: 0 0 18px rgba(251, 113, 133, 0.6);
  animation: heartbeat 1.6s ease-in-out infinite;
}
@keyframes heartbeat { 0%, 40%, 100% { scale: 1; } 10% { scale: 1.08; } 25% { scale: 1.04; } }
.chat-who { flex: 1; min-width: 0; }
.chat-who h2 { margin: 0; font-size: 16px; }
.chat-who .fine { margin: 2px 0 0; }
.chat-log {
  flex: 1; min-height: 0;
  margin: 0; padding: 4px 2px;
  list-style: none;
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; scrollbar-width: thin;
}
.msg { max-width: 92%; }
.msg-text { margin: 0; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; font-size: 13.5px; line-height: 1.45; }
.msg-user { align-self: flex-end; }
.msg-user .msg-text { background: rgba(124, 196, 255, 0.18); border: 1px solid rgba(124, 196, 255, 0.3); border-bottom-right-radius: 4px; }
.msg-persona .msg-text { background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-trace { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.msg-trace button {
  display: flex; align-items: flex-start; gap: 7px;
  width: 100%;
  padding: 3px 6px;
  text-align: left; font-size: 11.5px; color: var(--muted);
  background: transparent; border: 0; border-radius: 8px;
}
.msg-trace button:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.trace-round {
  flex: none;
  display: grid; place-items: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  font: 700 10px/1 var(--font); color: #2a1a00;
  background: radial-gradient(circle at 35% 30%, #fff7e0, #f5b544);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--round) 70%, transparent), 0 0 10px color-mix(in srgb, var(--round) 60%, transparent);
}
.trace-text strong { color: var(--text); font-weight: 600; }
.msg.is-pending .dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: breathe 1s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; }
.chat-form textarea {
  flex: 1; min-width: 0;
  resize: none;
  padding: 9px 11px;
  font: 13.5px/1.4 var(--font); color: var(--text);
  background: var(--well); border: 1px solid var(--line); border-radius: var(--r-md);
  outline: none;
}
.chat-form textarea:focus { border-color: rgba(124, 196, 255, 0.5); }
@media (max-width: 720px) {
  .chat { left: var(--gutter); width: auto; top: auto; height: min(70vh, 560px); }
}

/* Mon Hub : les personnes (Engrammes) en tête. */
.hub-people { margin: 0 0 14px; }
.hub-people h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.hub-people-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.hub-person {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(251, 113, 133, 0.28);
  border-radius: var(--r-md);
  background: linear-gradient(120deg, rgba(251, 113, 133, 0.1), rgba(34, 211, 238, 0.08));
}
.hub-person.is-busy { opacity: 0.6; pointer-events: none; }
.hub-person-orb {
  flex: none;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  font-weight: 700; color: #1b1030;
  background: radial-gradient(circle at 35% 30%, #fff, #dbeafe 50%, #93c5fd);
  box-shadow: 0 0 14px rgba(219, 234, 254, 0.6);
}
.hub-person-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.hub-person-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hub-person-info span { font-size: 11.5px; color: var(--muted); }
.hub-person-chat { border-color: rgba(251, 113, 133, 0.45); }

/* Verre organique : pendant l'incantation, la voix module le flou et la saturation du verre. */
body.is-incanting .glass {
  -webkit-backdrop-filter: blur(calc(28px + var(--organic, 0) * 40px)) saturate(calc(175% + var(--organic, 0) * 160%));
  backdrop-filter: blur(calc(28px + var(--organic, 0) * 40px)) saturate(calc(175% + var(--organic, 0) * 160%));
  border-color: rgba(124, 196, 255, calc(0.12 + var(--organic, 0) * 0.55));
}

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

/* ==========================================================================
   V5 · Écosystème vivant
   ========================================================================== */
/* Sédimentation : la carte s'efface pendant que ses particules (toile .shatter) s'enfoncent dans le fond. */
.card.is-dissolving { opacity: 0; transition: opacity 0.25s ease; pointer-events: none; }
.shatter { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }
.sediment {
  position: absolute; width: 150px; height: 150px; margin: -75px 0 0 -75px; border-radius: 50%; pointer-events: none; z-index: 0;
  opacity: calc(0.25 + 0.55 * var(--wear, 1));
  background:
    radial-gradient(circle at 50% 50%, rgba(180, 200, 230, 0.2) 0 3px, transparent 4px),
    radial-gradient(circle at 34% 58%, rgba(124, 196, 255, 0.28) 0 2px, transparent 3px),
    radial-gradient(circle at 63% 38%, rgba(255, 255, 255, 0.22) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 58% 66%, rgba(155, 92, 255, 0.24) 0 2px, transparent 3px),
    radial-gradient(circle, rgba(124, 196, 255, 0.1), transparent 68%);
}
.sediment.is-fresh { animation: sediment-settle 1.4s var(--ease); }
@keyframes sediment-settle { from { transform: scale(1.6); filter: brightness(2.2); } to { transform: none; filter: none; } }
.insp-ghost { color: #d9c6ff; }

/* Darwinisme d'interface : pastille « Simplifier ? » posée sur le widget où le pointeur tourne en rond. */
.card-evolve {
  position: absolute; right: 10px; bottom: 10px; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: 6px 6px 6px 12px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--glass-solid); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow); font-size: 12.5px; animation: evolve-in 0.35s var(--spring);
}
.card-evolve button { border: 0; border-radius: 999px; font: inherit; cursor: pointer; }
.card-evolve-go { padding: 5px 11px; background: var(--text); color: var(--bg); font-weight: 600; }
.card-evolve-no { width: 26px; height: 26px; background: var(--glass-fill); color: var(--text); }
.card-evolve button:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
@keyframes evolve-in { from { opacity: 0; transform: translateY(8px) scale(0.96); } }
.prefs-toggle { align-items: flex-start; line-height: 1.4; }
.prefs-toggle input { margin-top: 2px; flex: none; }
@media (prefers-reduced-motion: reduce) { .sediment.is-fresh, .card-evolve { animation: none; } }

/* V5 · Mode spatial : perspective sur le canvas, cartes disposées en arc (inclinées vers vous, en profondeur).
   L'arc de chaque carte (--arc) est calculé selon sa place à l'écran (js/spatial.js). */
body.is-spatial .workspace { perspective: 1800px; perspective-origin: 50% 42%; }
body.is-spatial .world { transform-style: preserve-3d; }
body.is-spatial .card { transform: var(--arc, none); transition: transform 0.5s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s; }
body.is-spatial .card:hover { transform: var(--arc, none) translateZ(24px); }
body.is-spatial .links { opacity: 0.55; }
.tool.is-on { color: var(--text); border-color: var(--line-strong); background: var(--glass-hover); }
/* Réalité mixte (WebXR, superposition DOM) : la pièce apparaît derrière le verre. */
body.is-xr, body.is-xr .workspace { background: transparent !important; }
body.is-xr .aurora, body.is-xr .topbar-glow { display: none; }
@media (prefers-reduced-motion: reduce) { body.is-spatial .card { transition: none; } }
#spatial svg { width: 17px; height: 17px; vertical-align: middle; }
