:root {
  --ink: #1a1a1a;
  --ink-soft: #3a3a3a;
  --ink-faint: #6a6a6a;
  --paper: #fbfbf8;
  --line: #e2e0d8;
  --accent: #8b1a1a;
  --q1: #1b5e20; --q2: #2e6da4; --q3: #b06000; --q4: #8b1a1a; --d1: #b8860b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { font-family: 'Source Serif 4', Georgia, serif; font-weight: 700; }

/* ---------- Masthead ---------- */
.masthead {
  background: #fff;
  border-bottom: 2px solid var(--ink);
  padding: 0;
}
.masthead-inner {
  max-width: 1320px; margin: 0 auto; padding: 18px 32px 0 32px;
  display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { background:#f3f1ea; border-radius: 10px; padding: 6px; display:flex; }
.brand-title { font-size: 2rem; letter-spacing: -0.5px; line-height: 1; }
.brand-sub { font-family:'Inter'; font-size: 0.82rem; color: var(--ink-faint); margin-top: 3px; }
.tabs { display: flex; gap: 4px; }
.tab {
  font-family:'Inter'; font-size: 0.9rem; font-weight: 500;
  background: none; border: none; padding: 10px 18px; cursor: pointer;
  color: var(--ink-faint); border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all .15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.affil {
  max-width: 1320px; margin: 0 auto; padding: 8px 32px 12px 32px;
  font-size: 0.74rem; color: var(--ink-faint); letter-spacing: 0.2px;
}

/* ---------- Layout ---------- */
.container { max-width: 1320px; margin: 0 auto; padding: 28px 32px 60px 32px; }
.view { display: none; }
.view.active { display: block; }

/* ---------- Library ---------- */
.library-layout { display: grid; grid-template-columns: 250px 1fr; gap: 36px; }
.filters { position: sticky; top: 20px; align-self: start; }
.filter-group { margin-bottom: 22px; }
.filter-group label {
  display: block; font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--ink-faint); margin-bottom: 8px;
}
#search {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px;
  font-family:'Inter'; font-size: 0.88rem; background: #fff;
}
#search:focus { outline: none; border-color: var(--ink); }
.year-range { font-size: 0.82rem; color: var(--ink-soft); margin-bottom: 6px; font-weight:500; }
input[type="range"] { width: 100%; accent-color: var(--ink); }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-family:'Inter'; font-size: 0.78rem; font-weight: 600; padding: 5px 12px;
  border: 1px solid var(--line); border-radius: 20px; background:#fff; cursor: pointer;
  color: var(--ink-soft); transition: all .12s;
}
.chip:hover { border-color: var(--ink); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.topic-list { display: flex; flex-direction: column; gap: 2px; max-height: 280px; overflow-y: auto; }
.topic-item {
  font-size: 0.82rem; padding: 5px 8px; border-radius: 5px; cursor: pointer;
  display: flex; justify-content: space-between; color: var(--ink-soft); transition: background .1s;
}
.topic-item:hover { background: #f0eee6; }
.topic-item.active { background: var(--ink); color: #fff; }
.topic-item .tc { color: var(--ink-faint); font-size: 0.76rem; }
.topic-item.active .tc { color: #ccc; }
.toggles { display: flex; flex-direction: column; gap: 10px; }
.toggle { font-size: 0.84rem; color: var(--ink-soft); cursor: pointer; display:flex; align-items:center; gap:7px; font-weight:400;text-transform:none;letter-spacing:0; }
.reset-btn {
  width: 100%; padding: 9px; border: 1px solid var(--line); background:#fff; border-radius: 6px;
  font-family:'Inter'; font-size: 0.82rem; cursor: pointer; color: var(--ink-soft);
}
.reset-btn:hover { border-color: var(--ink); }

.results-head {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 12px; border-bottom: 2px solid var(--ink); margin-bottom: 4px;
}
#result-count { font-size: 0.86rem; color: var(--ink-soft); font-weight: 500; }
#sort { font-family:'Inter'; font-size: 0.84rem; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background:#fff; cursor:pointer; }

/* ---------- Article card ---------- */
.article {
  padding: 18px 4px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .1s;
}
.article:hover { background: #f6f4ec; }
.article-title { font-family:'Source Serif 4'; font-size: 1.12rem; font-weight: 600; line-height: 1.35; color: var(--ink); margin-bottom: 5px; }
.article-authors { font-size: 0.83rem; color: var(--ink-soft); margin-bottom: 6px; }
.article-meta { font-size: 0.8rem; color: var(--ink-faint); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.article-journal { font-style: italic; color: var(--ink-soft); }
.pill { display:inline-block; padding: 1px 8px; border-radius: 3px; font-size: 0.7rem; font-weight: 700; color:#fff; letter-spacing:0.3px; }
.pill.q1{background:var(--q1)} .pill.q2{background:var(--q2)} .pill.q3{background:var(--q3)} .pill.q4{background:var(--q4)} .pill.d1{background:var(--d1)}
.pill.oa{ background:#e7f3ea; color:var(--q1); border:1px solid #cce5d3; }
.pill.topic{ background:#f0eee6; color:var(--ink-soft); font-weight:500; border:1px solid var(--line); }

/* ---------- Detail modal ---------- */
.modal { display: none; position: fixed; inset: 0; background: rgba(20,18,14,0.5); z-index: 100; padding: 30px; }
.modal.open { display: flex; align-items: flex-start; justify-content: center; }
.modal-content {
  background: #fff; border-radius: 10px; max-width: 1200px; width: 100%; max-height: 92vh;
  overflow-y: auto; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-close {
  position: absolute; top: 14px; right: 18px; font-size: 1.8rem; background:none; border:none;
  cursor: pointer; color: var(--ink-faint); line-height: 1; z-index: 2;
}
.modal-close:hover { color: var(--ink); }
.detail { display: grid; grid-template-columns: 1fr 6px 1fr; gap: 0; }
.detail-info { padding: 32px; border-right: 1px solid var(--line); }
.detail-pdf { padding: 0; background: #f3f1ea; min-height: 600px; }
.detail-pdf iframe { width: 100%; height: 100%; min-height: 92vh; border: none; }
.detail-pdf .nopdf { padding: 40px; text-align: center; color: var(--ink-faint); }
.detail-divider { background: var(--line); cursor: col-resize; touch-action: none; position: relative; transition: background .1s; }
.detail-divider:hover { background: var(--accent); }
.detail-divider::after { content: '⋮'; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); color: var(--ink-faint); font-size: 14px; }
.detail-divider:hover::after { color: #fff; }
.detail h2 { font-size: 1.5rem; line-height: 1.3; margin-bottom: 12px; }
.detail-authors { font-size: 0.88rem; color: var(--ink-soft); margin-bottom: 16px; line-height: 1.5; }
.detail-line { font-size: 0.88rem; margin-bottom: 8px; color: var(--ink-soft); }
.detail-line b { color: var(--ink); }
.detail-line a { color: var(--accent); text-decoration: none; }
.detail-line a:hover { text-decoration: underline; }
.detail-pills { margin: 14px 0; display: flex; gap: 5px; flex-wrap: wrap; }
.detail-abstract { margin-top: 18px; }
.detail-abstract h4 { font-size: 0.95rem; margin-bottom: 8px; }
.detail-abstract p { font-size: 0.9rem; line-height: 1.65; color: var(--ink-soft); text-align: justify; }
.d1-flag { color: var(--d1); font-weight: 600; }

/* ---------- Stats ---------- */
.metrics-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 16px; margin-bottom: 30px; }
.metric { background:#fff; border:1px solid var(--line); border-radius: 8px; padding: 18px 20px; }
.metric .val { font-family:'Source Serif 4'; font-size: 2rem; font-weight: 700; color: var(--ink); }
.metric .lbl { font-size: 0.78rem; color: var(--ink-faint); margin-top: 2px; }
.metric .sub { font-size: 0.75rem; color: var(--accent); font-weight: 600; margin-top: 3px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.chart-card { background:#fff; border:1px solid var(--line); border-radius: 8px; padding: 20px 24px; }
.chart-card.full { grid-column: 1 / -1; }
.chart-card h3 { font-size: 1.05rem; margin-bottom: 16px; }
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 0.82rem; }
.bar-row .bl { width: 150px; text-align: right; color: var(--ink-soft); flex-shrink: 0; font-weight: 500; }
.bar-row .bt { flex: 1; background: #f0eee6; border-radius: 6px; height: 26px; position: relative; overflow: hidden; }
.bar-row .bf { height: 100%; border-radius: 6px; display: flex; align-items: center; justify-content: flex-end; padding-right: 9px; color: #fff; font-size: 0.76rem; font-weight: 700; min-width: 28px; transition: width .5s cubic-bezier(.2,.8,.2,1); box-shadow: inset 0 -8px 12px rgba(0,0,0,0.08); }
.bar-row .bf { background: linear-gradient(90deg, #2a2a2a, #1a1a1a); }
.bar-row .bf.accent { background: linear-gradient(90deg, #a82828, var(--accent)); }
.bar-row .bf.green { background: linear-gradient(90deg, #2e8540, var(--q1)); }
.bar-row .bf.gold { background: linear-gradient(90deg, #d4a017, var(--d1)); }
.bar-row .bf.blue { background: linear-gradient(90deg, #4a8bc2, var(--q2)); }
.cited-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.cited-table td, .cited-table th { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.cited-table th { font-family:'Inter'; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink-faint); }
.cited-table .ct-title { font-family:'Source Serif 4'; color: var(--ink); }

/* ---------- Assistant ---------- */
.assistant-wrap { max-width: 820px; margin: 0 auto; }
.assistant-title { font-size: 1.6rem; margin-bottom: 6px; }
.assistant-desc { color: var(--ink-faint); font-size: 0.9rem; margin-bottom: 24px; }
.examples { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.example {
  font-family:'Inter'; font-size: 0.82rem; padding: 8px 14px; background:#fff;
  border: 1px solid var(--line); border-radius: 20px; cursor: pointer; color: var(--ink-soft); text-align:left;
}
.example:hover { border-color: var(--ink); background:#f6f4ec; }
.ask-box { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
/* (estilos antiguos de #question y #ask-btn retirados — la caja de envío vive ahora en .ask-shell, bloque v6) */
.answer { background:#fff; border:1px solid var(--line); border-radius: 10px; padding: 28px 32px; margin-top: 10px; }
.answer-text { font-size: 0.95rem; line-height: 1.7; color: var(--ink-soft); }
.answer-text b { color: var(--ink); }
.answer-text .cite { color: var(--accent); font-weight: 600; cursor: pointer; }
.answer h4 { font-size: 1rem; margin: 22px 0 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.ref-card { border-left: 3px solid var(--ink); background:#faf9f5; padding: 12px 16px; margin: 10px 0; border-radius: 0 6px 6px 0; font-size: 0.85rem; }
.ref-card .rn { font-family:'Source Serif 4'; font-weight: 700; }
.ref-card .rj { font-style: italic; color: var(--ink-soft); }
.ref-card a { color: var(--accent); text-decoration: none; }
.spinner { display:inline-block; width:16px;height:16px;border:2px solid #ccc;border-top-color:var(--ink);border-radius:50%;animation:spin .7s linear infinite;vertical-align:middle;margin-right:8px;}
@keyframes spin { to { transform: rotate(360deg); } }
.api-notice { background:#fff8e6; border:1px solid #f0e0b0; border-radius:8px; padding:14px 18px; font-size:0.85rem; color:#7a5c00; margin-bottom:18px; }
.api-notice input { margin-top:8px; width:100%; padding:8px; border:1px solid var(--line); border-radius:5px; font-family:monospace; font-size:0.8rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .library-layout { grid-template-columns: 1fr; }
  .filters { position: static; }
  .detail { grid-template-columns: 1fr; }
  .detail-info { border-right: none; border-bottom: 1px solid var(--line); }
  .chart-grid { grid-template-columns: 1fr; }
}

/* ---------- Author autocomplete ---------- */
.author-box { position: relative; }
#author-search { width:100%; padding:10px 12px; border:1px solid var(--line); border-radius:6px; font-family:'Inter'; font-size:0.88rem; background:#fff; }
#author-search:focus { outline:none; border-color:var(--ink); }
.ac-dropdown { display:none; position:absolute; top:100%; left:0; right:0; background:#fff; border:1px solid var(--ink); border-radius:0 0 6px 6px; z-index:30; max-height:280px; overflow-y:auto; box-shadow:0 8px 24px rgba(0,0,0,0.12); }
.ac-dropdown.open { display:block; }
.ac-item { padding:9px 12px; cursor:pointer; display:flex; justify-content:space-between; font-size:0.84rem; border-bottom:1px solid #f0eee6; }
.ac-item:hover { background:#f6f4ec; }
.ac-count { color:var(--ink-faint); font-size:0.78rem; }
.ac-empty { padding:10px 12px; color:var(--ink-faint); font-size:0.82rem; }
.author-banner { background:#f6f4ec; border:1px solid var(--line); border-radius:8px; padding:12px 14px; margin-top:10px; font-size:0.84rem; display:flex; flex-direction:column; gap:10px; }
.author-banner button { background:var(--ink); color:#fff; border:none; padding:8px 14px; border-radius:6px; cursor:pointer; font-family:'Inter'; font-size:0.82rem; font-weight:500; }
.author-banner button:hover { background:#000; }

/* ---------- Conversational assistant ---------- */
.assistant-head { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin-bottom:18px; }
.new-chat-btn { background:#fff; border:1px solid var(--line); border-radius:6px; padding:8px 14px; cursor:pointer; font-family:'Inter'; font-size:0.82rem; color:var(--ink-soft); white-space:nowrap; }
.new-chat-btn:hover { border-color:var(--ink); }
#chat-thread { display:flex; flex-direction:column; gap:16px; margin-bottom:16px; }
.msg-user { align-self:flex-end; background:var(--ink); color:#fff; padding:10px 16px; border-radius:14px 14px 2px 14px; font-size:0.9rem; max-width:80%; }
.msg-assistant { align-self:flex-start; background:#fff; border:1px solid var(--line); border-radius:14px 14px 14px 2px; padding:20px 24px; font-size:0.92rem; line-height:1.7; color:var(--ink-soft); max-width:92%; }
.msg-assistant b { color:var(--ink); }
.msg-assistant .cite { color:var(--accent); font-weight:600; }
.msg-refs { margin-top:16px; padding-top:14px; border-top:1px solid var(--line); }
.msg-refs h4 { font-size:0.9rem; margin-bottom:8px; }

/* Clickable citations and reference cards */
.msg-assistant .cite { cursor: pointer; transition: opacity .1s; }
.msg-assistant .cite:hover { opacity: 0.6; text-decoration: underline; }
.ref-card[data-pmid] { transition: background .1s; }
.ref-card[data-pmid]:hover { background: #f0eee6; }

/* ===== Métricas mejoradas ===== */
.metrics-hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 18px; margin-bottom: 28px; }
.metric-card {
  background: linear-gradient(135deg, #fff 0%, #faf9f5 100%);
  border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px; position: relative; overflow: hidden;
}
.metric-card::before { content:''; position:absolute; top:0; left:0; width:4px; height:100%; background:var(--accent); }
.metric-card.green::before { background:var(--q1); }
.metric-card.gold::before { background:var(--d1); }
.metric-card.blue::before { background:var(--q2); }
.metric-card .mc-val { font-family:'Source Serif 4',serif; font-size:2.4rem; font-weight:700; line-height:1; color:var(--ink); }
.metric-card .mc-lbl { font-size:0.82rem; color:var(--ink-soft); margin-top:6px; font-weight:500; }
.metric-card .mc-sub { font-size:0.74rem; color:var(--ink-faint); margin-top:2px; }

.donut-wrap { display:flex; align-items:center; gap:40px; flex-wrap:wrap; padding:10px 0; }
.donut { width:240px; height:240px; flex-shrink:0; }
.donut-legend { display:flex; flex-direction:column; gap:6px; min-width:240px; }
.donut-legend .dl-item { display:flex; align-items:center; gap:10px; font-size:0.95rem; padding:4px 0; transition:opacity .15s; }
.donut-legend .dl-dot { width:14px; height:14px; border-radius:4px; flex-shrink:0; }
.donut-legend .dl-val { color:var(--ink-faint); margin-left:auto; padding-left:16px; }


/* ===== Congresos ===== */
.cong-filters { display:flex; gap:12px; align-items:center; margin:20px 0; flex-wrap:wrap; }
.cong-filters input[type=search] { flex:1; min-width:200px; padding:9px 12px; border:1px solid var(--line); border-radius:6px; font-family:'Inter'; font-size:0.88rem; }
.cong-filters select { padding:9px 12px; border:1px solid var(--line); border-radius:6px; font-family:'Inter'; font-size:0.85rem; background:#fff; cursor:pointer; }
.cong-item { padding:14px 4px; border-bottom:1px solid var(--line); }
.cong-title { font-family:'Source Serif 4',serif; font-size:1rem; font-weight:600; color:var(--ink); line-height:1.35; margin-bottom:5px; }
.cong-meta { font-size:0.82rem; color:var(--ink-faint); display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.cong-author { color:var(--ink-soft); font-weight:500; }
.cong-badge { display:inline-block; padding:1px 9px; border-radius:3px; font-size:0.7rem; font-weight:600; }
.cong-badge.congress { background:#eef2f7; color:var(--q2); border:1px solid #d8e2ee; }
.cong-badge.year { background:#f0eee6; color:var(--ink-soft); }
.cong-badge.cordio { background:var(--accent); color:#fff; }
.cong-badge.resi { background:#f3f1ea; color:var(--ink-faint); }

/* ===== Ranking con podio ===== */
.rank-row { display:flex; align-items:center; gap:12px; padding:8px 0; border-bottom:1px solid #f0eee6; }
.rank-row:last-child { border-bottom:none; }
.rk-pos { width:28px; text-align:center; font-size:1.1rem; flex-shrink:0; }
.rk-num { display:inline-block; width:22px; height:22px; line-height:22px; background:#f0eee6; border-radius:50%; font-size:0.75rem; font-weight:700; color:var(--ink-soft); }
.rk-name { width:180px; flex-shrink:0; font-size:0.86rem; color:var(--ink); font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rk-bar { flex:1; height:10px; background:#f0eee6; border-radius:5px; overflow:hidden; }
.rk-fill { display:block; height:100%; border-radius:5px; background:linear-gradient(90deg,#2e8540,var(--q1)); transition:width .5s cubic-bezier(.2,.8,.2,1); }
.rk-fill.green { background:linear-gradient(90deg,#2e8540,var(--q1)); }
.rk-val { width:32px; text-align:right; font-weight:700; font-size:0.85rem; color:var(--ink); flex-shrink:0; }

/* Donut polish */
.donut circle { transition: stroke-dasharray .6s cubic-bezier(.2,.8,.2,1); }

/* Download button + results actions */
.results-actions { display:flex; align-items:center; gap:10px; }
.download-btn { background:var(--ink); color:#fff; border:none; padding:7px 14px; border-radius:6px; font-family:'Inter'; font-size:0.82rem; font-weight:500; cursor:pointer; white-space:nowrap; }
.download-btn:hover { background:#000; }

/* ===== Assistant layout with history ===== */
.assistant-layout { display:grid; grid-template-columns:230px 1fr; gap:28px; align-items:start; }
.chat-history { position:sticky; top:20px; border:1px solid var(--line); border-radius:10px; background:#fff; overflow:hidden; }
.ch-head { display:flex; justify-content:space-between; align-items:center; padding:12px 14px; border-bottom:1px solid var(--line); font-size:0.8rem; font-weight:600; text-transform:uppercase; letter-spacing:0.5px; color:var(--ink-faint); }
.history-list { max-height:60vh; overflow-y:auto; }
.hist-item { padding:11px 14px; font-size:0.83rem; color:var(--ink-soft); cursor:pointer; border-bottom:1px solid #f0eee6; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; transition:background .1s; }
.hist-item:hover { background:#f6f4ec; }
.hist-item.active { background:#f0eee6; color:var(--ink); font-weight:500; border-left:3px solid var(--accent); padding-left:11px; }
.hist-empty { padding:16px 14px; font-size:0.8rem; color:var(--ink-faint); font-style:italic; }
.assistant-wrap { max-width:none; }

/* Clickable congress badges */
.cong-badge.congress, .cong-badge.cordio { cursor:pointer; transition:opacity .1s; }
.cong-badge.congress:hover, .cong-badge.cordio:hover { opacity:0.7; }

@media (max-width: 900px) {
  .assistant-layout { grid-template-columns:1fr; }
  .chat-history { position:static; }
}

/* ============ HOME / PORTADA ============ */
.hero { display:grid; grid-template-columns:1.4fr 1fr; gap:40px; align-items:center; padding:30px 0 40px; border-bottom:1px solid var(--line); margin-bottom:36px; }
.hero-eyebrow { font-size:0.78rem; font-weight:600; text-transform:uppercase; letter-spacing:1.5px; color:var(--accent); margin-bottom:14px; }
.hero-title { font-size:2.8rem; line-height:1.12; letter-spacing:-0.5px; margin-bottom:18px; color:var(--ink); }
.hero-title .hl { color:var(--accent); }
.hero-lead { font-size:1.08rem; line-height:1.6; color:var(--ink-soft); margin-bottom:26px; max-width:560px; }
.hero-actions { display:flex; gap:12px; flex-wrap:wrap; }
.hero-btn { font-family:'Inter'; font-size:0.92rem; font-weight:500; padding:12px 24px; border-radius:8px; border:1px solid var(--ink); background:#fff; color:var(--ink); cursor:pointer; transition:all .15s; }
.hero-btn:hover { background:#f6f4ec; }
.hero-btn.primary { background:var(--ink); color:#fff; }
.hero-btn.primary:hover { background:#000; }
.hero-art { display:flex; justify-content:center; }
.hero-svg { width:100%; max-width:300px; height:auto; }

.home-stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:18px; margin-bottom:40px; }
.home-stat { text-align:center; padding:20px; }
.home-stat .hs-val { font-family:'Source Serif 4',serif; font-size:2.6rem; font-weight:700; color:var(--ink); line-height:1; }
.home-stat .hs-lbl { font-size:0.84rem; color:var(--ink-faint); margin-top:6px; }

.home-features { display:grid; grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); gap:20px; margin-bottom:44px; }
.feature-card { border:1px solid var(--line); border-radius:12px; padding:26px 24px; cursor:pointer; transition:all .18s; background:#fff; }
.feature-card:hover { border-color:var(--ink); transform:translateY(-3px); box-shadow:0 10px 30px rgba(0,0,0,0.06); }
.feat-icon { font-size:2rem; margin-bottom:12px; }
.feature-card h3 { font-size:1.2rem; margin-bottom:8px; }
.feature-card p { font-size:0.88rem; line-height:1.55; color:var(--ink-soft); margin-bottom:14px; }
.feat-link { font-size:0.85rem; font-weight:600; color:var(--accent); }

.home-about { display:grid; grid-template-columns:1.5fr 1fr; gap:40px; align-items:center; padding:34px; background:linear-gradient(135deg,#faf9f5,#f3f1ea); border-radius:14px; }
.about-block h2 { font-size:1.5rem; margin-bottom:14px; }
.about-block p { font-size:0.95rem; line-height:1.7; color:var(--ink-soft); }
.about-logos { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.logo-slot { aspect-ratio:16/9; border:1px dashed #c8c5ba; border-radius:8px; display:flex; align-items:center; justify-content:center; text-align:center; font-size:0.74rem; color:var(--ink-faint); background:#fff; padding:8px; line-height:1.3; }

@media (max-width:900px) {
  .hero { grid-template-columns:1fr; }
  .hero-art { order:-1; }
  .hero-title { font-size:2rem; }
  .home-about { grid-template-columns:1fr; }
}

/* ===== Calendario de congresos ===== */
.section-h { font-family:'Source Serif 4',serif; font-size:1.3rem; margin:10px 0 16px; }
.cal-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:16px; margin-bottom:36px; }
.cal-card { border:1px solid var(--line); border-radius:12px; padding:18px 20px; background:#fff; position:relative; border-left-width:4px; }
.cal-card.urgent { border-left-color:var(--accent); background:linear-gradient(135deg,#fff,#fdf3f3); }
.cal-card.soon { border-left-color:var(--d1); }
.cal-card.open { border-left-color:var(--q1); }
.cal-card.closed { border-left-color:#bbb; opacity:0.7; }
.cal-top { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.cal-siglas { font-family:'Source Serif 4',serif; font-size:1.3rem; font-weight:700; color:var(--ink); }
.cal-ambito { font-size:0.7rem; text-transform:uppercase; letter-spacing:0.5px; color:var(--ink-faint); background:#f0eee6; padding:2px 8px; border-radius:10px; }
.cal-name { font-size:0.82rem; color:var(--ink-soft); line-height:1.4; margin-bottom:10px; min-height:34px; }
.cal-dates { font-size:0.8rem; color:var(--ink-faint); margin-bottom:10px; }
.cal-status { font-size:0.84rem; font-weight:600; padding:6px 10px; border-radius:6px; display:inline-block; }
.cal-status.urgent { background:#fdeaea; color:var(--accent); }
.cal-status.soon { background:#fdf6e3; color:#9a6a00; }
.cal-status.open { background:#eaf5ec; color:var(--q1); }
.cal-status.closed { background:#f0f0f0; color:#888; }
.cal-est { display:block; font-size:0.7rem; color:var(--ink-faint); font-style:italic; margin-top:6px; }
.cal-link { display:inline-block; margin-top:10px; font-size:0.8rem; color:var(--accent); text-decoration:none; font-weight:500; }
.cal-link:hover { text-decoration:underline; }

/* Answer action button */
.msg-actions { display:flex; justify-content:flex-end; margin-bottom:10px; }
.msg-pdf-btn { background:#fff; border:1px solid var(--line); border-radius:6px; padding:5px 12px; font-family:'Inter'; font-size:0.76rem; color:var(--ink-soft); cursor:pointer; }
.msg-pdf-btn:hover { border-color:var(--ink); background:#f6f4ec; }

/* ---------- Logos institucionales (Inicio) ---------- */
.about-logos .logo-slot { border-style: solid; border-color: var(--line); padding: 14px 16px; }
.about-logos .logo-slot img { max-width: 100%; max-height: 62px; width: auto; height: auto; object-fit: contain; }

/* ---------- Repercusión / Impacto ---------- */
#impacto .imp-p { font-size:0.95rem; line-height:1.6; color:var(--ink-soft); max-width:680px; margin-bottom:18px; }
#impacto .imp-finding strong { color:var(--ink); }
.compare { display:flex; flex-direction:column; gap:16px; max-width:640px; }
.cmp-top { display:flex; justify-content:space-between; font-size:0.85rem; font-weight:600; color:var(--ink-soft); margin-bottom:6px; }
.cmp-top span:last-child { font-family:'Source Serif 4',serif; font-weight:700; color:var(--ink); }
.cmp-track { height:26px; background:#f1efe7; border-radius:6px; overflow:hidden; }
.cmp-fill { height:100%; border-radius:6px; animation:cmpGrow .9s ease; }
.cmp-fill.lowfat { background:var(--accent); }
.cmp-fill.med { background:var(--q1); }
@keyframes cmpGrow { from { width:0; } }
.cmp-foot { font-size:0.78rem; color:var(--ink-faint); margin-top:4px; }
.cmp-foot a { color:var(--accent); }

.premio-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:16px; }
.premio-card { border:1px solid var(--line); border-left:3px solid var(--d1); border-radius:8px; padding:16px 18px; background:#fff; }
.premio-h { font-family:'Source Serif 4',serif; font-weight:700; font-size:1rem; line-height:1.3; margin-bottom:8px; }
.premio-meta { font-size:0.78rem; color:var(--ink-faint); margin-bottom:8px; }
.premio-det { font-size:0.85rem; color:var(--ink-soft); line-height:1.5; margin-bottom:8px; }
.premio-link { font-size:0.82rem; font-weight:600; color:var(--accent); text-decoration:none; }
.premio-link:hover { text-decoration:underline; }

.imp-n { font-weight:400; color:var(--ink-faint); font-size:0.82rem; }
.media-list { list-style:none; display:flex; flex-direction:column; gap:12px; }
.media-item { border-bottom:1px solid var(--line); padding-bottom:10px; }
.media-item:last-child { border-bottom:none; padding-bottom:0; }
.media-title { font-size:0.9rem; line-height:1.4; }
.media-title a { color:var(--ink); text-decoration:none; }
.media-title a:hover { color:var(--accent); text-decoration:underline; }
.media-meta { font-size:0.76rem; color:var(--ink-faint); margin-top:3px; }

.imp-list { list-style:none; display:flex; flex-direction:column; gap:14px; }
.imp-row { border-bottom:1px solid var(--line); padding-bottom:12px; }
.imp-row:last-child { border-bottom:none; padding-bottom:0; }
.imp-row-h { font-size:0.95rem; line-height:1.4; font-weight:500; }
.imp-row-h a { color:var(--ink); text-decoration:none; }
.imp-row-h a:hover { color:var(--accent); text-decoration:underline; }
.imp-row-m { font-size:0.78rem; color:var(--ink-faint); margin-top:4px; }
.imp-row-d { font-size:0.82rem; color:var(--ink-soft); margin-top:4px; }
.imp-badge { display:inline-block; font-size:0.68rem; font-weight:700; text-transform:uppercase; letter-spacing:0.4px; color:var(--accent); background:#f7eded; border-radius:4px; padding:2px 7px; margin-right:6px; }

/* ============================================================
   PULIDO VISUAL v4 — refinamiento editorial
   ============================================================ */

/* Selección de texto y foco accesible, en la paleta de la casa */
::selection { background: #8b1a1a22; color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* Transición suave al cambiar de sección */
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view.active { animation: viewIn .35s cubic-bezier(.2,.8,.2,1); }

/* Pestañas: subrayado que crece al pasar el ratón */
.tab { position: relative; }
.tab::after {
  content:''; position:absolute; left:18px; right:18px; bottom:-2px; height:2px;
  background: var(--line); transform: scaleX(0); transform-origin: left; transition: transform .2s ease;
}
.tab:hover:not(.active)::after { transform: scaleX(1); }

/* Pestañas con scroll horizontal en pantallas estrechas */
@media (max-width: 900px) {
  .masthead-inner { padding: 14px 20px 0 20px; }
  .affil { padding: 8px 20px 12px 20px; }
  .container { padding: 22px 20px 50px 20px; }
  .tabs {
    width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; flex-wrap: nowrap;
    mask-image: linear-gradient(90deg, #000 92%, transparent);
    -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; padding: 10px 14px; flex-shrink: 0; }
  .brand-title { font-size: 1.6rem; }
}

/* Portada: cinco tarjetas en una fila en pantallas anchas */
.home-features { grid-template-columns: repeat(auto-fit, minmax(208px, 1fr)); }
.feat-icon { margin-bottom: 14px; height: 36px; display: flex; align-items: flex-end; }
.feat-icon svg { width: 34px; height: 34px; }
.feature-card .feat-link { display: inline-block; transition: transform .18s ease; }
.feature-card:hover .feat-link { transform: translateX(3px); }
.feature-card:hover .feat-icon svg path[stroke="#1a1a1a"],
.feature-card:hover .feat-icon svg rect { stroke: var(--ink); }

/* Anillo de pulso del hero — latido lento y discreto */
@keyframes pulseRing {
  0%   { transform: scale(.78); opacity: 0; }
  18%  { opacity: .35; }
  60%  { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}
.pulse-ring { transform-origin: 100px 100px; animation: pulseRing 4.5s cubic-bezier(.2,.6,.4,1) infinite; opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .pulse-ring { animation: none; opacity: .12; }
  .view.active { animation: none; }
}

/* Encabezados de página (Repercusión y futuras secciones) */
.page-h { font-size: 1.9rem; margin: 6px 0 6px; letter-spacing: -0.3px; }
.page-intro { color: var(--ink-soft); max-width: 740px; margin-bottom: 26px; line-height: 1.6; font-size: 0.97rem; }

/* Tabla de citados: resaltar fila al pasar */
.cited-table tbody tr { transition: background .12s; }
.cited-table tbody tr:hover { background: #f6f4ec; }

/* Barras de desplazamiento finas en listas internas */
.topic-list, .history-list { scrollbar-width: thin; scrollbar-color: #d5d2c6 transparent; }
.topic-list::-webkit-scrollbar, .history-list::-webkit-scrollbar { width: 6px; }
.topic-list::-webkit-scrollbar-thumb, .history-list::-webkit-scrollbar-thumb { background: #d5d2c6; border-radius: 3px; }

/* ---------- Footer editorial ---------- */
.site-footer { background: #fff; border-top: 2px solid var(--ink); margin-top: 30px; }
.footer-inner {
  max-width: 1320px; margin: 0 auto; padding: 26px 32px 18px;
  display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap;
}
.footer-brand { display: flex; align-items: center; gap: 11px; }
.footer-name { font-family: 'Source Serif 4', serif; font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.footer-tag { font-size: 0.75rem; color: var(--ink-faint); margin-top: 2px; }
.footer-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.footer-nav button {
  font-family: 'Inter'; font-size: 0.8rem; background: none; border: none; cursor: pointer;
  color: var(--ink-faint); padding: 6px 10px; border-radius: 5px; transition: all .12s;
}
.footer-nav button:hover { color: var(--accent); background: #f6f4ec; }
.footer-base {
  max-width: 1320px; margin: 0 auto; padding: 0 32px 22px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 0.72rem; color: var(--ink-faint); letter-spacing: 0.2px;
}

/* ============================================================
   v5 — Repercusión en X, favicons de medios e imagen del hero
   ============================================================ */

/* Imagen del hero */
.hero-img {
  width: 100%; max-width: 440px; height: auto; display: block;
  border-radius: 14px; border: 1px solid var(--line);
  box-shadow: 0 14px 40px rgba(20,18,14,0.10);
}
@media (max-width: 900px) { .hero-img { max-width: 100%; } }

/* Favicons pequeños junto a medios y revistas */
.m-favicon {
  width: 16px; height: 16px; border-radius: 3px; vertical-align: -3px;
  margin-right: 8px; flex-shrink: 0; background: #f0eee6;
}

/* Distribución de Repercusión: contenido + panel de X */
.impacto-layout { display: grid; grid-template-columns: minmax(0,1fr) 350px; gap: 26px; align-items: start; }
@media (max-width: 1100px) {
  .impacto-layout { grid-template-columns: 1fr; }
  .x-panel { position: static !important; }
  .x-feed { max-height: 480px; }
}

/* Panel de X */
.x-panel {
  position: sticky; top: 16px; background: #fff; border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; display: flex; flex-direction: column;
  max-height: calc(100vh - 32px);
}
.x-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.x-mark {
  width: 34px; height: 34px; border-radius: 9px; background: #0f1419; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.15rem; font-weight: 700; flex-shrink: 0;
}
.x-title { font-family: 'Source Serif 4', serif; font-weight: 700; font-size: 1.02rem; line-height: 1.15; }
.x-sub { font-size: 0.74rem; color: var(--ink-faint); margin-top: 2px; }
.x-filters { display: flex; gap: 5px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.x-chip {
  font-family: 'Inter'; font-size: 0.74rem; font-weight: 600; padding: 4px 11px;
  border: 1px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer;
  color: var(--ink-soft); transition: all .12s;
}
.x-chip:hover { border-color: var(--ink); }
.x-chip.active { background: #0f1419; color: #fff; border-color: #0f1419; }
.x-feed { overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; scrollbar-color: #d5d2c6 transparent; }
.x-feed::-webkit-scrollbar { width: 6px; }
.x-feed::-webkit-scrollbar-thumb { background: #d5d2c6; border-radius: 3px; }
.x-empty { padding: 18px 14px; font-size: 0.82rem; color: var(--ink-faint); font-style: italic; }

/* Tarjeta tipo publicación de X */
.x-card {
  position: relative; background: #fff; border: 1px solid #cfd9de; border-radius: 14px;
  padding: 12px 14px; transition: background .12s, border-color .12s;
}
.x-card:hover { background: #f7f9f9; border-color: #8b98a5; }
.x-card-link { position: absolute; inset: 0; z-index: 1; }
.x-card-head { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.x-avatar {
  width: 36px; height: 36px; border-radius: 50%; color: #fff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Inter'; font-weight: 700; font-size: 0.95rem;
}
.x-who { min-width: 0; display: flex; flex-direction: column; }
.x-name { font-size: 0.85rem; font-weight: 700; color: #0f1419; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.x-handle { font-size: 0.76rem; color: #536471; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.x-glyph { margin-left: auto; color: #0f1419; font-size: 0.95rem; align-self: flex-start; }
.x-text { font-size: 0.85rem; line-height: 1.45; color: #0f1419; overflow-wrap: break-word; }
.x-snippet { font-size: 0.77rem; line-height: 1.45; color: #536471; margin-top: 6px; }
.x-tags { margin-top: 7px; display: flex; gap: 6px; flex-wrap: wrap; }
.x-tag { color: #1d9bf0; font-size: 0.79rem; }
.x-foot { margin-top: 8px; font-size: 0.74rem; font-weight: 600; color: #1d9bf0; }

/* ============================================================
   v6 — Asistente y Métricas refinados, PWA
   ============================================================ */

/* ---------- Asistente: bienvenida ---------- */
.assistant-welcome { text-align: center; max-width: 600px; margin: 26px auto 34px; }
.aw-icon { width: 52px; height: 52px; margin-bottom: 14px; }
.assistant-welcome .assistant-title { margin-bottom: 10px; }
.aw-desc { color: var(--ink-soft); font-size: 0.93rem; line-height: 1.65; max-width: 520px; margin: 0 auto 26px; }
.aw-examples-lbl { font-size: 0.72rem; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 12px; }
.assistant-welcome .examples { justify-content: center; }

/* ---------- Asistente: caja de envío ---------- */
.ask-shell {
  display: flex; align-items: flex-end; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 10px 10px 10px 18px; margin-top: 18px;
  box-shadow: 0 2px 10px rgba(20,18,14,0.04);
  transition: border-color .15s, box-shadow .15s;
}
.ask-shell:focus-within { border-color: var(--ink); box-shadow: 0 4px 16px rgba(20,18,14,0.08); }
.ask-shell textarea {
  flex: 1; border: none; outline: none; resize: none; background: transparent;
  font-family: 'Inter'; font-size: 0.92rem; line-height: 1.5; color: var(--ink);
  min-height: 24px; max-height: 160px; padding: 6px 0;
}
.send-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--ink); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
.send-btn:hover { background: var(--accent); }
.send-btn:active { transform: scale(0.94); }
.ask-hint { font-size: 0.7rem; color: var(--ink-faint); text-align: center; margin-top: 10px; letter-spacing: 0.2px; }

/* ---------- Asistente: hilo de conversación ---------- */
#chat-thread { display: flex; flex-direction: column; gap: 16px; }
.msg-user {
  border-radius: 16px 16px 4px 16px; padding: 11px 18px;
  box-shadow: 0 2px 8px rgba(20,18,14,0.10); line-height: 1.55;
}
.msg-assistant {
  border-radius: 4px 16px 16px 16px; padding: 20px 26px 18px;
  box-shadow: 0 2px 12px rgba(20,18,14,0.05); position: relative;
}
.msg-assistant::before {
  content: ''; display: block; width: 44px; height: 3px; border-radius: 2px;
  background: var(--accent); margin-bottom: 14px; opacity: 0.85;
}
.ans-p { margin: 0 0 12px; }
.ans-p:last-of-type { margin-bottom: 0; }
.ans-h {
  font-family: 'Source Serif 4', serif; font-weight: 700; color: var(--ink);
  font-size: 1.02rem; margin: 18px 0 8px;
}
.ans-list { margin: 4px 0 14px 4px; padding-left: 20px; }
.ans-list li { margin-bottom: 7px; line-height: 1.6; }
.ans-list li::marker { color: var(--accent); font-weight: 700; }
.ans-code { background: #f3f1ea; border-radius: 4px; padding: 1px 6px; font-size: 0.85em; }
.msg-refs h4 { font-size: 0.95rem; }
.msg-actions { float: right; margin: -4px -8px 6px 10px; }

/* ---------- Asistente: historial ---------- */
.chat-history { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.hist-item { line-height: 1.45; }

/* ---------- Métricas: barras animadas y tabla refinada ---------- */
@keyframes growX { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.bar-row .bf { transform-origin: left; animation: growX .65s cubic-bezier(.2,.8,.2,1) backwards; }
.bar-row:nth-child(1) .bf { animation-delay: .02s; } .bar-row:nth-child(2) .bf { animation-delay: .06s; }
.bar-row:nth-child(3) .bf { animation-delay: .10s; } .bar-row:nth-child(4) .bf { animation-delay: .14s; }
.bar-row:nth-child(5) .bf { animation-delay: .18s; } .bar-row:nth-child(6) .bf { animation-delay: .22s; }
.bar-row:nth-child(7) .bf { animation-delay: .26s; } .bar-row:nth-child(8) .bf { animation-delay: .30s; }
.bar-row:nth-child(n+9) .bf { animation-delay: .34s; }
@media (prefers-reduced-motion: reduce) { .bar-row .bf { animation: none; } }

.cited-table { border-collapse: collapse; width: 100%; }
.cited-table th {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--ink-faint); text-align: left; padding: 8px 12px; border-bottom: 2px solid var(--ink);
}
.cited-table td { padding: 12px; border-bottom: 1px solid #eeece4; vertical-align: top; font-size: 0.85rem; }
.cited-table tbody tr:last-child td { border-bottom: none; }
.ct-year { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.cited-table .ct-title { font-family: 'Source Serif 4', serif; font-weight: 600; color: var(--ink); line-height: 1.4; }
.ct-journal { color: var(--ink-soft); }
.ct-q .pill { margin-right: 4px; }
.ct-num { text-align: right; }
.ct-cites { font-family: 'Source Serif 4', serif; font-weight: 700; font-size: 1rem; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Etiquetas temáticas con nombre legible en barras */
#chart-topics .bl, #chart-journals .bl { font-size: 0.76rem; }
