/* Chat de consulta PoE 1 / PoE 2: botón de acceso flotante y página a pantalla completa (/chat-poe).
   Usa las variables de tema del sitio (/theme.css). En escritorio el chat ocupa el alto de la ventana bajo la cabecera del
   sitio (el pie queda debajo); en móvil ocupa toda la pantalla y se ajusta al teclado (--poe-vh, --poe-vtop: poe-chat-ui.js). */
.poe-launcher { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 70; display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px 10px 12px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--border)); background: var(--surface); color: var(--text); font: 700 .9rem/1 var(--font); text-decoration: none; box-shadow: var(--shadow); cursor: pointer; transition: transform .16s var(--ease), box-shadow .2s; }
.poe-launcher:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -12px var(--accent); }
.poe-launcher:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.poe-launcher .poe-badge { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: .68rem; letter-spacing: .02em; }
@media (max-width: 560px) { .poe-launcher { padding: 8px; } .poe-launcher .poe-launch-text { display: none; } .poe-launcher .poe-badge { width: 36px; height: 36px; font-size: .78rem; } }

/* ---------- página /chat-poe ---------- */
main.tool-chat-poe { padding-top: 12px; padding-bottom: 16px; min-height: 0; }
.poe-page { --poe-read: 880px; position: relative; display: flex; flex-direction: column; height: calc(var(--poe-vh, 100dvh) - var(--poe-top, 64px) - 28px); min-height: 460px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 24px 60px -28px rgba(0,0,0,.55); overflow: hidden; font-family: var(--font); }
/* Columna de lectura: el fondo ocupa todo el ancho y el texto no pasa de --poe-read (líneas cómodas de leer). */
.poe-page .poe-head, .poe-page .poe-log, .poe-page .poe-composer { padding-left: max(16px, calc((100% - var(--poe-read)) / 2)); padding-right: max(16px, calc((100% - var(--poe-read)) / 2)); }

.poe-head { flex: none; display: flex; flex-direction: column; gap: 10px; padding-top: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, var(--surface-2), var(--surface)); }
.poe-head-row { display: flex; align-items: center; gap: 12px; }
.poe-back { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px 8px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 700 .88rem/1 var(--font); cursor: pointer; }
.poe-back:hover { border-color: var(--accent); }
.poe-title { margin: 0; font: 700 1.15rem/1.2 var(--font-head); }
.poe-title:focus { outline: none; }
.poe-sub { margin: 2px 0 0; font-size: .78rem; color: var(--muted); }
.poe-head-text { flex: 1; min-width: 0; }
.poe-icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; flex: none; }
.poe-icon-btn:hover { border-color: var(--accent); }
.poe-back:focus-visible, .poe-icon-btn:focus-visible, .poe-switch button:focus-visible, .poe-chip:focus-visible, .poe-jump:focus-visible, .poe-retry:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.poe-head-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.poe-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); min-width: 200px; }
.poe-switch button { padding: 9px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 700 .9rem/1 var(--font); cursor: pointer; }
.poe-switch button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.poe-body { position: relative; flex: 1; min-height: 0; display: flex; }
.poe-log { flex: 1; min-width: 0; overflow-y: auto; padding-top: 18px; padding-bottom: 18px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.poe-log:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.poe-jump { position: absolute; right: 18px; bottom: 14px; display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border)); background: var(--surface); color: var(--text); font: 700 .84rem/1 var(--font); box-shadow: var(--shadow); cursor: pointer; }
.poe-jump[hidden] { display: none; }

.poe-empty { margin: auto 0; padding: 18px; border: 1px dashed var(--border); border-radius: 14px; color: var(--muted); font-size: .95rem; line-height: 1.55; }
.poe-empty p { margin: 0; }
.poe-empty-title { color: var(--text); font: 700 1.05rem/1.3 var(--font-head); margin-bottom: 6px !important; }
.poe-msg { max-width: 100%; font-size: .97rem; line-height: 1.6; overflow-wrap: anywhere; }
.poe-msg-user { align-self: flex-end; max-width: min(78%, 640px); padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: var(--accent); color: var(--on-accent); white-space: pre-wrap; }
.poe-msg-bot { align-self: stretch; padding: 14px 16px; border-radius: 16px 16px 16px 4px; background: var(--surface-2); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.poe-msg-bot p { margin: 0; }
.poe-msg-bot h3 { margin: 4px 0 0; font: 700 1.04rem/1.3 var(--font-head); }
.poe-msg-bot h3:first-child { margin-top: 0; }
.poe-msg-bot ul { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 4px; }
.poe-kv { display: flex; flex-direction: column; margin: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; font-size: .92rem; }
.poe-kv-row { display: grid; grid-template-columns: minmax(140px, 30%) 1fr; gap: 12px; padding: 7px 12px; }
.poe-kv-row + .poe-kv-row { border-top: 1px solid var(--border); }
.poe-kv dt { color: var(--muted); }
.poe-kv dd { margin: 0; min-width: 0; }
.poe-ai { padding: 10px 12px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--accent-soft); display: flex; flex-direction: column; gap: 4px; }
.poe-ai-label { font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.poe-ai-wait { margin: 0; min-height: 1.2em; }
.poe-dots::after { content: "…"; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; color: var(--muted); font-size: 1.1rem; animation: poe-dots 1.2s steps(3, end) infinite; }
.poe-note { padding: 8px 12px; border-radius: 10px; background: var(--accent-2-soft); font-size: .88rem; }
.poe-price { padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); font-size: .92rem; }
.poe-price strong { display: block; margin-bottom: 3px; }
.poe-price ul { list-style: none; padding: 0; }
/* Tarjetas de guías y vídeos: rejilla de dos columnas cuando hay ancho. */
.poe-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 10px; }
.poe-links { display: flex; flex-direction: column; gap: 8px; }
.poe-card { padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.poe-card h4 { margin: 0; font-size: .97rem; line-height: 1.3; }
.poe-card-video { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.poe-card.poe-card-link { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; font-size: .9rem; }
.poe-card.poe-card-link .btn { flex: none; }
.poe-link-label { min-width: 0; }
.poe-kind { align-self: flex-start; padding: 2px 8px; border-radius: 999px; font-size: .7rem; font-weight: 700; letter-spacing: .02em; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.poe-card-video .poe-kind { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--text); }
.poe-card-meta { margin: 0; font-size: .82rem; color: var(--muted); }
.poe-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.poe-tag { padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); font-size: .74rem; color: var(--muted); }
.poe-warn { font-size: .82rem; color: var(--text); padding-left: 8px; border-left: 3px solid var(--accent-2); }
.poe-card-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: auto; }
.poe-card-actions .btn, .poe-card-link .btn, .poe-retry { padding: .5rem .9rem; font-size: .86rem; display: inline-flex; align-items: center; gap: 6px; }
.poe-verified { font-size: .74rem; color: var(--muted); }
.poe-sources { border-top: 1px dashed var(--border); padding-top: 8px; font-size: .84rem; }
.poe-sources strong { color: var(--muted); font-weight: 600; }
.poe-sources ul { list-style: none; padding: 0; margin-top: 4px; }
.poe-sources a, .poe-msg-bot a:not(.btn) { color: var(--text); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 70%, transparent); text-underline-offset: 2px; }
.poe-typing { align-self: flex-start; font-size: .9rem; color: var(--muted); padding: 6px 2px; }
.poe-typing::after { content: "…"; animation: poe-dots 1.2s steps(3, end) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes poe-dots { from { width: 0; } to { width: 1.2em; } }
.poe-error { align-self: stretch; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--accent-2); font-size: .92rem; }

.poe-composer { flex: none; border-top: 1px solid var(--border); background: var(--surface); padding-top: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
/* Sugerencias: hasta dos líneas que se ajustan al ancho (sin barra de desplazamiento horizontal). */
.poe-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; max-height: 70px; overflow: hidden; }
.poe-suggest:empty { display: none; }
.poe-chip { flex: none; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: 600 .82rem/1.1 var(--font); cursor: pointer; white-space: nowrap; }
.poe-chip:hover { border-color: var(--accent); }
.poe-form { display: flex; gap: 10px; align-items: flex-end; }
.poe-input { flex: 1; min-width: 0; resize: none; min-height: 52px; max-height: 200px; overflow-y: hidden; scrollbar-width: thin; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: 1rem/1.45 var(--font); }
.poe-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.poe-send { flex: none; min-width: 52px; min-height: 52px; }
.poe-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding-top: 6px; font-size: .76rem; color: var(--muted); }
.poe-enter { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.poe-enter input { width: 16px; height: 16px; accent-color: var(--accent); }
.poe-help { flex: 1; min-width: 0; }
.poe-count.over { color: var(--accent-2); font-weight: 700; }
.poe-disclaimer { margin: 4px 0 0; font-size: .72rem; color: var(--muted); }
.poe-disclaimer summary { cursor: pointer; list-style: none; }
.poe-disclaimer summary::-webkit-details-marker { display: none; }
.poe-disclaimer .poe-legal-more { text-decoration: underline; text-underline-offset: 2px; }
.poe-disclaimer ul { margin: 6px 0 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 3px; }
.poe-disclaimer a, .poe-credits a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
/* Procedencia y licencias de una respuesta: plegadas y en pequeño, al pie de la respuesta. */
.poe-credits { font-size: .76rem; color: var(--muted); }
.poe-credits summary { cursor: pointer; width: fit-content; }
.poe-credits summary:focus-visible, .poe-disclaimer summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.poe-credits ul { margin: 4px 0 0; padding-left: 1.1rem; gap: 2px; }

/* «Analizar mi build»: panel desplegable sobre la conversación. */
.poe-an-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: inherit; font: inherit; font-size: .88rem; cursor: pointer; }
.poe-an-toggle[aria-expanded="true"] { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.poe-an-toggle:focus-visible, .poe-an input:focus-visible, .poe-an select:focus-visible, .poe-an textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.poe-an { flex: none; padding: 12px max(16px, calc((100% - 880px) / 2)); border-top: 1px solid var(--border); max-height: 50%; overflow-y: auto; background: var(--surface-2); }
.poe-an[hidden] { display: none; }
.poe-an-help { margin: 0 0 8px; font-size: .86rem; opacity: .85; }
.poe-an-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 8px; }
.poe-an-field { display: flex; flex-direction: column; gap: 3px; font-size: .82rem; min-width: 0; }
.poe-an-field input, .poe-an-field select, .poe-an-field textarea { width: 100%; box-sizing: border-box; min-height: 38px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: inherit; font: inherit; font-size: .92rem; }
.poe-an-field textarea { resize: vertical; margin-top: 8px; }
.poe-an-pair { display: flex; gap: 6px; }
.poe-an-pair input { flex: 1 1 60%; min-width: 0; }
.poe-an-pair select { flex: 1 1 40%; min-width: 0; }
.poe-an-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- móvil: pantalla completa real, ajustada al teclado virtual ---------- */
@media (max-width: 719px) {
  body.poe-chat-page { overflow: hidden; }
  main.tool-chat-poe { padding: 0; }
  .poe-page { position: fixed; left: 0; right: 0; top: var(--poe-vtop, 0px); height: var(--poe-vh, 100dvh); min-height: 0; z-index: 80; border: 0; border-radius: 0; box-shadow: none; }
  .poe-head { padding-top: max(10px, env(safe-area-inset-top)); gap: 8px; }
  .poe-back { padding: 8px 12px 8px 8px; }
  .poe-title { font-size: 1.02rem; }
  .poe-switch { min-width: 0; flex: 1; }
  .poe-msg { font-size: .95rem; }
  .poe-msg-user { max-width: 88%; }
  .poe-msg-bot { padding: 12px; }
  .poe-kv-row { grid-template-columns: 1fr; gap: 2px; }
  .poe-card.poe-card-link { flex-direction: column; align-items: stretch; }
  .poe-input { min-height: 46px; font-size: 16px; } /* 16 px: iOS no hace zoom al enfocar */
  .poe-send { min-width: 46px; min-height: 46px; }
  .poe-help { display: none; }
  /* (La información y licencias sigue accesible en móvil, plegada y en una línea.) */
  .poe-disclaimer > summary { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .poe-disclaimer:not([open]) > summary > span:first-child { display: none; }
  .poe-jump { right: 12px; bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) { .poe-launcher { transition: none; } .poe-launcher:hover { transform: none; } .poe-typing::after, .poe-dots::after { animation: none; width: auto; } }
@media print { .poe-launcher { display: none !important; } .poe-page { position: static; height: auto; overflow: visible; } .poe-composer, .poe-head-tools { display: none; } .poe-log { overflow: visible; } }

/* Icono oficial de la entidad (enlazado al CDN de GGG) o marcador neutro si falta. */
.poe-icon { width: 48px; height: 48px; object-fit: contain; align-self: flex-start; border-radius: 8px; background: var(--surface-3, rgba(255,255,255,.04)); border: 1px solid var(--border); }
.poe-icon-fallback { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; color: var(--muted, #9aa0b4); }
