/* IA del Centro Producción del Espacio — hoja de estilos (identidad de cpe-udla.org: blanco y negro, Jost,
   esquinas rectas, bordes de 1 px, etiquetas en mayúsculas espaciadas e inversión a negro al pasar el cursor) */
@font-face { font-family: "Jost"; font-style: normal; font-weight: 300 600; font-display: swap;
  src: url("/static/fonts/jost-latin.woff2") format("woff2"); }
@font-face { font-family: "Jost"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("/static/fonts/jost-latin-italic.woff2") format("woff2"); }

:root {
  --paper: #ffffff; --ink: #0b0b0b; --gray: #6f6f6f; --line: #dcdcdc; --soft: #f4f4f4;
  --sidebar-w: 300px;
  --font: "Jost", "Futura", "Futura PT", "Century Gothic", "Avenir Next", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  --logo-filter: none;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #0b0b0b; --ink: #f2f2f2; --gray: #9c9c9c; --line: #2e2e2e; --soft: #161616;
    --logo-filter: invert(1); color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 16px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--ink); }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- etiquetas y botones ---------- */
.kicker, .side-label { text-transform: uppercase; letter-spacing: .14em; font-size: .7rem; color: var(--gray); }
.label-block { display: inline-block; background: var(--ink); color: var(--paper); text-transform: uppercase;
  letter-spacing: .1em; font-size: .9rem; font-weight: 600; padding: 4px 10px; margin: 0; }
.primary, .ghost, .navlink {
  border-radius: 0; text-transform: uppercase; letter-spacing: .09em; font-size: .78rem; font-weight: 500;
  padding: .55rem .9rem; transition: background .12s ease, color .12s ease; }
.primary { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.primary:hover:not(:disabled) { background: var(--paper); color: var(--ink); }
.primary:disabled { opacity: .35; cursor: default; }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--ink); text-decoration: none; display: inline-block; }
.ghost:hover, .ghost:focus-visible { background: var(--ink); color: var(--paper); }
.badge { display: inline-block; background: var(--ink); color: var(--paper); text-transform: uppercase;
  letter-spacing: .1em; font-size: .64rem; padding: 2px 7px; }

/* ---------- barra lateral ---------- */
.layout { height: 100%; display: flex; }
.sidebar { width: var(--sidebar-w); flex: none; height: 100%; overflow-y: auto; scrollbar-width: thin;
  border-right: 1px solid var(--ink); padding: 28px 24px 24px; display: flex; flex-direction: column; gap: 26px;
  background: var(--paper); z-index: 20; }
.brand img { width: 100%; max-width: 210px; filter: var(--logo-filter); }
.nav { display: flex; flex-direction: column; }
.nav form { margin: 0; }
.navlink, .nav a { display: block; width: calc(100% + 16px); text-align: left; text-decoration: none; background: none;
  border: 0; color: var(--ink); margin: 2px -8px; padding: 7px 8px; text-transform: uppercase; letter-spacing: .09em;
  font-size: .82rem; font-weight: 500; }
.navlink:hover, .navlink:focus-visible, .nav a:hover, .nav a:focus-visible, .nav a.on, .nav a.active {
  background: var(--ink); color: var(--paper); outline: none; }
.side-block { border-top: 1px solid var(--line); padding-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.side-text { font-size: .78rem; line-height: 1.5; color: var(--gray); margin: 0; }
.side-model { font: .72rem/1.4 var(--mono); color: var(--gray); }
.side-meta { margin-top: auto; display: flex; align-items: center; gap: 14px; padding-top: 10px; }
.side-meta img { height: 44px; width: auto; filter: var(--logo-filter); }
.side-meta img.udla { height: 24px; }
.menu-toggle { display: none; }
.scrim { display: none; }

/* ---------- columna principal del chat ---------- */
.app { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; }
.topbar { display: none; }
main { flex: 1; overflow-y: auto; }
.thread { max-width: 50rem; margin: 0 auto; padding: 48px clamp(16px, 4vw, 48px) 32px; }

/* portada (conversación vacía) */
.empty { padding-top: 2vh; }
.hero h1 { font-size: clamp(2rem, 4.2vw, 3.2rem); font-weight: 500; line-height: 1.15; letter-spacing: .01em;
  margin: 12px 0 0; text-wrap: balance; }
.hero .sub { margin: 18px 0 0; max-width: 52ch; color: var(--gray); font-style: italic; }
.explore { margin-top: 44px; }
.explore .label-block { margin-bottom: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card { border: 1px solid var(--ink); background: var(--paper); color: var(--ink); padding: 16px 16px 18px; min-height: 150px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 12px; text-align: left;
  border-radius: 0; transition: background .12s ease, color .12s ease; }
.card .tag { text-transform: uppercase; letter-spacing: .12em; font-size: .64rem; color: var(--gray); }
.card .t { font-size: .95rem; font-weight: 500; line-height: 1.35; text-transform: uppercase; letter-spacing: .03em; }
.card .meta { font-size: .8rem; color: var(--gray); line-height: 1.45; }
button.card { cursor: pointer; }
button.card:hover, button.card:focus-visible { background: var(--ink); color: var(--paper); outline: none; }
button.card:hover .tag, button.card:hover .meta, button.card:focus-visible .tag, button.card:focus-visible .meta { color: var(--paper); }
.formats { margin-top: 26px; font-size: .8rem; color: var(--gray); max-width: 70ch; }

/* mensajes */
.msg { margin: 0 0 30px; }
.msg.user { border: 1px solid var(--ink); padding: 12px 16px 14px; margin-left: clamp(1rem, 12%, 6rem); white-space: pre-wrap; }
.msg.user::before { content: "Pregunta"; display: block; white-space: normal; text-transform: uppercase;
  letter-spacing: .14em; font-size: .62rem; color: var(--gray); margin-bottom: 6px; }
.msg.user .files { font-size: .78rem; color: var(--gray); margin-top: 8px; }
.msg.bot .body { font-size: 1.02rem; line-height: 1.68; overflow-wrap: anywhere; }
.msg.bot .body > :first-child { margin-top: 0; }
.msg.bot .body :is(p, ul, ol, pre, table, blockquote) { margin: 0 0 1rem; }
.msg.bot .body h1 { font-size: 1.5rem; font-weight: 500; line-height: 1.25; margin: 1.4rem 0 .8rem; }
.msg.bot .body h2 { display: inline-block; background: var(--ink); color: var(--paper); text-transform: uppercase;
  letter-spacing: .1em; font-size: .86rem; font-weight: 600; padding: 4px 10px; margin: 1.6rem 0 .9rem; }
.msg.bot .body h3, .msg.bot .body h4 { text-transform: uppercase; letter-spacing: .06em; font-size: .9rem; font-weight: 600;
  margin: 1.3rem 0 .5rem; }
.msg.bot .body a { color: var(--ink); text-underline-offset: 2px; }
.msg.bot .body strong { font-weight: 600; }
.msg.bot .body blockquote { border-left: 3px solid var(--ink); margin-left: 0; padding-left: 14px; color: var(--gray); font-style: italic; }
.msg.bot .body hr { border: 0; border-top: 1px solid var(--line); margin: 1.4rem 0; }
.msg.bot .body pre { background: var(--soft); border: 1px solid var(--line); padding: 12px; overflow-x: auto; font-size: .84rem; }
.msg.bot .body code { font-family: var(--mono); font-size: .88em; }
.msg.bot .body table { border-collapse: collapse; display: block; overflow-x: auto; font-size: .9rem; line-height: 1.4; }
.msg.bot .body th, .msg.bot .body td { border: 1px solid var(--ink); padding: 6px 10px; text-align: left; vertical-align: top; }
.msg.bot .body th { text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; font-weight: 600; background: var(--soft); }
.msg.bot .status { color: var(--gray); font-style: italic; }
.msg.bot .err { border-left: 3px solid var(--ink); padding-left: 12px; }

/* pasos de la investigación: como la terminal del sitio */
.steps { list-style: none; margin: 0 0 14px; padding: 10px 12px; background: var(--soft); border-left: 3px solid var(--ink);
  color: var(--gray); font: .74rem/1.6 var(--mono); }
.steps:empty { display: none; }
.steps li::before { content: ">_ "; color: var(--ink); }

/* pie de la respuesta */
.msg.bot .foot { display: flex; gap: 8px 14px; flex-wrap: wrap; align-items: center; color: var(--gray);
  font-size: .76rem; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.msg.bot .foot button { background: none; border: 1px solid var(--line); color: var(--ink); padding: 3px 8px; border-radius: 0;
  text-transform: uppercase; letter-spacing: .08em; font-size: .66rem; }
.msg.bot .foot button:hover, .msg.bot .foot button:focus-visible { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.msg.bot .foot .warn { flex-basis: 100%; color: var(--ink); border-left: 3px solid var(--ink); padding: 2px 0 2px 10px; }
.fb { display: inline-flex; gap: 6px; }
.sources { flex-basis: 100%; }
.sources a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.sources a:hover { border-color: var(--ink); }
.filelink { color: var(--ink); font-weight: 600; text-decoration: none; text-transform: uppercase; letter-spacing: .08em;
  font-size: .7rem; border: 1px solid var(--ink); padding: 3px 8px; }
.filelink:hover { background: var(--ink); color: var(--paper); }
.filelink::before { content: "↓ "; }

/* evidencia trazable: citas que se pueden pulsar, panel de evidencia y confianza */
.msg.bot .body button.cite { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer;
  border-bottom: 1px dotted var(--ink); }
.msg.bot .body button.cite:hover, .msg.bot .body button.cite:focus-visible { background: var(--ink); color: var(--paper); outline: none; }
.evidence { flex-basis: 100%; border: 1px solid var(--ink); }
.evidence summary { cursor: pointer; padding: 6px 10px; text-transform: uppercase; letter-spacing: .1em; font-size: .68rem;
  font-weight: 600; color: var(--ink); list-style-position: inside; }
.evidence[open] summary { border-bottom: 1px solid var(--line); }
.evidence ol { list-style: none; margin: 0; padding: 0; max-height: 26rem; overflow-y: auto; }
.evidence li { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--ink); font-size: .8rem; line-height: 1.45; }
.evidence li:last-child { border-bottom: 0; }
.evidence li.on { background: var(--soft); box-shadow: inset 3px 0 0 var(--ink); }
.evidence .ev-head a { color: var(--ink); }
.ev-tag { display: inline-block; background: var(--ink); color: var(--paper); text-transform: uppercase; letter-spacing: .08em;
  font-size: .58rem; padding: 1px 6px; vertical-align: 1px; }
.evidence blockquote { margin: 6px 0 0; padding-left: 10px; border-left: 2px solid var(--line); color: var(--gray); font-style: italic; }
.conf { display: inline-block; margin-left: 8px; padding: 1px 7px; font-size: .6rem; letter-spacing: .1em; border: 1px solid var(--ink); }
.conf.alta { background: var(--ink); color: var(--paper); }
.conf.baja { border-style: dashed; }
.conf-why { margin: 0; padding: 8px 12px; font-size: .74rem; color: var(--gray); border-bottom: 1px solid var(--line); }

/* ---------- caja de escritura ---------- */
.composer { border-top: 1px solid var(--ink); background: var(--paper); padding: 14px clamp(16px, 4vw, 48px) 14px; }
.composer .inner { max-width: 50rem; margin: 0 auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--ink); padding: 2px 4px 2px 10px;
  font-size: .78rem; max-width: 100%; }
.chip .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14rem; }
.chip .s { color: var(--gray); }
.chip.bad { border-style: dashed; }
.chip button { border: 0; background: none; color: var(--gray); font-size: 1rem; line-height: 1; padding: 0 4px; }
.chip button:hover { color: var(--ink); }
.row { display: flex; gap: 8px; align-items: stretch; }
textarea { flex: 1; min-width: 0; resize: none; padding: 10px 12px; border: 1px solid var(--ink); border-radius: 0; background: var(--paper);
  max-height: 40vh; line-height: 1.5; }
textarea::placeholder { color: var(--gray); }
.modebar { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-top: 10px; font-size: .74rem;
  text-transform: uppercase; letter-spacing: .08em; }
.modebar select { padding: 3px 6px; border: 1px solid var(--ink); border-radius: 0; background: var(--paper);
  text-transform: none; letter-spacing: 0; font-size: .82rem; margin-left: 6px; }
.webtoggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.webtoggle input { accent-color: var(--ink); width: 14px; height: 14px; margin: 0; }
.hint { color: var(--gray); font-size: .72rem; margin-top: 8px; line-height: 1.45; }
body.drag main { outline: 2px dashed var(--ink); outline-offset: -10px; }

/* ---------- ingreso ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 32px 16px; }
.login form { width: min(24rem, 100%); border: 1px solid var(--ink); padding: 32px 28px 28px; background: var(--paper); }
.login .brand img { max-width: 170px; margin-bottom: 26px; }
.login h1 { font-size: 1.6rem; font-weight: 500; line-height: 1.2; margin: 8px 0 24px; }
.login label { display: block; text-transform: uppercase; letter-spacing: .1em; font-size: .7rem; color: var(--gray); margin-bottom: 6px; }
.login input { width: 100%; padding: 10px 12px; border: 1px solid var(--ink); border-radius: 0; background: var(--paper); }
.login button { margin-top: 16px; width: 100%; }
.login .side-meta { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.error { border-left: 3px solid var(--ink); padding-left: 10px; font-size: .88rem; margin: 14px 0 0; }
.fine { color: var(--gray); font-size: .76rem; line-height: 1.5; margin: 18px 0 0; }

/* ---------- paneles: base y temas, registro, ingreso ---------- */
.report { max-width: 72rem; }
.report h2 { display: table; background: var(--ink); color: var(--paper); text-transform: uppercase; letter-spacing: .1em;
  font-size: .9rem; font-weight: 600; padding: 4px 10px; margin: 44px 0 16px; }
.report > h2:first-child, .report > :first-child h2:first-child { margin-top: 0; }
.report h3 { text-transform: uppercase; letter-spacing: .06em; font-size: .9rem; font-weight: 600; margin: 22px 0 8px; }
.report .muted, .muted { color: var(--gray); font-size: .88rem; }
.report .warn, .warn { color: var(--ink); font-size: .88rem; }
.report a { color: var(--ink); text-underline-offset: 2px; }
.report a.ghost, .report a.primary { text-decoration: none; }
.scroll { overflow-x: auto; }
.report table { border-collapse: collapse; font-size: .88rem; min-width: 100%; }
.report th, .report td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: right; white-space: nowrap; }
.report th[scope=row], .report thead th:first-child { text-align: left; }
.report thead th { text-transform: uppercase; letter-spacing: .08em; font-size: .68rem; font-weight: 600; color: var(--gray);
  border-bottom: 1px solid var(--ink); }
.report ul { padding-left: 1.2rem; }
.report table.data { width: 100%; font-size: .85rem; }
.report table.data td, .report table.data th { text-align: left; white-space: normal; vertical-align: top; }
.report form.inline { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.report .card { display: block; min-height: 0; border: 1px solid var(--ink); padding: 16px 18px; margin: 14px 0; }
.report .grid { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 10px 16px; }
.report label.f { display: flex; flex-direction: column; gap: 4px; text-transform: uppercase; letter-spacing: .08em;
  font-size: .66rem; color: var(--gray); }
.report input[type=text], .report input[type=date], .report input[type=file], .report select, .report textarea {
  font-size: .9rem; padding: 7px 9px; border: 1px solid var(--ink); border-radius: 0; background: var(--paper); width: 100%;
  text-transform: none; letter-spacing: 0; color: var(--ink); }
.report form.inline :is(input, select) { width: auto; }
.report input[type=file] { padding: 6px; }
::file-selector-button { font: inherit; text-transform: uppercase; letter-spacing: .08em; font-size: .7rem; border: 1px solid var(--ink);
  border-radius: 0; background: var(--paper); color: var(--ink); padding: 5px 10px; margin-right: 10px; cursor: pointer; }
::file-selector-button:hover { background: var(--ink); color: var(--paper); }
.report textarea { min-height: 4.5rem; resize: vertical; }
.report .btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.report .pill { font-size: .62rem; text-transform: uppercase; letter-spacing: .1em; border: 1px solid var(--ink); padding: 1px 6px;
  white-space: nowrap; }
.report .pill.warn { background: var(--ink); color: var(--paper); }
.report .metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 10px 0 22px; }
.report .metric { border: 1px solid var(--ink); padding: 14px 14px 12px; }
.report .metric b { display: block; font-size: 1.7rem; font-weight: 600; line-height: 1.1; }
.report .metric span { display: block; margin-top: 6px; font-size: .68rem; line-height: 1.4; text-transform: uppercase;
  letter-spacing: .1em; color: var(--gray); }
.report .notice { border-left: 3px solid var(--ink); background: var(--soft); padding: 10px 14px; font-size: .88rem; }

/* ---------- pantallas angostas: el menú lateral se pliega ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: none; width: min(var(--sidebar-w), 86vw); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 15; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px;
    border-bottom: 1px solid var(--ink); background: var(--paper); }
  .topbar .mini { display: flex; align-items: center; gap: 10px; text-decoration: none; text-transform: uppercase;
    letter-spacing: .1em; font-size: .74rem; font-weight: 500; min-width: 0; }
  .topbar .mini img { height: 28px; width: auto; filter: var(--logo-filter); }
  .topbar .mini span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .menu-toggle { display: inline-block; }
  .panel-tabs { display: flex; gap: 2px; overflow-x: auto; }
  .panel-tabs a { text-decoration: none; text-transform: uppercase; letter-spacing: .08em; font-size: .68rem; font-weight: 500;
    padding: 5px 8px; white-space: nowrap; }
  .panel-tabs a.on, .panel-tabs a:hover { background: var(--ink); color: var(--paper); }
  .thread { padding-top: 28px; }
  .msg.user { margin-left: 1rem; }
}
@media (max-width: 600px) {
  .row { flex-wrap: wrap; }
  .row textarea { order: -1; flex-basis: 100%; min-width: 0; }
  .row #send { flex: 1; }
  .composer { padding: 10px 12px 12px; }
  .msg.user { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
