:root { color: #1c2430; font: 15px/1.45 "Segoe UI", sans-serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #f4f6f8; color: #1c2430; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 18px; background: #14352c; color: #fff; }
.brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.brand span { color: #9ddeb8; }
.brand small { display: block; font-weight: 500; color: #d5ebe1; letter-spacing: 0; }
header button, .primary { background: #1f8a5b; color: #fff; border: 0; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
button { background: #e7ece9; border: 0; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.menu { max-width: 640px; margin: 48px auto; padding: 0 20px; }
.menu .brand { color: #14352c; }
.menu .brand span { color: #1f8a5b; }
.menu h1 { margin: 8px 0 28px; font-size: 28px; }
.menu section + section { margin-top: 28px; }
.menu h2 { margin: 0 0 12px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: #5d6b76; }
.menu ol { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: simulador; }
.menu li { counter-increment: simulador; }
.menu a { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 16px; background: #fff; border-radius: 12px; text-decoration: none; }
.menu a .nombre::before { content: counter(simulador) ". "; font-weight: 700; }
.menu a span:last-child { color: #5d6b76; }
body:has(.chat-layout), body:has(.report-layout) { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.chat-layout, .report-layout { display: grid; flex: 1; min-height: 0; overflow: hidden; }
.chat-layout { grid-template-columns: 240px 1fr; }
.report-layout { grid-template-columns: minmax(280px, 400px) minmax(0, 1fr); }
.report-layout .chat-side { border-left: 0; border-right: 1px solid #e1e6ea; background: #fff; padding: 12px; }
aside { background: #fff; border-right: 1px solid #e1e6ea; padding: 12px; min-height: 0; overflow: auto; }
.aside-title { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.history-item, .history button.history-open { width: 100%; text-align: left; background: transparent; border-radius: 8px; }
.history-item { display: flex; gap: 4px; align-items: center; }
.history-item.active .history-open { background: #e7f6ee; }
.history-open { flex: 1; padding: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-delete { padding: 4px 8px; }
.workspace, .chat-side, .canvas-wrap { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.workspace { padding: 12px; gap: 8px; }
.setup { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.setup p { margin: 0; flex: 1; min-width: 220px; }
.setup label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.setup input, .setup select, dialog input, dialog select { border: 1px solid #c9d2d8; border-radius: 8px; padding: 8px; background: #fff; }
.workspace > .chat { flex: 1; min-height: 0; }
.messages { background: #fff; border-radius: 12px; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.message { max-width: 90%; }
.message.user { align-self: flex-end; }
.bubble { background: #f3f6f4; border-radius: 12px; padding: 8px 10px; }
.message.user .bubble { background: #e7f6ee; }
.message.error .bubble { background: #fdeCEC; }
.bubble.thinking { color: #5d6b76; }
.bubble table { border-collapse: collapse; width: 100%; }
.bubble th, .bubble td { border: 1px solid #d5dee4; padding: 4px 6px; text-align: left; }
.chat, .chat-side { min-height: 0; display: flex; flex-direction: column; font-size: 12px; }
.messages { flex: 1; min-height: 0; }
.chat-side { border-left: 1px solid #e1e6ea; background: #fff; padding: 12px; }
#message-form { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
textarea { width: 100%; border: 1px solid #c9d2d8; border-radius: 10px; padding: 8px; resize: vertical; }
.composer-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
#imagen-btn { margin-right: auto; }
.adjuntos { display: flex; flex-wrap: wrap; gap: 8px; }
.adjuntos:empty { display: none; }
.adjunto { position: relative; }
.adjunto img, .bubble img { display: block; max-width: 100%; max-height: 160px; border-radius: 8px; object-fit: contain; background: #fff; }
.adjunto img { width: 96px; height: 72px; object-fit: cover; }
.adjunto button { position: absolute; top: 2px; right: 2px; padding: 0 6px; line-height: 18px; }
.notice { color: #8a3b3b; margin: 0; }
.notice:empty { display: none; }
.canvas-wrap { padding: 12px; gap: 8px; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.panel-toggle { padding: 4px 10px; font-size: 12px; white-space: nowrap; }
.panel-toggle[aria-pressed="false"] { background: #14352c; color: #fff; }
.report-layout.sin-historial > aside,
.report-layout.sin-chat > .chat-side { display: none; }
@media (min-width: 981px) {
  .report-layout.sin-historial { grid-template-columns: minmax(0, 1fr) 340px; }
  .report-layout.sin-chat { grid-template-columns: 220px minmax(0, 1fr); }
  .report-layout.sin-historial.sin-chat { grid-template-columns: minmax(0, 1fr); }
}
#lienzo { flex: 1; width: 100%; border: 1px solid #d5dee4; border-radius: 12px; background: #fff; min-height: 480px; }
dialog { border: 0; border-radius: 16px; padding: 18px; width: min(480px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(16, 24, 32, .35); }
.dialog-head, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
dialog label { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; font-size: 13px; }
dialog input, dialog select { width: 100%; }
#conversaciones { width: min(420px, calc(100vw - 24px)); }
#new-chat { width: 100%; }
#history { max-height: min(60vh, 480px); overflow: auto; margin-top: 12px; }
#history:empty::before { content: 'Todavía no hay conversaciones.'; color: #5d6b76; font-size: 13px; }
.stage { flex: 1; min-height: 0; overflow: auto; background: #e6ebef; border-radius: 12px; display: flex; justify-content: center; padding: 16px; }
.stage.sin-encuesta { align-items: center; }
.vacio { display: none; max-width: 360px; margin: 0; text-align: center; color: #40515c; }
.sin-encuesta .vacio { display: block; }
.marco { width: 720px; max-width: 100%; }
.sin-encuesta .marco { display: none; }
.encuesta { background: #fff; min-height: 640px; box-shadow: 0 10px 28px rgba(20, 32, 40, .12); }
.encuesta-barra { display: block; padding: 24px 32px 0; background: transparent; color: inherit; }
.encuesta-barra h1 { margin: 0; padding-bottom: 14px; border-bottom: 1px solid #e3e6e8; font-size: 18px; font-weight: 600; color: #1c2430; }
.encuesta-cuerpo { padding: 28px 32px 40px; color: #1c2430; font-size: 15px; }
.bienvenida { margin: 0 0 28px; }
.pregunta + .pregunta { margin-top: 32px; }
.nota { display: inline-block; margin: 0 0 8px; padding: 3px 10px; border-radius: 999px; background: #fff4d6; color: #6a4b12; font-size: 12px; }
.enunciado { margin: 0 0 12px; }
.opcional { color: #5d6b76; font-style: italic; font-weight: 400; }
.pista { margin: -4px 0 8px; color: #5d6b76; font-size: 12px; }
.leyenda { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 13px; color: #5d6b76; }
.escala { width: max-content; max-width: 100%; margin: 0 auto; }
.nums { display: grid; grid-template-columns: repeat(var(--n, 11), minmax(0, 38px)); gap: 4px; }
.num, .opcion, .combo { font: inherit; }
.num { min-width: 0; height: 34px; padding: 0; border: 1px solid #cfcfcf; border-radius: 4px; background: #fff; color: #1c2430; }
.num.na { font-size: 11px; }
.num.activo, .opcion.activo { background: #d5d5d5; border-color: #b5b5b5; }
.opcion { display: block; width: 100%; text-align: left; margin: 0 0 6px; padding: 10px 12px; border: 1px solid #e3e3e3; border-radius: 2px; background: #f3f3f3; }
.combo, .abierta { width: 100%; border: 1px solid #cfcfcf; border-radius: 4px; background: #fff; }
.combo { padding: 8px; }
.abierta { height: 74px; }
.fila { display: grid; grid-template-columns: minmax(120px, 1fr) auto; gap: 8px; align-items: center; padding: 8px 0; }
.cierre { margin-top: 32px; padding-top: 16px; border-top: 1px solid #ececec; }
.cierre small { display: block; margin-bottom: 6px; color: #5d6b76; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.cierre p { margin: 0; }
.activity { display: flex; gap: 8px; align-items: center; color: #40515c; margin: 8px 0 0; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #1f8a5b; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
body.oficial { height: 100vh; overflow: hidden; background: #f4f6f8; }
.oficial-layout { height: 100vh; display: grid; grid-template-columns: minmax(280px, 400px) minmax(0, 1fr); }
.oficial-layout .chat-side { border-left: 0; border-right: 1px solid #e1e6ea; background: #fff; padding: 12px; }
.oficial-layout .canvas-wrap { padding: 12px; }
@media (max-width: 980px) {
  .chat-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  aside { border-right: 0; border-bottom: 1px solid #e1e6ea; max-height: 180px; }
}
.canvas-wrap { position: relative; }
#chat-toggle, .chat-velo, .chat-cerrar { display: none; }
@media (max-width: 900px) {
  #chat-toggle { display: inline-block; position: absolute; z-index: 5; top: 20px; left: 20px; box-shadow: 0 4px 14px rgba(16, 24, 32, .2); }
  .stage { padding-top: 60px; }
  .report-layout, .oficial-layout { position: relative; grid-template-columns: minmax(0, 1fr); }
  .report-layout .chat-side, .oficial-layout .chat-side { position: absolute; z-index: 20; top: 0; bottom: 0; left: 0; width: min(400px, 88vw); transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; box-shadow: 4px 0 24px rgba(16, 24, 32, .18); }
  .chat-abierto .chat-side { transform: none; visibility: visible; transition: transform .2s ease; }
  .chat-velo { position: absolute; inset: 0; z-index: 10; background: rgba(16, 24, 32, .35); }
  .chat-abierto .chat-velo { display: block; }
  #chat-toggle[aria-expanded="true"] { background: #14352c; }
  .chat-cerrar { display: block; align-self: flex-end; padding: 2px 10px; margin-bottom: 6px; font-size: 18px; line-height: 1.2; }
}
