/* Lecture structurée de la note — Lot 3 */
.insights-panel {
  border-top: 1px solid var(--line, #ddd7cd);
  padding: 12px 14px 14px;
  background: var(--paper-raised, #fffdf8);
  min-width: 0;
  flex-shrink: 0;
  /* position:sticky ne peut se déplacer qu'à l'intérieur de son bloc
     englobant immédiat. Posé sur .insights-tabs seul (à l'intérieur de ce
     panneau, haut de ~160px), la barre ne restait "collée" que sur une
     fenêtre de scroll de ~150px avant la fin du carnet — quasi invisible
     sur un carnet long. En le posant ici, sur .insights-panel qui est
     enfant DIRECT de .ledger (le vrai scrollport, overflow-y:auto,
     base.css), la plage de "collage" couvre tout le scroll de #rows :
     les onglets Calculs/Décisions/Actions/Repères restent visibles quelle
     que soit la longueur du carnet. .insights-content garde son plafond
     (30vh) et son propre scroll interne, donc le panneau collé reste
     compact. Fond opaque + z-index : au tout bas réel de .ledger, .legend
     (qui suit ce panneau dans le DOM) défile derrière lui au lieu de le
     recouvrir. */
  position: sticky;
  bottom: 0;
  z-index: 2;
}

.insights-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.insights-tabs button {
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid var(--line, #ddd7cd);
  border-radius: 999px;
  background: transparent;
  color: var(--muted, #77736b);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.insights-tabs button:hover,
.insights-tabs button:focus-visible {
  border-color: var(--accent, #b9652b);
  color: var(--ink, #292721);
}

.insights-tabs button[aria-selected="true"] {
  background: var(--accent, #b9652b);
  border-color: var(--accent, #b9652b);
  color: #fffdf8;
}

.tab-insight-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 1px 5px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: .64rem;
  line-height: 1;
  opacity: .78;
}

.tab.on .tab-insight-badge { opacity: 1; }

.insights-content {
  max-height: 30vh;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  padding-top: 10px;
}

.insights-content h3 {
  margin: 10px 0 6px;
  font-size: 0.82rem;
  color: var(--ink, #292721);
}

.insights-content h3:first-child { margin-top: 0; }

.insights-content h3 small,
.insights-content li small {
  color: var(--muted, #77736b);
  font-size: 0.72rem;
  font-weight: 400;
}

.insights-content ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.insights-content li {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 7px 8px;
  border-left: 2px solid var(--accent, #b9652b);
  background: color-mix(in srgb, var(--paper, #f7f3eb) 75%, transparent);
  font-size: 0.78rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.insights-content li[data-source-line] {
  cursor: pointer;
  transition: background-color .15s ease, transform .15s ease;
}

.insights-content li[data-source-line]:hover,
.insights-content li[data-source-line]:focus-visible {
  background: color-mix(in srgb, var(--accent, #b9652b) 12%, var(--paper, #f7f3eb));
  outline: 2px solid color-mix(in srgb, var(--accent, #b9652b) 55%, transparent);
  outline-offset: 1px;
}

.insights-content li.insight-item--done {
  border-left-color: #66805e;
  opacity: .72;
}

.insight-source { margin-left: auto; }

.insights-content li span { flex: 1 1 100%; }
.insights-content li small { overflow-wrap: anywhere; }
.insights-empty,
.insights-help,
.insights-count { margin: 0; color: var(--muted, #77736b); font-size: 0.78rem; }

@media (max-width: 760px) {
  /* Le collage (position:sticky) est une correction desktop : sur mobile,
     .ledger est une feuille du bas à hauteur pilotée par --insights-height
     (adjustPanelHeight(), insights-ui.js), pas un scrollport classique.
     Sticky y transformait ce panneau en overlay qui interceptait les clics
     destinés à .ticket-grab/.ticket-peek, situés au-dessus dans la feuille.
     Le comportement mobile existant (déjà pensé pour ne pas écraser
     #rows/.tab-bar, cf. fb6afd8) reste inchangé. */
  .insights-panel { position: static; padding-inline: 10px; }
  .insights-tabs { gap: 5px; }
  .insights-tabs button { min-height: 44px; padding-inline: 12px; }
  .ledger:not(.collapsed) {
    max-height: var(--insights-height, 72dvh);
  }
  .ledger:not(.collapsed) .rows {
    max-height: calc(var(--insights-height, 72dvh) - 72px);
  }
  .insights-content { max-height: min(35vh, 280px); }
}

@media (prefers-reduced-motion: reduce) {
  .insights-panel * { scroll-behavior: auto; }
}

.home-quick-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.home-quick-actions button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--ink-line, #2e323b);
  border-radius: 8px;
  background: transparent;
  color: inherit;
}

.home-quick-actions button:hover,
.home-quick-actions button:focus-visible {
  border-color: var(--copper, #b0622d);
  color: var(--copper, #b0622d);
}

.home-step-label {
  margin: 14px 0 0;
  color: var(--txt-dim, #8b919e);
  font-size: 0.78rem;
}

.home-onboarding-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.home-onboarding-actions button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--ink-line, #2e323b);
  border-radius: 8px;
  color: var(--text-muted, #cfcbc2);
}

.home-onboarding-actions .cta {
  background: var(--copper, #b0622d);
  border-color: var(--copper, #b0622d);
  color: #fff;
}

.quick-help {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 20px 10px;
  padding: 8px 10px;
  border-left: 3px solid var(--copper, #b0622d);
  background: color-mix(in srgb, var(--paper, #f7f3eb) 8%, transparent);
  color: var(--text-muted, #cfcbc2);
  font-size: 0.72rem;
}

.quick-help strong { color: var(--copper, #b0622d); }
.quick-help span { flex: 1; }
.quick-help code { color: var(--copper, #b0622d); }
.quick-help button { min-height: 32px; padding: 4px 8px; }

@media (max-width: 760px) {
  .quick-help { margin-inline: 10px; }
  .home-onboarding-actions button { width: min(100%, 280px); }
}
