/* =====================================================================
   Portrait / Mosaik — feuille de style.

   Langage visuel repris du prototype de reference : IBM Plex Sans pour
   l'interface, IBM Plex Mono pour les mesures, Newsreader pour les titres
   editoriaux. Tokens bg / bg2 / bg3, line / line2, text / dim / faint,
   accent / gold / slate — injectes par theme.ts depuis la palette choisie
   par Q(P_k, i).

   Les trois couleurs de sens portent la semantique du graphe :
   accent = projet, gold = sujet, slate = relation et vie.
   ===================================================================== */

:root {
  /* Repli avant que theme.ts n'injecte la palette : declinaison A, creme.
     bg = #F2CDA0 exactement — le sable clair reste LE fond, pas une pale
     approximation de lui-meme. bg2/bg3 sont plus CLAIRS que ce canevas
     (cartes qui attrapent la lumiere), pas plus sombres — voir palette.ts.
     Valeurs alignees sur palette.ts. */
  --bg: #F2CDA0; --bg2: #F8E6D0; --bg3: #FBEFE1;
  --line: rgba(2,89,89,.12); --line2: rgba(2,89,89,.22);
  --text: #025959; --dim: rgba(2,89,89,.66); --faint: rgba(2,89,89,.42);
  --accent: #025959; --gold: #BF9673; --gold-ink: #6E4A29; --slate: #468C73;

  --sans: "IBM Plex Sans", ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;

  --sidebar: 232px;
  --drawer: 372px;
  --r: 12px;
  --r-sm: 8px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 400ms ease, color 400ms ease;
}

button {
  font: inherit; color: inherit; cursor: pointer;
  background: transparent; border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 6px 10px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}
button:hover { border-color: var(--line2); background: var(--bg2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
button.ghost { background: transparent; }
button.icon { border: none; font-size: 15px; color: var(--dim); padding: 4px 7px; }

input, textarea, select { font: inherit; color: inherit; }
input[type="search"], input[type="text"], textarea {
  width: 100%; padding: 7px 11px;
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 999px; color: var(--text);
}
textarea { border-radius: var(--r); }
input::placeholder { color: var(--faint); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mono { font-family: var(--mono); font-size: 11px; letter-spacing: .01em; color: var(--faint); }

/* ------------------------------------------------------------- Shell */

.app { display: grid; grid-template-columns: var(--sidebar) 1fr auto; height: 100vh; overflow: hidden; }

.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 12px 12px;
}

.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 20px; }
.brand .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.brand-name { font-weight: 600; letter-spacing: -.01em; }
.badge {
  margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--faint);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px;
}

nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  border: none; border-radius: var(--r-sm); padding: 8px 10px;
  color: var(--dim); text-align: left;
}
.nav-item em { font-family: var(--mono); font-style: normal; font-size: 11px; color: var(--faint); }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--bg3); color: var(--text); font-weight: 500; }
.nav-item.active span::before {
  content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); margin-right: 8px; vertical-align: middle;
}
.nav-item:not(.active) span { padding-left: 13px; }

.sidebar-foot {
  margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.me { display: flex; align-items: center; gap: 9px; min-width: 0; }
.me-pet { width: 34px; height: 34px; flex: none; }
.me-name { font-size: 13px; font-weight: 500; }
.me-sub { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.sidebar-foot .icon { margin-left: auto; }

/* ------------------------------------------------------------ Topbar */

.stage { position: relative; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.titles { min-width: 0; }
.titles h1 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.titles p { margin: 1px 0 0; font-size: 12px; color: var(--faint); }
.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search { width: 190px; font-size: 12.5px; }

.segmented { display: flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--bg2); }
.seg {
  border: none; border-radius: 999px; padding: 4px 11px;
  font-size: 12px; color: var(--dim); background: transparent;
}
.seg:hover { background: var(--bg3); }
.seg.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.palettes .seg { font-family: var(--mono); width: 28px; padding: 4px 0; text-align: center; }
.zoom .seg { font-family: var(--mono); }

/* --topbar-h est mesuree en JS : la barre change de hauteur quand elle se replie. */
.view { position: absolute; inset: var(--topbar-h, 62px) 0 0 0; display: none; }
.view.active { display: block; }
.view.scroll { overflow-y: auto; }
.page { padding: 26px 30px 70px; max-width: 880px; }

.time-banner {
  position: absolute; top: calc(var(--topbar-h, 62px) + 14px); left: 50%;
  transform: translateX(-50%); z-index: 6;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 6px 5px 14px; font-size: 12px; display: flex; gap: 8px; align-items: center;
}
.time-banner button { padding: 2px 9px; font-size: 11.5px; }

/* ------------------------------------------------------------- Graphe */

.graph-host { position: absolute; inset: 0; }
.graph-svg { width: 100%; height: 100%; cursor: grab; touch-action: none; display: block; }
.graph-svg.panning { cursor: grabbing; }

/* Liens : courbe de Bezier, epaisseur et opacite issues de W_uv. */
.edge { fill: none; stroke: var(--slate); stroke-linecap: round; transition: opacity 260ms ease; }
.edge.cat-projet { stroke: var(--accent); }
.edge.cat-sujet { stroke: var(--gold); }
.edge.cat-vie { stroke: var(--slate); }
.edge.dim { opacity: .06 !important; }

/* Impulsion : T_uv = T_max - W(T_max - T_min). pathLength=100 normalise le trajet. */
.edge-pulse {
  fill: none; stroke-linecap: round; stroke-dasharray: 1.6 98.4;
  animation-name: flow; animation-timing-function: linear; animation-iteration-count: infinite;
}
.edge-pulse.cat-projet { stroke: var(--accent); }
.edge-pulse.cat-sujet { stroke: var(--gold); }
.edge-pulse.cat-vie { stroke: var(--slate); }
.edge-pulse.dim { opacity: 0 !important; }
@keyframes flow { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }

.node { cursor: pointer; }
/* Contour a 1 px, comme la reference : au-dela le graphe devient un dessin
   au feutre. L'epaisseur ne code rien — c'est la taille qui porte S_v. */
.node-disc { stroke-width: 1; transition: stroke-width 180ms ease; }
.node:hover .node-disc, .node.focus .node-disc { stroke-width: 1.8; }
.node.dim { opacity: .22; }
.node-glow { pointer-events: none; }

/* Facette privee : liseré discret, visible du seul proprietaire. */
.node-private { fill: none; stroke: var(--faint); stroke-dasharray: 1 5; }
.node[data-status="suggere"] .node-disc { stroke-dasharray: 5 4; }
.node[data-status="masque"] { opacity: .35; }

/* Bloc de libelle : 160 x 46, tailles fixes relevees sur la reference
   (Plex Sans 13,5/500 et Plex Mono 9,5/500 en --faint). */
.node-label {
  font-family: var(--sans); text-align: center; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
}
.node-title {
  font-size: 13.5px; font-weight: 500; line-height: 1.15;
  color: var(--text); letter-spacing: -.005em;
}
.node-qualifier {
  font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  color: var(--faint); margin-top: 2px;
}

.pet-glow, .pet-disc { pointer-events: none; }
.pet-name { font-family: var(--mono); font-size: 9.5px; fill: var(--faint); text-anchor: middle; letter-spacing: .08em; }

/* Mascotte — section 21. Transitions rares et lentes. */
.pet-body { fill: var(--accent); fill-opacity: .92; }
.pet-eye { fill: var(--bg); }
.pet-ring { stroke: var(--accent); stroke-opacity: 0; stroke-width: 1.6; }
.pet-zzz { fill: var(--faint); font-family: var(--mono); font-size: 10px; opacity: 0; }
.pet { animation: breathe 7s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.pet[data-state="blink"] .pet-eye { ry: .4; }
.pet[data-state="curious"] { animation: lean 1.5s ease-in-out; }
.pet[data-state="celebrate"] { animation: hop .75s ease-in-out 2; }
.pet[data-state="celebrate"] .pet-ring { animation: ripple 1.2s ease-out 2; }
.pet[data-state="new-node"] .pet-ring { animation: ripple 1.7s ease-out; }
.pet[data-state="sleep"] .pet-eye { ry: .35; }
.pet[data-state="sleep"] .pet-zzz { opacity: .75; animation: drift 3.4s ease-in-out infinite; }

@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.03); } }
@keyframes lean { 0%,100% { transform: rotate(0); } 40% { transform: rotate(-6deg); } }
@keyframes hop { 0%,100% { transform: translateY(0); } 45% { transform: translateY(-8px); } }
@keyframes ripple { from { r: 30; stroke-opacity: .5; } to { r: 72; stroke-opacity: 0; } }
@keyframes drift { 0%,100% { transform: translateY(0); opacity: .75; } 50% { transform: translateY(-5px); opacity: .3; } }

/* Pied de canvas : filtres a gauche, legende a droite. */
.canvas-foot {
  /* La marge droite laisse la place au bouton de l'assistant. */
  position: absolute; left: 16px; right: 76px; bottom: 14px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 14px;
  pointer-events: none;
}
.canvas-foot > * { pointer-events: auto; }

.filters {
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 6px 12px; font-size: 12px; max-width: 260px;
}
.filters summary { cursor: pointer; color: var(--dim); font-family: var(--mono); font-size: 11px; }
.filters[open] { padding-bottom: 12px; }
.filters .range { display: block; margin: 10px 0 6px; color: var(--dim); }
.filters .range b { font-family: var(--mono); color: var(--text); }
.filters input[type="range"] { width: 100%; accent-color: var(--accent); }
.filters .types { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; color: var(--dim); }
.filters .types label, .filters .switch { display: flex; align-items: center; gap: 5px; }
.filters .switch { margin-top: 8px; color: var(--dim); }
.filters input[type="checkbox"] { accent-color: var(--accent); }

.legend {
  display: flex; align-items: center; gap: 14px; font-size: 11.5px; color: var(--dim);
  background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px;
}
.legend span { display: flex; align-items: center; gap: 6px; }
.legend .d { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.legend .d.accent { background: var(--accent); }
.legend .d.gold { background: var(--gold); }
.legend .d.slate { background: var(--slate); }

.board-tools { display: flex; align-items: center; gap: 8px; }
#board-energy { gap: 12px; }
#board-energy .readout-row { gap: 5px; }
.proposal { display: none; align-items: center; gap: 8px; font-size: 11.5px; color: var(--dim); }
.proposal.visible { display: flex; }

/* --------------------------------------------------------- Whiteboard */

.board-host {
  position: absolute; inset: 0; overflow: hidden; cursor: grab;
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 24px 24px;
}
.board-host.panning { cursor: grabbing; }
.board-canvas { position: absolute; inset: 0; transform-origin: 0 0; }
.world-canvas { position: absolute; width: 1800px; height: 1100px; transform-origin: 0 0; }
.world-continent { position: absolute; margin: 0; font-family: var(--serif); font-size: 24px; font-weight: 300; color: var(--faint); text-transform: capitalize; }
.world-item { position: absolute; box-sizing: border-box; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); padding: 16px; cursor: grab; box-shadow: 0 8px 24px rgba(0,0,0,.07); overflow: hidden; }
.world-item.selected { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.world-item.pinned::after { content: '◆'; position: absolute; right: 9px; top: 7px; color: var(--gold-ink); font-size: 9px; }
.world-item.role-anchor { border-color: var(--accent); }
.world-item.role-surprise { border-style: dashed; }
.world-item h3 { margin: 7px 0 5px; font-family: var(--serif); font-size: 20px; font-weight: 400; }
.world-item p { margin: 0; color: var(--dim); font-family: var(--mono); font-size: 11px; }
.world-item.type-quote { background: color-mix(in srgb, var(--gold) 9%, var(--bg2)); border-color: color-mix(in srgb, var(--gold) 50%, var(--line)); }
.world-item.type-quote h3 { display: none; }
.world-item.type-quote p { margin-top: 18px; color: var(--ink); font: italic 18px/1.35 var(--serif); }
.world-item.type-quote cite { display: block; margin-top: 12px; color: var(--dim); font: 9px var(--mono); }
.world-meta { font-family: var(--mono); font-size: 8px; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }
.world-art { height: 120px; margin: -16px -16px 13px; background: radial-gradient(circle at 28% 35%, hsl(var(--seed) 32% 70%), transparent 30%), linear-gradient(135deg, hsl(var(--seed) 22% 26%), hsl(calc(var(--seed) + 45) 28% 67%)); position: relative; }
.world-art::before { content: ''; position: absolute; inset: 16%; border: 1px solid rgba(255,255,255,.5); transform: rotate(-7deg); }
.world-art.has-image::before { display: none; }
.world-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.world-art span, .world-art a { position: absolute; bottom: 7px; right: 9px; max-width: calc(100% - 18px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: white; background: rgba(0,0,0,.48); padding: 3px 5px; border-radius: 3px; font: 8px var(--mono); text-transform: uppercase; }
.world-resize { position: absolute; right: 7px; bottom: 5px; padding: 2px; border: 0; color: var(--faint); }
.world-timeline { display: flex; gap: 4px; }
.world-timeline button { padding: 4px 8px; font: 10px var(--mono); }
.world-timeline button.active { background: var(--accent); color: var(--bg); }
.world-explanation { max-width: 48ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); font-size: 10px; }
.world-ab-open { padding: 5px 10px; font: 10px var(--mono); border-color: var(--accent); }
.world-onboarding-open { padding: 5px 10px; font: 10px var(--mono); border-color: var(--gold); }
.world-onboarding-modal { position: fixed; inset: 0; z-index: 1100; display: grid; place-items: center; padding: 24px; background: rgba(1,35,35,.78); }
.world-onboarding-modal[hidden] { display: none; }
.world-onboarding-card { position: relative; width: min(760px, calc(100vw - 48px)); box-sizing: border-box; padding: 30px; border-radius: 18px; background: var(--bg); box-shadow: 0 24px 80px rgba(0,0,0,.4); }
.world-onboarding-card h2 { margin: 8px 0 20px; font: 34px var(--serif); }
.world-onboarding-card > p { color: var(--dim); font-size: 12px; }
.world-onboarding-close { position: absolute; right: 18px; top: 14px; border: 0; font-size: 24px; }
.world-onboarding-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.world-onboarding-pair button { display: grid; grid-template-columns: auto 1fr; gap: 8px; min-height: 230px; padding: 18px; text-align: left; background: var(--bg2); }
.world-onboarding-pair button:hover { border-color: var(--accent); transform: translateY(-2px); }
.world-onboarding-pair strong { font: 22px var(--serif); }
.world-onboarding-pair i { grid-column: 1 / -1; display: block; height: 130px; border-radius: 8px; background: linear-gradient(145deg, var(--accent), var(--bg2) 58%), repeating-linear-gradient(90deg, transparent 0 35px, var(--line) 35px 36px); }
.world-onboarding-pair .preview-b { background: radial-gradient(circle at 20% 30%, var(--gold) 0 14%, transparent 15%), radial-gradient(circle at 70% 65%, var(--slate) 0 19%, transparent 20%), var(--bg); }
.world-onboarding-card.done { text-align: center; }
@media (max-width: 650px) { .world-onboarding-pair { grid-template-columns: 1fr; } }
.world-ab-modal { position: fixed; inset: 0; z-index: 1000; padding: 24px; background: rgba(1,35,35,.72); overflow: auto; }
.world-ab-modal[hidden] { display: none; }
.world-ab-card { width: min(1040px, calc(100vw - 48px)); margin: auto; box-sizing: border-box; padding: 24px; border-radius: 18px; background: var(--bg); color: var(--ink); box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.world-ab-card > header { display: flex; justify-content: space-between; gap: 20px; }
.world-ab-card h2 { margin: 3px 0; font-family: var(--serif); font-size: 30px; font-weight: 400; }
.world-ab-card header p { margin: 3px 0; color: var(--dim); }
.world-ab-close { align-self: flex-start; border: 0; font-size: 24px; }
.world-ab-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 20px 0 14px; }
.world-ab-variant h3 { margin: 0 0 7px; text-align: center; font: 24px var(--serif); }
.world-ab-preview { position: relative; aspect-ratio: 18 / 11; overflow: hidden; border: 1px solid var(--line2); border-radius: 12px; background: var(--bg2) radial-gradient(var(--line) 1px, transparent 1px); background-size: 8px 8px; }
.world-ab-mini { position: absolute; box-sizing: border-box; overflow: hidden; border: 1px solid var(--line2); border-radius: 4px; background: var(--bg); background-size: cover; background-position: center; }
.world-ab-mini span { position: absolute; inset: auto 3px 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 5px var(--mono); color: var(--ink); background: color-mix(in srgb, var(--bg) 82%, transparent); }
.world-ab-mini.has-image span { color: white; background: rgba(0,0,0,.55); }
.world-ab-choices { display: flex; justify-content: center; gap: 8px; }
.world-ab-choices button { min-width: 120px; }
.world-ab-choices button.active { color: var(--bg); background: var(--accent); }
.world-ab-ratings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; margin: 18px 0; }
.world-ab-ratings label { display: grid; grid-template-columns: 1fr 150px; align-items: center; gap: 8px; font-size: 12px; }
.world-ab-ratings small { grid-column: 2; color: var(--faint); font: 8px var(--mono); }
.world-ab-card > footer { display: flex; align-items: center; gap: 8px; }
.world-ab-status { margin-right: auto; color: var(--dim); font: 10px var(--mono); }
@media (max-width: 760px) { .world-ab-pair, .world-ab-ratings { grid-template-columns: 1fr; } .world-ab-ratings label { grid-template-columns: 1fr 120px; } }
.board-links { position: absolute; inset: 0; width: 2400px; height: 1600px; pointer-events: none; overflow: visible; }
.board-link { fill: none; stroke: var(--slate); stroke-linecap: round; }
.board-label-layer { position: absolute; inset: 0; width: 2400px; height: 1600px; pointer-events: none; }

/* Repere de colonne : discret, jamais une grille qui contraint le placement. */
.board-column-head {
  position: absolute; top: 12px;
  font-family: var(--serif); font-weight: 300; font-size: 15px;
  letter-spacing: -0.15px; color: var(--faint);
}

.board-item { position: absolute; cursor: grab; }
.board-item:active { cursor: grabbing; }

/* Famille « carte » : fond bg2, coin arrondi, ombre douce — ce qui se range. */
.board-item.is-boxed {
  background: var(--bg2); border-radius: var(--r);
  padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.09);
}
/* Famille « texte libre » : pas de cadre — ce qui se formule. */
.board-item.is-free { background: transparent; padding: 2px 0 6px; }

.board-pin {
  position: absolute; top: -6px; right: -6px; width: 15px; height: 15px;
  border-radius: 50%; border: 2px solid var(--bg); box-shadow: 0 1px 3px rgba(0,0,0,.25);
  background: var(--gold);
}
.board-pin.privacy-prive { background: var(--gold-ink); }
.board-pin.privacy-sur_demande { background: var(--slate); }
.board-pin.privacy-equipe { background: var(--accent); opacity: .55; }
.board-pin.privacy-organisation { opacity: 0; }

.board-resize {
  position: absolute; right: -3px; bottom: -3px; width: 14px; height: 14px;
  border-right: 2px solid var(--line2); border-bottom: 2px solid var(--line2);
  border-bottom-right-radius: 9px; opacity: .35; cursor: nwse-resize;
}

.board-body { white-space: pre-wrap; font-size: 13px; line-height: 1.45; }
.board-body[contenteditable="true"] { outline: 2px solid var(--accent); border-radius: 5px; }
.mapping.none, .mapping.contredit_par { color: var(--gold-ink); }

.board-ghost {
  position: absolute; border: 1px dashed var(--accent); border-radius: var(--r);
  background: color-mix(in srgb, var(--accent) 7%, transparent); pointer-events: none;
}

/* Etiquette manuscrite sur les connecteurs — Caveat, comme une annotation au crayon. */
.board-connector-label {
  position: absolute; pointer-events: none; white-space: nowrap;
  font-family: "Caveat", cursive; font-size: 18px; line-height: 1;
  padding: 2px 8px 3px; border-radius: 11px;
  background: var(--bg); color: var(--slate); opacity: .92;
}

/* ---- texte libre : intention, citation ---- */

.free-eyebrow, .card-eyebrow {
  font-family: var(--mono); font-size: 9px; letter-spacing: .11em;
  color: var(--faint); margin-bottom: 12px;
}
.card-eyebrow.inline { margin-bottom: 0; }
.free-wrap .board-body {
  font-family: var(--serif); font-weight: 200; font-size: 27px; line-height: 1.28;
  letter-spacing: -.012em; color: var(--text);
}
.type-citation .free-quote .board-body {
  font-style: italic; font-size: 30px; line-height: 1.16; letter-spacing: -.02em;
}
.free-quote-foot {
  display: flex; align-items: center; gap: 10px; margin-top: 16px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .07em;
  text-transform: uppercase; color: var(--faint);
}
.free-quote-foot .rule { width: 26px; height: 1px; background: var(--gold); display: inline-block; }
.free-wrap footer, .card-body-wrap footer { margin-top: 10px; }

/* ---- cartes : titre commun ---- */

.card-title { font-size: 12px; font-weight: 600; margin-bottom: 10px; }
.card-title.inline { margin-bottom: 0; }
.card-desc { font-size: 12.5px; color: var(--dim); line-height: 1.5; margin: 10px 0 0; }

/* ---- liste ---- */
.card-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.card-list li {
  font-size: 12.5px; color: var(--dim); padding-left: 13px; position: relative; line-height: 1.4;
}
.card-list li::before {
  content: '–'; position: absolute; left: 0; color: var(--faint);
}

/* ---- valeurs : bulles ---- */
.value-bubbles { display: flex; flex-wrap: wrap; gap: 10px; }
.value-bubble {
  width: 72px; height: 72px; border-radius: 50%; border: 1px solid var(--line2);
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 11.5px; color: var(--dim); padding: 6px; line-height: 1.2;
}

/* ---- rituel : pilules ---- */
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { padding: 4px 9px; border: 1px solid var(--line); border-radius: 20px; font-size: 11px; color: var(--dim); }

/* ---- projet : point + pourcentage + barre fine ---- */
.project-row { display: flex; align-items: center; gap: 8px; }
.project-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.project-pct { margin-left: auto; font-family: var(--mono); font-size: 9px; color: var(--faint); }
.thin-track { height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 7px; }
.thin-fill { height: 100%; background: var(--accent); }

/* ---- chart : saillance en direct ---- */
.chart-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.chart-head .card-eyebrow.inline { margin-left: auto; white-space: nowrap; }
.chart-row-label { display: flex; font-size: 11.5px; color: var(--dim); margin-bottom: 5px; }
.mono-faint { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--faint); }
.chart-track { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.chart-fill { height: 100%; background: var(--accent); border-radius: 3px; }

/* ---- collaborations : avatars ---- */
.collab-list { display: flex; flex-direction: column; gap: 10px; }
.collab-row { display: flex; align-items: center; gap: 10px; }
.collab-avatar {
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line2);
  background: var(--bg3); display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--dim); flex: none;
}
.collab-name { font-size: 12px; }
.collab-role { font-size: 10.5px; color: var(--faint); }

/* ---- image / souvenir : texture generative ---- */
.art-frame { position: relative; }
.art-canvas { width: 100%; height: 190px; display: block; border-radius: 7px; border: 1px solid var(--line); }
.art-caption {
  position: absolute; left: 12px; bottom: 12px; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: .06em; color: var(--bg); background: rgba(0,0,0,.32);
  padding: 3px 7px; border-radius: 4px;
}

/* ------------------------------------------------------------ Pages */

.panel { border-bottom: 1px solid var(--line); padding: 0 0 26px; margin-bottom: 26px; }
.panel:last-child { border-bottom: none; }
.panel h2 { margin: 0 0 3px; font-family: var(--serif); font-size: 21px; font-weight: 400; letter-spacing: -.01em; }
.eyebrow { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin: 0 0 10px; }
.hint { color: var(--faint); font-size: 12.5px; margin: 4px 0 16px; max-width: 62ch; }
.empty { color: var(--faint); font-style: italic; }

.chip {
  display: inline-block; font-family: var(--mono); font-size: 10px; padding: 2px 8px;
  border-radius: 999px; border: 1px solid var(--line); color: var(--dim);
}
.chip.ok { border-color: var(--accent); color: var(--accent); }
.chip.warn { border-color: var(--gold); color: var(--gold-ink); }
.chip.type { border-color: var(--line2); }
.chip.privacy.prive { border-color: var(--gold); color: var(--gold-ink); }
.chip.facet.apercu { border-style: dashed; }
.chip.facet.sur_demande { border-style: dotted; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }

/* Timeline */
.timeline { display: flex; gap: 6px; align-items: flex-end; }
.tl-col { flex: 1; display: flex; flex-direction: column; gap: 8px; align-items: center; border: none; padding: 8px 4px; border-radius: var(--r-sm); }
.tl-col:hover { background: var(--bg2); }
.tl-col.active { background: var(--bg3); }
.tl-col span { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.tl-bars { display: flex; gap: 2px; align-items: flex-end; height: 92px; }
.tl-bars .bar { width: 4px; background: var(--accent); opacity: .6; border-radius: 2px 2px 0 0; }
.tl-col.reset { flex: 0 0 auto; }

.delta-summary { display: flex; gap: 16px; flex-wrap: wrap; font-family: var(--mono); font-size: 11px; color: var(--faint); margin-bottom: 14px; }
.delta-summary b { color: var(--text); }

.cmp-row { display: grid; grid-template-columns: 190px 1fr 58px; gap: 12px; align-items: center; padding: 3px 0; font-size: 13px; }
.cmp-label em { font-family: var(--mono); font-style: normal; font-size: 9.5px; color: var(--gold-ink); }
.cmp-track { position: relative; height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.cmp-track i { position: absolute; top: 0; height: 100%; border-radius: 3px; }
.cmp-track .before { background: var(--faint); }
.cmp-track .after { background: var(--accent); }
.cmp-row b { font-family: var(--mono); font-size: 11px; text-align: right; color: var(--dim); }
.cmp-row.up b { color: var(--accent); }

.transformation { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 10px; background: var(--bg2); }
.transformation.persistent { border-color: var(--line2); }
.transformation header { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.transformation p { font-family: var(--serif); font-size: 16px; font-weight: 300; line-height: 1.45; margin: 0 0 10px; }
.transformation .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.transformation .actions button { font-size: 11.5px; padding: 4px 10px; }
.transformation .verdict { font-family: var(--sans); font-size: 12px; color: var(--accent); }

/* Recommandations */
.reco { border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin-bottom: 12px; background: var(--bg2); }
.reco header { display: flex; align-items: baseline; gap: 9px; margin-bottom: 8px; }
.reco h3 { margin: 0; font-size: 15px; font-weight: 600; }
.reco .role { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.reco .why { font-family: var(--serif); font-size: 16px; font-weight: 300; line-height: 1.5; margin: 0 0 8px; }
.reco .path { font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin: 0 0 10px; }
.reco details summary { font-family: var(--mono); font-size: 10.5px; color: var(--faint); cursor: pointer; }
.reco .message { margin-top: 12px; }
.reco .message label { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.reco .message textarea { margin-top: 5px; background: var(--bg); }
.reco .leak { font-size: 11.5px; margin: 6px 0 0; color: var(--accent); }
.reco .leak.bad { color: var(--gold-ink); font-weight: 600; }

.components { display: flex; flex-direction: column; gap: 3px; margin: 8px 0; }
.component { display: grid; grid-template-columns: 150px 1fr 42px; gap: 10px; align-items: center; font-size: 11.5px; color: var(--dim); }
.component i { height: 4px; border-radius: 2px; background: var(--accent); display: block; min-width: 1px; }
.component.penalty i { background: var(--gold); }
.component b { font-family: var(--mono); font-size: 11px; color: var(--text); text-align: right; }
.component.muted i { background: var(--line); }

.rejected-row { display: flex; gap: 12px; font-size: 12.5px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.rejected-row span { color: var(--faint); }
.person-card { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 15px; margin-bottom: 8px; }
.person-card header { display: flex; align-items: baseline; gap: 9px; margin-bottom: 8px; }
.person-card h3 { margin: 0; font-size: 14px; font-weight: 500; }

/* Sources et parametres */
.source-row { display: grid; grid-template-columns: 108px 1fr 150px; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.source-row .name { font-weight: 500; }
.source-row .name small { display: block; font-family: var(--mono); font-size: 10px; color: var(--faint); font-weight: 400; }
.source-row .bar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.source-row .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.source-row .facts { font-family: var(--mono); font-size: 10.5px; color: var(--faint); text-align: right; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setting-row .label { font-size: 13px; }
.setting-row .label small { display: block; color: var(--faint); font-size: 11.5px; }
.readout-row { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--faint); padding: 1px 0; }
.readout-row b { color: var(--text); font-weight: 400; }
.readout-row.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.journal-row { font-size: 12px; color: var(--dim); padding: 5px 0; border-bottom: 1px solid var(--line); }

/* ------------------------------------------------------ Panneau droit */

.drawer {
  width: 0; background: var(--bg2); border-left: 1px solid transparent;
  overflow-y: auto; transition: width 280ms cubic-bezier(.4,0,.2,1);
}
.drawer.open { width: var(--drawer); border-left-color: var(--line); }
.drawer-empty { padding: 26px 22px; color: var(--faint); font-size: 12.5px; }
.drawer > section, .drawer > header { padding: 16px 22px; border-bottom: 1px solid var(--line); }
.drawer-head { position: relative; }
.drawer-head .close { position: absolute; top: 14px; right: 16px; border: none; color: var(--faint); font-size: 15px; padding: 2px 6px; }
.drawer-head h2 { margin: 6px 0 6px; font-family: var(--serif); font-size: 25px; font-weight: 300; letter-spacing: -.015em; }
.drawer-head .desc { margin: 0; font-size: 13px; color: var(--dim); line-height: 1.5; }
.drawer h3 { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin: 0 0 10px; font-weight: 400; }
.drawer .formula { font-family: var(--mono); font-size: 9.5px; color: var(--faint); text-transform: none; letter-spacing: 0; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pair .k { font-family: var(--mono); font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }
.pair .v { font-size: 13px; margin-top: 2px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; padding: 2px 0; }
.kv b { font-family: var(--mono); font-size: 11.5px; font-weight: 400; }
.kv.rel span { color: var(--dim); }
.viewpoint-note { font-size: 12.5px; color: var(--gold-ink); margin: 10px 0 0; line-height: 1.5; }
.note { font-size: 12px; color: var(--faint); margin: 10px 0 0; line-height: 1.5; }

.evidence { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.evidence li { display: grid; grid-template-columns: 74px 1fr; gap: 10px; align-items: baseline; }
.evidence .src { font-family: var(--mono); font-size: 9.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }
.evidence p { margin: 0; font-size: 12.5px; line-height: 1.45; }
.evidence .prov { color: var(--faint); font-size: 11.5px; margin-top: 3px; }
.evidence .w { font-family: var(--mono); font-size: 10px; color: var(--faint); }

.drawer-actions { display: flex; flex-direction: column; gap: 6px; padding-bottom: 30px; }
.drawer-actions button { text-align: left; }
.privacy-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.privacy-actions button { font-size: 11.5px; padding: 4px 10px; }
.board-content { white-space: pre-wrap; font-family: var(--serif); font-size: 16px; font-weight: 300; }

/* -------------------------------------------------------------- Chat */

.chat-toggle {
  position: fixed; right: 20px; bottom: 20px; width: 38px; height: 38px;
  border-radius: 11px; background: var(--accent); border-color: var(--accent);
  color: var(--bg); display: grid; place-items: center; z-index: 20;
}
.chat {
  position: fixed; right: 20px; bottom: 68px; width: 340px; max-height: 62vh;
  background: var(--bg2); border: 1px solid var(--line2); border-radius: var(--r);
  display: none; flex-direction: column; overflow: hidden; z-index: 20;
  box-shadow: 0 20px 50px rgba(0,0,0,.18);
}
.chat.open { display: flex; }
.chat header { display: flex; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.chat header h3 { margin: 0; font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 400; }
.chat header .close { margin-left: auto; border: none; color: var(--faint); font-size: 16px; padding: 0 4px; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; }
.msg { font-size: 12.5px; padding: 8px 11px; border-radius: 10px; max-width: 92%; line-height: 1.45; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--bg); }
.msg.assistant { background: var(--bg3); }
.chat-form { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chat-form button { flex: none; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 12px 12px; }
.chat-suggest button { font-size: 11px; padding: 4px 9px; color: var(--dim); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* La barre du haut doit tenir sur une ligne le plus longtemps possible :
   quand elle se replie, elle mange le canvas. */
@media (max-width: 1240px) {
  .drawer.open { width: 330px; }
  .search { width: 140px; }
  .titles p { display: none; }
}
@media (max-width: 1040px) {
  :root { --sidebar: 196px; }
  .search { width: 112px; font-size: 12px; }
  .seg { padding: 4px 8px; font-size: 11.5px; }
  .topbar { padding: 12px 14px; gap: 12px; }
  .topbar-tools { gap: 6px; }
  .titles h1 { font-size: 14px; }
}
/* Sous cette largeur, un panneau qui prend sa place dans la grille laisse
   moins de 250 px au contenu. Il passe donc en superposition. */
@media (max-width: 1040px) {
  .drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 15; }
  .drawer.open { width: 324px; box-shadow: -18px 0 44px rgba(0,0,0,.16); }
  .drawer > section, .drawer > header { padding: 14px 18px; }
  .drawer-head h2 { font-size: 21px; }
}
@media (max-width: 880px) {
  .segmented[aria-label="Vue principale"] { display: none; }
  /* Uniquement la legende du graphe : le releve du tableau garde ses libelles,
     sinon il n'affiche plus qu'une suite de nombres sans nom. */
  .view[data-view="moi"] .legend span:not(:last-child) { display: none; }
}

/* ------------------------------------------------------------------ Portrait

   Page composée automatiquement. Le canevas fait 2160 px de large et se met à
   l'échelle du conteneur : les positions calculées par layout.ts restent donc
   valables quelle que soit la fenêtre.
   ------------------------------------------------------------------------- */

.portrait-host { position: absolute; inset: 0; overflow: auto; padding: 0 0 60px; }
/* Le canevas garde ses coordonnées absolues (2160 px de large) et c'est une
   mise à l'échelle qui l'adapte à la fenêtre. `zoom` ne sait pas prendre un
   min()/calc() — il retombait silencieusement à 1 et la page débordait — donc
   le facteur est calculé en JS et posé sur --pscale. Le calque .portrait-scaler
   réserve la place réellement occupée après mise à l'échelle, sinon le conteneur
   croit toujours faire 2160 px et affiche une barre horizontale inutile. */
.portrait-scaler { position: relative; }
.portrait-canvas {
  position: absolute; top: 0; left: 0; width: 2160px;
  transform: scale(var(--pscale, 1)); transform-origin: 0 0;
}
.portrait-connectors { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.portrait-link { fill: none; stroke: var(--slate); stroke-width: 1.4; stroke-opacity: .5; }
.portrait-link-label {
  font-family: 'Caveat', cursive; font-size: 17px; fill: var(--slate);
  text-anchor: middle; opacity: .92;
}

.portrait-block {
  position: absolute; background: var(--bg2); border-radius: var(--r);
  padding: 16px 18px; box-shadow: 0 1px 2px rgba(0,0,0,.09);
  transition: box-shadow 160ms ease, transform 160ms ease;
}
.portrait-block:hover { box-shadow: 0 4px 14px rgba(0,0,0,.10); }
.portrait-block h3 {
  margin: 0 0 12px; font-family: var(--mono); font-size: 9px;
  letter-spacing: .09em; text-transform: uppercase; color: var(--faint); font-weight: 500;
}
.portrait-caption {
  margin: 10px 0 0; font-family: var(--serif); font-style: italic;
  font-size: 11.5px; color: var(--faint);
}
/* Une carte privée reste lisible mais se signale : elle sautera au partage. */
.portrait-block.is-private { border-left: 2px solid var(--gold); }

.portrait-tools {
  position: absolute; top: 6px; right: 6px; display: flex; gap: 2px;
  opacity: 0; transition: opacity 140ms ease;
}
.portrait-block:hover .portrait-tools { opacity: 1; }
.portrait-tools button {
  width: 20px; height: 20px; padding: 0; font-size: 11px; line-height: 1;
  border-radius: 5px; color: var(--faint);
}

/* Les douze formes ------------------------------------------------------- */

.portrait-body.identity { display: flex; gap: 12px; align-items: center; }
.portrait-avatar {
  width: 54px; height: 54px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, var(--accent), var(--slate));
}
.portrait-name { font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.portrait-role { font-size: 11.5px; color: var(--dim); }

.portrait-body.hub p, .portrait-body.quote p {
  margin: 0; font-family: var(--serif); font-weight: 300; letter-spacing: -.01em;
}
.portrait-body.hub p { font-size: 27px; line-height: 1.25; }
.portrait-body.quote p { font-size: 21px; line-height: 1.3; font-style: italic; }
.portrait-body .attr { display: block; margin-top: 8px; font-size: 11px; color: var(--faint); }

.portrait-body ul { margin: 0; padding-left: 15px; }
.portrait-body li { font-size: 13px; line-height: 1.55; }
.portrait-body li.check { list-style: none; margin-left: -15px; }
.portrait-body li.check::before { content: '☐ '; color: var(--faint); }
.portrait-body li.check.on::before { content: '☑ '; color: var(--accent); }

.portrait-body .chips { display: flex; flex-wrap: wrap; gap: 6px; }

.prow { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; font-size: 13px; }
.prow + .prow { border-top: 1px solid var(--line); }
.plabel { font-weight: 500; }
.pdetail { color: var(--dim); font-size: 11.5px; }
.pmeta { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--faint); }

.pperson { display: flex; align-items: center; gap: 9px; padding: 6px 0; }
.pavatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
  background: var(--bg3); color: var(--dim);
}
.pperson b { display: block; font-size: 13px; font-weight: 500; }
.pperson em { font-style: normal; font-size: 11px; color: var(--faint); }

.pbar { display: grid; grid-template-columns: 118px 1fr 34px; gap: 8px; align-items: center;
        font-size: 12px; padding: 4px 0; }
.pbar i { height: 5px; border-radius: 3px; background: var(--accent); opacity: .75; display: block; }
.pbar b { font-family: var(--mono); font-size: 11px; text-align: right; color: var(--dim); }

.pcircles { display: flex; flex-wrap: wrap; gap: 9px; }
.pcircle {
  width: 74px; height: 74px; border-radius: 50%; border: 1px solid var(--line2);
  display: grid; place-items: center; text-align: center;
  font-size: 11px; color: var(--dim); padding: 4px;
}

.ptimeline { display: flex; align-items: flex-end; gap: 5px; height: 78px; }
.ptl { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%;
       justify-content: flex-end; gap: 4px; }
.ptl i { width: 100%; background: var(--accent); opacity: .55; border-radius: 2px 2px 0 0; }
.ptl em { font-style: normal; font-family: var(--mono); font-size: 9px; color: var(--faint); }

.pimages { display: grid; gap: 6px; }
.pimages.grid, .pimages.mosaic { grid-template-columns: 1fr 1fr; }
.pimages.strip { grid-template-columns: repeat(4, 1fr); }
.pimages figure { margin: 0; }
.pimages img { width: 100%; height: 92px; object-fit: cover; border-radius: 7px; display: block; }
.pimages figcaption { font-size: 8.5px; color: var(--faint); margin-top: 3px; }
.pimages figcaption a { color: inherit; }

.pswatches { display: flex; gap: 12px; flex-wrap: wrap; }
.pswatch { display: flex; flex-direction: column; gap: 5px; font-size: 10px; color: var(--faint); }
.pswatch i { width: 44px; height: 30px; border-radius: 6px; border: 1px solid var(--line); }

.ppills { display: flex; flex-direction: column; gap: 6px; }
.ppill { padding: 7px 11px; border-radius: 7px; font-size: 12.5px; color: var(--bg); }
.ppill.tone-accent { background: var(--accent); }
.ppill.tone-gold { background: var(--goldInk, var(--gold)); }
.ppill.tone-slate { background: var(--slate); }

#portrait-status { display: flex; gap: 14px; align-items: center; }
#portrait-status button { font-size: 11px; padding: 3px 9px; }
