/* ============================================================
   Lib Hymus — Étude de marché Advertesting™
   Direction : « dossier d'investissement » — navy d'encre, sable
   ochre, papier chaud. Display: Bricolage Grotesque / Texte: Public Sans
   ============================================================ */

:root {
  --paper: #F6F4EF;
  --surface: #FFFFFF;
  --ink: #182338;
  --ink-2: #46506A;
  --muted: #878CA0;
  --line: #E4E0D5;
  --line-soft: #EEEAE0;

  --navy: #2D5A92;          /* série « Sélections » (demande) */
  --navy-deep: #1D3A61;
  --navy-tint: #E8EEF6;
  --sand: #C79A45;          /* série « Mix du projet » (offre) */
  --sand-soft: #F4EDDD;
  --red: #B4473E;           /* pôle négatif (divergent) */
  --red-tint: #F6E7E5;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(24, 35, 56, 0.05), 0 8px 28px -12px rgba(24, 35, 56, 0.12);
  --font-display: "Bricolage Grotesque", "Public Sans", system-ui, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --header-h: 58px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 18px); }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: clamp(14.8px, 1.1vw + 12px, 16px);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
img { max-width: 100%; height: auto; }

a { color: var(--navy); }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; border-radius: 4px; }

/* ---------- Header ---------- */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 60;
  height: var(--header-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 clamp(16px, 4vw, 32px);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 6px 18px -14px rgba(24, 35, 56, 0.28);
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--ink); }
.brand .brand-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.brand .brand-tm { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.header-spacer { flex: 1; }
.header-cta {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--navy); color: #fff; border: none; cursor: pointer;
  font: 600 13.5px/1 var(--font-body);
  padding: 10px 16px; border-radius: 999px;
  transition: background 0.15s ease, transform 0.15s ease;
}
.header-cta:hover { background: var(--navy-deep); }
.header-cta svg { width: 15px; height: 15px; }
.header-logo { height: 38px; width: auto; display: block; flex: none; margin-left: 4px; }
.progress-bar {
  position: absolute; left: 0; bottom: -1px; height: 2px; width: 0;
  background: linear-gradient(90deg, var(--navy), var(--sand));
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1220px; margin: 0 auto;
  padding: calc(var(--header-h) + 34px) clamp(16px, 4vw, 32px) 80px;
  display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 44px;
}
.layout > main { min-width: 0; }
.layout > .toc { min-width: 0; max-width: 100%; }
.chart-wrap > canvas { max-width: 100%; }
.toc {
  position: sticky; top: calc(var(--header-h) + 28px);
  align-self: start; max-height: calc(100vh - var(--header-h) - 56px);
  overflow: auto; padding-right: 6px;
  scrollbar-width: thin;
}
.toc-label { font: 700 11px/1 var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px 2px; }
.toc nav { display: flex; flex-direction: column; gap: 2px; }
.toc a {
  display: flex; gap: 8px; align-items: baseline;
  padding: 6.5px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--ink-2); text-decoration: none; line-height: 1.35;
  border-left: 2px solid transparent;
}
.toc a .num { font: 700 10.5px/1.4 var(--font-body); color: var(--muted); letter-spacing: 0.04em; min-width: 16px; }
.toc a:hover { background: var(--line-soft); color: var(--ink); }
.toc a.active { background: var(--navy-tint); color: var(--navy-deep); border-left-color: var(--navy); }
.toc a.active .num { color: var(--navy); }
.toc a.toc-sub { padding-left: 26px; font-size: 12.8px; }

/* ---------- Hero ---------- */
.hero { margin-bottom: 26px; }
.eyebrow {
  font: 700 12px/1 var(--font-body); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--navy); margin: 0 0 14px;
  display: flex; align-items: center; gap: 10px;
}
.eyebrow::after { content: ""; height: 1px; flex: 0 0 44px; background: var(--sand); }
h1 {
  font-family: var(--font-display);
  font-size: clamp(40px, 6.5vw, 64px);
  font-weight: 700; letter-spacing: -0.025em; line-height: 1.02;
  margin: 0 0 10px;
}
h1 .h1-sub { display: block; font-size: clamp(17px, 2.2vw, 22px); font-weight: 500; color: var(--ink-2); letter-spacing: -0.005em; margin-top: 12px; line-height: 1.35; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px 22px; color: var(--muted); font-size: 13.5px; margin: 18px 0 0; }
.hero-meta span { display: inline-flex; align-items: center; gap: 7px; }
.hero-meta .meta-team { display: inline; line-height: 1.6; }
.hero-meta .meta-team b { font-weight: 600; color: var(--ink-2); }
.hero-meta svg { width: 14px; height: 14px; opacity: 0.75; }

/* Entonnoir (signature du hero) */
.funnel { margin-top: 34px; display: grid; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: minmax(150px, 210px) 1fr; gap: 16px; align-items: center; }
.funnel-row .f-label { text-align: right; }
.funnel-row .f-label b { display: block; font-size: 14px; font-weight: 600; line-height: 1.3; }
.funnel-row .f-label small { color: var(--muted); font-size: 12px; line-height: 1.35; display: block; }
.funnel-track { position: relative; height: 44px; }
.funnel-fill {
  height: 100%; border-radius: 8px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; min-width: 96px;
  color: #fff; white-space: nowrap;
  transform-origin: left center;
  animation: growX 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.funnel-row:nth-child(1) .funnel-fill {
  background: linear-gradient(135deg, #2E547F 0%, #1D3A61 60%, #16294a 100%);
  box-shadow: 0 14px 30px -12px rgba(29, 58, 97, 0.65), inset 0 1px 0 rgba(255,255,255,0.22);
}
.funnel-row:nth-child(2) .funnel-fill {
  background: linear-gradient(135deg, #4373B0 0%, #2D5A92 65%, #24487a 100%);
  box-shadow: 0 14px 30px -12px rgba(45, 90, 146, 0.6), inset 0 1px 0 rgba(255,255,255,0.25);
  animation-delay: 0.12s;
}
.funnel-row:nth-child(3) .funnel-fill {
  background: linear-gradient(135deg, #E0B565 0%, #C79A45 65%, #b3873a 100%);
  color: var(--ink);
  box-shadow: 0 14px 30px -12px rgba(199, 154, 69, 0.65), inset 0 1px 0 rgba(255,255,255,0.35);
  animation-delay: 0.24s;
}
.funnel-fill .f-n { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }
.funnel-fill .f-pct { font-size: 12px; opacity: 0.85; font-weight: 600; }
@keyframes growX { from { transform: scaleX(0.15); opacity: 0; } to { transform: scaleX(1); opacity: 1; } }

/* ---------- Sections ---------- */
section.part { margin-top: 64px; scroll-margin-top: calc(var(--header-h) + 20px); }
.part-head { display: flex; align-items: baseline; gap: 16px; border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 8px; }
.part-head .roman { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--sand); letter-spacing: 0.08em; }
.part-head h2 { font-family: var(--font-display); font-weight: 700; font-size: clamp(24px, 3.4vw, 32px); letter-spacing: -0.02em; margin: 0; line-height: 1.15; }
.part-lede { color: var(--ink-2); font-size: 15.5px; margin: 14px 0 0; }

article.block { margin-top: 34px; scroll-margin-top: calc(var(--header-h) + 20px); }
.block > h3 { font-family: var(--font-display); font-weight: 600; font-size: 21px; letter-spacing: -0.015em; margin: 0 0 6px; display: flex; align-items: baseline; gap: 10px; }
.block > h3 .idx { color: var(--muted); font-size: 13px; font-weight: 700; }
.block-sub { color: var(--ink-2); font-size: 14.5px; margin: 0 0 16px; }

/* Cartes */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(16px, 2.6vw, 26px);
}
.chart-card .chart-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-bottom: 4px; }
.chart-card .chart-title { font-weight: 600; font-size: 15px; margin: 0; }
.chart-card .chart-unit { color: var(--muted); font-size: 12.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 10px 0 4px; }
.legend .key { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
.swatch.sel { background: var(--navy); }
.swatch.mix { background: var(--sand); }
.swatch.neg { background: var(--red); }
.chart-wrap { position: relative; height: clamp(270px, 50vw, 340px); margin-top: 8px; }
.chart-wrap.tall { height: clamp(370px, 100vw, 430px); }
.chart-wrap.short { height: clamp(225px, 42vw, 260px); }
.chart-wrap.xtall { height: clamp(460px, 135vw, 560px); }

/* Tables de données repliables */
details.data-table { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 10px; }
details.data-table summary {
  cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; user-select: none;
  list-style: none; display: inline-flex; align-items: center; gap: 6px;
}
details.data-table summary::-webkit-details-marker { display: none; }
details.data-table summary::before { content: "▸"; transition: transform 0.15s; font-size: 11px; }
details.data-table[open] summary::before { transform: rotate(90deg); }
details.data-table .table-scroll { overflow-x: auto; margin-top: 10px; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.data th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--line-soft); }

/* Analyse / Conclusion */
.analysis { margin: 18px 0 0; }
.analysis .tag, .conclusion .tag {
  display: inline-block; font: 700 11px/1 var(--font-body);
  letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 8px;
}
.analysis .tag { color: var(--navy); }
.analysis p { margin: 0 0 10px; color: var(--ink-2); font-size: 15px; }
.conclusion {
  margin: 18px 0 0; padding: 16px 20px;
  background: var(--sand-soft);
  border-left: 3px solid var(--sand);
  border-radius: 0 10px 10px 0;
}
.conclusion .tag { color: #8F6A1F; }
.conclusion p { margin: 0; font-size: 15px; color: var(--ink); }

/* Chips d'écart */
.ecarts-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600;
  border-radius: 999px; padding: 6px 12px;
  border: 1px solid transparent;
}
.chip .delta { font-variant-numeric: tabular-nums; font-weight: 700; }
.chip.pos { background: var(--navy-tint); color: var(--navy-deep); border-color: color-mix(in srgb, var(--navy) 25%, transparent); }
.chip.neg { background: var(--red-tint); color: #8C332C; border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.chips-note { font-size: 11.5px; color: var(--muted); margin-top: 8px; }

/* KPI tuiles (sommaire) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-top: 22px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.kpi .k-value { font-family: var(--font-display); font-weight: 700; font-size: clamp(26px, 2.6vw + 14px, 32px); letter-spacing: -0.02em; line-height: 1.1; margin: 6px 0 4px; }
.kpi .k-note { font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.kpi.accent { background: linear-gradient(135deg, var(--navy-deep), var(--navy)); border-color: var(--navy-deep); }
.kpi.accent .k-label { color: #B9CCE4; }
.kpi.accent .k-value, .kpi.accent .k-note { color: #fff; }

/* Constats (sommaire exécutif) */
.findings { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 20px; }
.finding { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.finding .f-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--navy-tint); color: var(--navy); display: grid; place-items: center; }
.finding .f-icon svg { width: 17px; height: 17px; }
.finding h4 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.005em; }
.finding p { margin: 0; font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }

/* Tableau PSF (méthodologie) */
.psf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-top: 16px; }
.psf-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--surface); }
.psf-card h5 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.psf-card table { width: 100%; border-collapse: collapse; font-size: 13px; }
.psf-card td { padding: 4px 0; font-variant-numeric: tabular-nums; }
.psf-card td:first-child { color: var(--ink-2); }
.psf-card td:last-child { text-align: right; font-weight: 600; }

/* Heatmap corrélations */
.heatmap-scroll { overflow-x: auto; padding-bottom: 6px; }
.heatmap { display: grid; gap: 3px; min-width: 500px; margin-top: 10px; }
.hm-cell {
  border-radius: 9px; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  height: 48px; cursor: default;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), inset 0 -8px 14px -10px rgba(24,35,56,0.35);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.hm-cell:hover {
  transform: scale(1.12);
  box-shadow: 0 12px 26px -8px rgba(24, 35, 56, 0.45), inset 0 1px 0 rgba(255,255,255,0.25);
  position: relative; z-index: 2;
}
.hm-label {
  display: flex; align-items: center; font-size: 12px; color: var(--ink-2); font-weight: 500; line-height: 1.2;
  padding-right: 8px; padding-left: 2px;
  position: sticky; left: 0; z-index: 2;
  background: linear-gradient(90deg, var(--surface) 82%, transparent);
}
.hm-collabel {
  display: flex; align-items: flex-end; justify-content: center; text-align: center;
  font-size: 11.5px; color: var(--ink-2); font-weight: 500; line-height: 1.25; padding-bottom: 6px;
}
.hm-scale { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.hm-scale .grad { flex: 0 0 180px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #B4473E, #EFECE6, #2D5A92); }

/* Top unités */
.units-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 14px; margin-top: 18px; }
.unit-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; position: relative; overflow: hidden; }
.unit-card .u-rank {
  position: absolute; top: 0; right: 0; padding: 5px 12px;
  background: var(--sand-soft); color: #8F6A1F; font-weight: 700; font-size: 11.5px;
  border-radius: 0 0 0 10px; letter-spacing: 0.06em;
}
.unit-card.first .u-rank { background: var(--navy); color: #fff; }
.unit-card .u-num { font-family: var(--font-display); font-weight: 700; font-size: 30px; letter-spacing: -0.02em; }
.unit-card .u-typ { color: var(--navy); font-weight: 600; font-size: 13px; margin-top: 2px; }
.unit-card dl { margin: 12px 0 0; display: grid; gap: 5px; font-size: 12.8px; }
.unit-card dl div { display: flex; justify-content: space-between; gap: 10px; }
.unit-card dt { color: var(--muted); }
.unit-card dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.unit-card .u-bar { height: 7px; border-radius: 4px; background: var(--line-soft); margin-top: 14px; overflow: hidden; }
.unit-card .u-bar i { display: block; height: 100%; background: linear-gradient(90deg, #4373B0, var(--navy-deep)); border-radius: 4px; box-shadow: 0 2px 8px rgba(45,90,146,0.5); }
.unit-card { transition: transform 0.16s ease, box-shadow 0.16s ease; }
.unit-card:hover { transform: translateY(-3px); box-shadow: 0 4px 8px rgba(24,35,56,0.06), 0 18px 40px -14px rgba(24,35,56,0.22); }

/* Recommandations */
.recos { counter-reset: reco; display: grid; gap: 10px; margin-top: 20px; }
.reco { display: grid; grid-template-columns: 40px 1fr; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 15px 18px; box-shadow: var(--shadow); }
.reco::before {
  counter-increment: reco; content: counter(reco, decimal-leading-zero);
  font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--sand);
  align-self: start; padding-top: 1px;
}
.reco b { display: block; font-size: 14.5px; margin-bottom: 2px; }
.reco p { margin: 0; font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 70px; padding: 30px 0 10px; color: var(--muted); font-size: 13px; }
.site-footer .foot-grid { display: flex; flex-wrap: wrap; gap: 14px 40px; justify-content: space-between; align-items: baseline; }
.site-footer b { color: var(--ink-2); font-weight: 600; }
.site-footer .foot-note { margin-top: 14px; font-size: 12px; max-width: 78ch; line-height: 1.6; }

/* ---------- Chat ---------- */
.chat-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 70;
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--navy-deep); color: #fff; border: none; cursor: pointer;
  font: 600 14px/1 var(--font-body);
  padding: 14px 20px; border-radius: 999px;
  box-shadow: 0 10px 30px -8px rgba(24, 35, 56, 0.45);
  transition: transform 0.15s ease, background 0.15s ease;
}
.chat-fab:hover { transform: translateY(-2px); background: var(--navy); }
.chat-fab svg { width: 17px; height: 17px; }
.chat-fab .pulse {
  position: absolute; top: -3px; right: -3px; width: 11px; height: 11px;
  background: var(--sand); border-radius: 50%; border: 2px solid var(--paper);
}

.chat-panel {
  position: fixed; right: 22px; bottom: 22px; z-index: 80;
  width: min(680px, calc(100vw - 28px));
  height: min(860px, calc(100dvh - 44px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 24px 70px -18px rgba(24, 35, 56, 0.45);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(14px) scale(0.98); pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.chat-panel.open { opacity: 1; transform: none; pointer-events: auto; }
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--navy-deep); color: #fff;
}
.chat-head .c-avatar {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--sand), #E0BC72);
  display: grid; place-items: center; color: var(--navy-deep);
}
.chat-head .c-avatar svg { width: 18px; height: 18px; }
.chat-head .c-title { font-weight: 700; font-size: 14.5px; line-height: 1.2; }
.chat-head .c-sub { font-size: 11.5px; opacity: 0.75; }
.chat-head .c-close { margin-left: auto; background: none; border: none; color: #fff; opacity: 0.8; cursor: pointer; padding: 6px; border-radius: 8px; }
.chat-head .c-close:hover { opacity: 1; background: rgba(255,255,255,0.12); }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--paper); }
.msg { max-width: 88%; padding: 11px 15px; border-radius: 14px; font-size: 14px; line-height: 1.58; overflow-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; max-width: 96%; min-width: 0; }
.msg.bot p { margin: 0 0 8px; } .msg.bot p:last-child { margin: 0; }
.msg.bot ul, .msg.bot ol { margin: 4px 0 8px; padding-left: 18px; }
.msg.bot li { margin: 2px 0; }
.msg.bot strong { color: var(--navy-deep); }
.msg.bot table {
  display: block; max-width: 100%; overflow-x: auto;
  border-collapse: collapse; font-size: 12.8px; margin: 8px 0;
  scrollbar-width: thin;
}
.msg.bot th, .msg.bot td { border: 1px solid var(--line); padding: 5px 9px; white-space: nowrap; }
.msg.bot tr:first-child td { background: var(--line-soft); font-weight: 600; }
.msg.bot .caret { display: inline-block; width: 7px; height: 14px; background: var(--sand); margin-left: 2px; vertical-align: text-bottom; animation: blink 0.9s steps(2) infinite; border-radius: 1px; }
@keyframes blink { 50% { opacity: 0; } }
.msg.error { background: var(--red-tint); border: 1px solid color-mix(in srgb, var(--red) 30%, transparent); color: #8C332C; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 7px; }
.chat-suggestions button {
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  font: 500 12px/1.3 var(--font-body); color: var(--navy-deep);
  padding: 7px 12px; cursor: pointer; text-align: left;
}
.chat-suggestions button:hover { border-color: var(--navy); background: var(--navy-tint); }
.chat-inputbar { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-inputbar textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px;
  font: 400 13.8px/1.45 var(--font-body); color: var(--ink);
  padding: 10px 12px; max-height: 110px; background: var(--paper);
}
.chat-inputbar textarea:focus { outline: 2px solid var(--navy); outline-offset: -1px; }
.chat-inputbar .send {
  flex: none; width: 42px; height: 42px; align-self: flex-end;
  border: none; border-radius: 12px; background: var(--navy); color: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.chat-inputbar .send:disabled { opacity: 0.45; cursor: default; }
.chat-inputbar .send svg { width: 17px; height: 17px; }
.chat-foot { font-size: 10.5px; color: var(--muted); text-align: center; padding: 0 12px 10px; background: var(--surface); }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc {
    position: sticky; top: var(--header-h); z-index: 50;
    max-height: none; overflow: visible;
    margin: 0 calc(-1 * clamp(16px, 4vw, 32px)) 8px;
    padding: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
  }
  .toc a .num { display: none; }
  .toc-label { display: none; }
  .toc nav {
    flex-direction: row; overflow-x: auto; gap: 4px;
    padding: 8px clamp(16px, 4vw, 32px);
    scrollbar-width: none;
  }
  .toc nav::-webkit-scrollbar { display: none; }
  .toc a { flex: none; border-left: none; border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0; padding: 6px 10px; }
  .toc a.active { border-left: none; border-bottom-color: var(--navy); background: var(--navy-tint); }
  .toc a.toc-sub { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .site-header { gap: 10px; padding: 0 14px; }
  .brand .brand-tm { display: none; }
  .header-logo { height: 28px; }
  .card { padding: 14px 12px; }
  .part-head { gap: 10px; }
  .conclusion { padding: 13px 15px; }
  .reco { grid-template-columns: 30px 1fr; gap: 10px; padding: 13px 14px; }
  .units-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .hm-cell { height: 42px; font-size: 11px; }
  .chat-inputbar textarea { font-size: 16px; }
  .funnel-fill .f-n { font-size: 16.5px; }
  .funnel-fill { padding: 0 11px; gap: 7px; }
  .funnel-row { grid-template-columns: 1fr; gap: 4px; }
  .funnel-row .f-label { text-align: left; display: flex; gap: 8px; align-items: baseline; }
  .funnel-track { height: 40px; }
  .hero-meta { gap: 6px 16px; font-size: 12.5px; }
  .chat-panel { right: 12px; bottom: 12px; width: calc(100vw - 24px); height: calc(100dvh - 24px); border-radius: 16px; }
  .chat-fab { right: 14px; bottom: 14px; padding: 13px 16px; }
  .chat-fab .fab-text { display: none; }
  .header-cta .cta-text { display: none; }
  .header-cta { padding: 10px 12px; }
}

/* Impression */
@media print {
  .site-header, .toc, .chat-fab, .chat-panel { display: none !important; }
  .layout { grid-template-columns: 1fr; padding-top: 0; }
  .card, .kpi, .finding { box-shadow: none; }
}
