/* AMT Journal — Análisis IA */
.ai { display: flex; flex-direction: column; gap: 16px; }
.ai .card-head { align-items: flex-start; }
.ai .card-title { display: inline-flex; align-items: center; gap: 8px; }
.ai-engine { display: inline-flex; cursor: help; }

/* chip de icono, compartido por hallazgos y estado vacío */
.ai-ic {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  color: var(--text-2);
}
.ai-tone-pos { color: var(--pos); background: var(--pos-soft); border-color: rgba(62, 207, 142, .2); }
.ai-tone-neg { color: var(--neg); background: var(--neg-soft); border-color: rgba(240, 97, 109, .2); }
.ai-tone-warn { color: var(--warn); background: var(--warn-soft); border-color: rgba(227, 169, 79, .2); }
.ai-tone-blue { color: var(--blue); background: var(--blue-soft); border-color: rgba(61, 123, 255, .24); }

/* ---------- héroe: score + pilares ---------- */
.ai-hero { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); overflow: hidden; }
.ai-hero::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(560px 300px at 7% -12%, rgba(61, 123, 255, .13), transparent 70%);
  pointer-events: none;
}
/* marcas de registro en las esquinas (mismo motivo que el héroe del dashboard) */
.ai-hero .mk { position: absolute; width: 9px; height: 9px; opacity: .32; pointer-events: none; }
.ai-hero .mk::before, .ai-hero .mk::after { content: ""; position: absolute; background: var(--text); }
.ai-hero .mk::before { left: 4px; top: 0; width: 1px; height: 9px; }
.ai-hero .mk::after { top: 4px; left: 0; height: 1px; width: 9px; }
.ai-hero .mk.tl { top: 9px; left: 9px; } .ai-hero .mk.tr { top: 9px; right: 9px; }
.ai-hero .mk.bl { bottom: 9px; left: 9px; } .ai-hero .mk.br { bottom: 9px; right: 9px; }

.ai-hero-main { position: relative; display: flex; flex-direction: column; min-width: 0; }
.ai-hero-top { flex: 1; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 36px; padding: 36px 36px 32px; }

.ai-score { position: relative; width: 184px; height: 184px; flex: none; }
.ai-score .ch-ring-track { stroke: var(--text); stroke-opacity: .07; }
.ai-score .ch-ring-val { filter: drop-shadow(0 0 7px rgba(61, 123, 255, .55)); }
.ai-score.is-low .ch-ring-val { filter: none; }
.ai-score-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ai-score-num { font-size: 58px; font-weight: 600; letter-spacing: -.05em; line-height: 1; }
.ai-score-of { margin-top: 5px; font-size: 11px; color: var(--text-3); }
.ai-score-grade { margin-top: 9px; padding-top: 8px; min-width: 76px; border-top: 1px solid var(--line); font-size: 12px; font-weight: 600; letter-spacing: .01em; color: var(--text); }
.ai-score.is-low .ai-score-grade { color: var(--warn); }

.ai-hero-text { min-width: 0; }
.ai-headline { margin-top: 12px; font-size: 26px; font-weight: 600; letter-spacing: -.032em; line-height: 1.2; text-wrap: balance; }
.ai-summary { margin-top: 12px; max-width: 62ch; font-size: 13.5px; line-height: 1.68; color: var(--text-2); }
.ai-hero-foot { display: flex; align-items: flex-start; gap: 9px; padding: 13px 36px 14px; border-top: 1px solid var(--line-soft); font-size: 12.5px; line-height: 1.5; color: var(--text-3); }
.ai-hero-foot .ic { flex: none; margin-top: 2px; }

.ai-pillars { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 22px 26px 6px; border-left: 1px solid var(--line-soft); }
.ai-pillars-cap { margin-bottom: 4px; }
.ai-pillar { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 12px 0 13px; border-bottom: 1px solid var(--line-soft); }
.ai-pillar:last-child { border-bottom: none; }
.ai-pillar-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ai-pillar-label { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 500; }
.ai-pillar-label .ic { color: var(--text-3); align-self: center; }
.ai-pillar-weight { padding: 1px 6px; border-radius: var(--r-xs); background: rgba(255, 255, 255, .05); font-size: 11px; font-weight: 500; color: var(--text-3); cursor: help; }
.ai-pillar-score { font-size: 16px; font-weight: 600; letter-spacing: -.02em; }
.ai-pillar-score span { margin-left: 2px; font-size: 11.5px; font-weight: 500; letter-spacing: 0; color: var(--text-3); }
.ai-pillar-text { margin-top: 9px; font-size: 12px; line-height: 1.55; color: var(--text-3); }

/* ---------- fortalezas y fugas ---------- */
.ai-list { display: flex; flex-direction: column; }
.ai-list .card-body { flex: 1; padding-top: 8px; padding-bottom: 8px; }
.ai-list .card-link { flex: none; padding-top: 1px; white-space: nowrap; }
.ai-insight { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 15px 0; border-bottom: 1px solid var(--line-soft); }
.ai-insight:last-of-type { border-bottom: none; }
.ai-insight-main { min-width: 0; }
.ai-insight-title { font-size: 13.5px; font-weight: 600; line-height: 1.35; letter-spacing: -.005em; }
.ai-insight-text { margin-top: 4px; font-size: 12.5px; line-height: 1.6; color: var(--text-2); }
.ai-insight-metric { padding-top: 1px; font-size: 13.5px; font-weight: 600; white-space: nowrap; color: var(--text); }
.ai-insight-metric.pos { color: var(--pos); }
.ai-insight-metric.neg { color: var(--neg); }
.ai-quiet { padding: 14px 0 18px; font-size: 13px; line-height: 1.6; color: var(--text-3); }
.ai-more { margin: 4px 0 8px -10px; }

/* ---------- plan de acción ---------- */
.ai-plan .card-body { padding-top: 8px; padding-bottom: 8px; }
.ai-plan-progress { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; padding-top: 2px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.ai-plan-progress .meter { width: 120px; }
.ai-step {
  width: 100%;
  display: grid; grid-template-columns: 20px auto minmax(0, 1fr); gap: 14px; align-items: start;
  padding: 15px 0;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}
.ai-step:last-child { border-bottom: none; }
.ai-step:disabled { cursor: progress; }
.ai-check {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--inset);
  color: transparent;
  transition: background .15s, border-color .15s, color .15s;
}
.ai-step:hover .ai-check { border-color: var(--text-3); }
.ai-step.is-done .ai-check { background: var(--blue); border-color: var(--blue); color: var(--text); }
.ai-step-num { padding-top: 2px; font-family: var(--mono); font-size: 11px; color: var(--text-4); }
.ai-step-main { display: flex; flex-direction: column; min-width: 0; }
.ai-step-title { font-size: 13.5px; font-weight: 600; line-height: 1.4; letter-spacing: -.005em; transition: color .15s; }
.ai-step-text { margin-top: 4px; font-size: 12.5px; line-height: 1.6; color: var(--text-2); transition: color .15s; }
.ai-step.is-done .ai-step-title { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--text-4); }
.ai-step.is-done .ai-step-text { color: var(--text-3); }

/* ---------- historial del score ---------- */
.ai-history { display: flex; flex-direction: column; }
.ai-history .card-body { flex: 1; display: grid; place-items: center; }
.ai-history .empty { padding: 28px 16px 32px; }
.ai-history-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 18px 18px 18px; }
.ai-history-top .cap { white-space: nowrap; }
.ai-history-score { display: flex; align-items: baseline; margin-top: 9px; font-size: 30px; font-weight: 600; letter-spacing: -.04em; line-height: 1; }
.ai-history-of { margin-left: 3px; font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--text-3); }
.ai-delta { margin-left: 12px; font-size: 12.5px; font-weight: 400; letter-spacing: 0; color: var(--text-3); }
.ai-delta b { font-weight: 600; color: var(--text-2); }
.ai-history-spark { flex: none; }
.ai-history-hint { max-width: 190px; font-size: 12.5px; line-height: 1.5; text-align: right; color: var(--text-3); }
.ai-snaps { border-top: 1px solid var(--line-soft); }
.ai-snap { display: grid; grid-template-columns: minmax(0, 1fr) 52px 60px 28px; align-items: center; gap: 12px; padding: 9px 12px 9px 18px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.ai-snap:last-child { border-bottom: none; }
.ai-snap > :nth-child(2), .ai-snap > :nth-child(3) { text-align: right; }
.ai-snap-head { padding-top: 10px; padding-bottom: 10px; font-size: 10.5px; }
.ai-snap-main { display: flex; flex-direction: column; min-width: 0; }
.ai-snap-sub { margin-top: 1px; font-size: 11.5px; color: var(--text-3); }
.ai-snap-score { font-weight: 600; }
.ai-snap-delta { color: var(--text-2); }
.ai-snap .btn { color: var(--text-3); }
.ai-snap .btn:hover { color: var(--neg); }

/* ---------- preguntas ---------- */
.ai-ask-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 348px;
  grid-template-areas: "thread chips" "composer composer";
  margin-top: 16px;
  border-top: 1px solid var(--line-soft);
}
.ai-thread { grid-area: thread; display: flex; flex-direction: column; gap: 14px; min-width: 0; min-height: 300px; padding: 22px 22px 24px; }
.ai-thread.is-empty { justify-content: center; }
.ai-thread .empty { padding: 20px 16px; }
.ai-msg { display: flex; gap: 12px; min-width: 0; animation: fade-up .35s var(--ease) both; }
.ai-msg-q { justify-content: flex-end; }
.ai-msg-q:not(:first-child) { margin-top: 10px; }
.ai-bubble { max-width: min(520px, 86%); padding: 9px 14px; border: 1px solid var(--line); border-radius: 12px 12px 4px 12px; background: rgba(255, 255, 255, .06); font-size: 13.5px; font-weight: 500; line-height: 1.45; }
.ai-msg-ic { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .03); color: var(--text-2); }
.ai-answer { flex: 0 1 680px; min-width: 0; padding: 14px 16px 12px; border: 1px solid var(--line-soft); border-radius: 4px 12px 12px 12px; background: var(--inset); }
.ai-answer p { margin-top: 9px; font-size: 13.5px; line-height: 1.68; color: var(--text-2); }
.ai-answer p:first-of-type { color: var(--text); }
.ai-answer p b { font-weight: 600; color: var(--text); }
.ai-answer p span { white-space: nowrap; }
.ai-answer-tbl { margin-top: 14px; border: 1px solid var(--line-soft); border-radius: var(--r-md); background: rgba(255, 255, 255, .012); }
.ai-answer-tbl .tbl { table-layout: fixed; }
.ai-answer-tbl .tbl th { padding: 8px 12px; }
.ai-answer-tbl .tbl th:nth-child(n+2) { width: 118px; }
.ai-answer-tbl .tbl th:nth-child(3) { width: 96px; }
.ai-answer-tbl .tbl td { padding: 8px 12px; font-size: 12.5px; }
.ai-answer-tbl .tbl th:first-child, .ai-answer-tbl .tbl td:first-child { padding-left: 14px; }
.ai-answer-tbl .tbl th:last-child, .ai-answer-tbl .tbl td:last-child { padding-right: 14px; }
.ai-answer-label { display: block; }
.ai-th-short { display: none; }
.ai-answer-foot { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; font-size: 12px; line-height: 1.5; color: var(--text-3); }
.ai-small { display: flex; align-items: flex-start; gap: 7px; color: var(--warn); }
.ai-small .ic { flex: none; margin-top: 2px; }

.ai-chips { grid-area: chips; min-width: 0; padding: 20px 18px 22px; border-left: 1px solid var(--line-soft); }
.ai-chip-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.ai-chip {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  min-height: 38px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: rgba(255, 255, 255, .025);
  font-size: 13px; font-weight: 500; line-height: 1.35; color: var(--text-2);
  text-align: left;
  transition: background .14s, border-color .14s, color .14s;
}
.ai-chip .ic { flex: none; color: var(--text-3); transition: color .14s; }
.ai-chip:hover { background: rgba(255, 255, 255, .06); border-color: var(--line-strong); color: var(--text); }
.ai-chip:hover .ic { color: var(--text-2); }
.ai-chip.is-asked { background: transparent; border-color: var(--line-soft); color: var(--text-3); }
.ai-chip.is-asked .ic { color: var(--blue); }

.ai-composer { grid-area: composer; padding: 16px 18px 18px; border-top: 1px solid var(--line-soft); }
.ai-composer-row { display: flex; gap: 8px; }
.ai-composer-field { flex: 1; min-width: 0; }
.ai-composer-field > .affix ~ .input { padding-left: 36px; padding-right: 124px; }
.ai-composer-field .affix { color: var(--text-4); }
.ai-composer-soon { position: absolute; right: 7px; display: inline-flex; pointer-events: none; }
.ai-composer-note { margin-top: 10px; font-size: 12px; line-height: 1.55; color: var(--text-3); }

/* ---------- estado vacío ---------- */
.ai-empty { display: flex; flex-direction: column; align-items: center; padding-bottom: 0; overflow: hidden; }
.ai-empty .empty { padding: 52px 24px 0; }
.ai-empty-progress { width: min(340px, 100% - 48px); margin-top: 26px; }
.ai-empty-progress-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; font-size: 12.5px; color: var(--text-2); }
.ai-empty-progress-top .num { color: var(--text-3); }
.ai-empty-progress-top b { font-size: 15px; font-weight: 600; color: var(--text); }
.ai-empty-left { margin-top: 9px; font-size: 12px; color: var(--text-3); }
.ai-empty-hint { display: flex; align-items: flex-start; gap: 9px; width: min(460px, 100% - 48px); margin-top: 20px; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: rgba(255, 255, 255, .025); font-size: 12.5px; line-height: 1.55; color: var(--text-2); }
.ai-empty-hint .ic { flex: none; margin-top: 2px; color: var(--blue); }
.ai-empty-actions { margin-top: 22px; }
.ai-empty-will { align-self: stretch; margin-top: 44px; padding: 22px 26px 26px; border-top: 1px solid var(--line-soft); }
.ai-empty-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px; margin-top: 16px; }
.ai-feature { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.ai-feature-title { font-size: 13px; font-weight: 600; }
.ai-feature-text { margin-top: 3px; font-size: 12.5px; line-height: 1.55; color: var(--text-3); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .ai-hero { grid-template-columns: minmax(0, 1fr); }
  .ai-pillars { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; padding: 20px 36px 8px; border-left: none; border-top: 1px solid var(--line-soft); }
  .ai-pillars-cap { grid-column: 1 / -1; }
  .ai-pillar { justify-content: flex-start; }
  .ai-pillar:nth-last-child(2) { border-bottom: none; }
  .ai-empty-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* la métrica sube a la línea del título y el texto ocupa todo el ancho */
  .ai-insight { grid-template-areas: "ic title metric" "ic text text"; row-gap: 4px; }
  .ai-insight-main { display: contents; }
  .ai-insight .ai-ic { grid-area: ic; }
  .ai-insight-title { grid-area: title; }
  .ai-insight-text { grid-area: text; margin-top: 0; }
  .ai-insight-metric { grid-area: metric; }
}
@media (max-width: 760px) {
  .ai-ask-body { grid-template-columns: minmax(0, 1fr); grid-template-areas: "thread" "chips" "composer"; }
  .ai-chips { border-left: none; border-top: 1px solid var(--line-soft); }
  .ai-thread { min-height: 0; }
}
@media (max-width: 640px) {
  .ai-hero-top { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 24px; padding: 30px 20px 24px; }
  .ai-hero-text { justify-self: stretch; }
  .ai-headline { font-size: 22px; }
  .ai-hero-foot { padding: 12px 20px 13px; }
  .ai-pillars { grid-template-columns: minmax(0, 1fr); padding: 18px 20px 6px; }
  .ai-pillar:nth-last-child(2) { border-bottom: 1px solid var(--line-soft); }
  .ai-plan .card-head { flex-wrap: wrap; }
  .ai-plan-progress { flex-direction: row; align-items: center; gap: 10px; }
  .ai-step { gap: 12px; }
  .ai-step-num { display: none; }
  .ai-step { grid-template-columns: 20px minmax(0, 1fr); }
  .ai-thread { padding: 18px 14px 20px; }
  .ai-msg-ic { display: none; }
  .ai-answer { flex-basis: auto; width: 100%; padding: 12px 12px 10px; }
  /* en móvil la tabla prescinde del win rate (ya va en el texto) y abrevia la cabecera */
  .ai-answer-tbl .tbl th:nth-child(3), .ai-answer-tbl .tbl td:nth-child(3) { display: none; }
  .ai-answer-tbl .tbl th:nth-child(2) { width: 62px; }
  .ai-answer-tbl .tbl th:nth-child(4) { width: 100px; }
  .ai-answer-tbl .tbl th, .ai-answer-tbl .tbl td { padding-left: 10px; padding-right: 10px; }
  .ai-th-long { display: none; }
  .ai-th-short { display: inline; }
  .ai-history-top { flex-wrap: wrap; }
  .ai-history-hint { max-width: none; text-align: left; }
  .ai-chips, .ai-composer { padding-left: 14px; padding-right: 14px; }
  .ai-composer-field > .affix ~ .input { padding-right: 12px; }
  .ai-composer-soon { display: none; }
  .ai-empty-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .ai-empty-will { padding: 20px 18px 22px; }
}
