/* AI Radar — hoja de estilos única, sin dependencias externas. */

:root {
  --bg: #0d1017;
  --bg-elev: #141922;
  --bg-elev-2: #1a212c;
  --bg-input: #10151d;
  --border: #242c3a;
  --border-soft: #1c2330;
  --text: #dbe3ef;
  --text-dim: #8b97ab;
  --text-faint: #5d6879;
  --accent: #6ea8fe;
  --accent-soft: rgba(110, 168, 254, 0.13);
  --warn: #e8b464;
  --warn-soft: rgba(232, 180, 100, 0.12);
  --ok: #6fce9f;
  --danger: #f0776c;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  --radius: 9px;
}

:root[data-theme="light"] {
  --bg: #f7f8fa;
  --bg-elev: #ffffff;
  --bg-elev-2: #f0f2f6;
  --bg-input: #ffffff;
  --border: #dde1e9;
  --border-soft: #e8ebf1;
  --text: #1b2230;
  --text-dim: #5b6779;
  --text-faint: #8d97a8;
  --accent: #2563c9;
  --accent-soft: rgba(37, 99, 201, 0.09);
  --warn: #a5690c;
  --warn-soft: rgba(165, 105, 12, 0.1);
  --ok: #1d7a4c;
  --danger: #c23b30;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* ---------- Estructura ---------- */

#app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  overflow: hidden;
}

header.top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  height: 54px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
}
.brand .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  align-self: center;
}
.brand small {
  font-weight: 400;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0;
}

.search-wrap { flex: 1; max-width: 520px; position: relative; }
.search-wrap input {
  width: 100%;
  padding: 7px 34px 7px 30px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
}
.search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-wrap .icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint); font-size: 13px; pointer-events: none;
}
.search-wrap kbd {
  position: absolute; right: 8px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono); font-size: 10px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
  pointer-events: none;
}

.top-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.top-actions button {
  padding: 6px 11px;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13px;
  white-space: nowrap;
}
.top-actions button:hover { background: var(--bg-elev-2); color: var(--text); }
.top-actions button.active { background: var(--accent-soft); color: var(--accent); }

main.cols {
  display: grid;
  grid-template-columns: 216px 372px 1fr;
  min-height: 0;
  overflow: hidden;
}

nav.side, section.list, section.reader { overflow-y: auto; min-height: 0; }
nav.side { border-right: 1px solid var(--border); padding: 14px 10px 40px; background: var(--bg-elev); }
section.list { border-right: 1px solid var(--border); padding: 10px 10px 60px; }
section.reader { padding: 0; background: var(--bg); }

/* ---------- Barra lateral ---------- */

.side-group { margin-bottom: 18px; }
.side-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  padding: 0 8px 6px;
  font-weight: 600;
}

.track-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 13.5px;
  text-align: left;
}
.track-btn:hover { background: var(--bg-elev-2); color: var(--text); }
.track-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.track-btn .sw { width: 7px; height: 7px; border-radius: 2px; flex-shrink: 0; }
.track-btn .n { margin-left: auto; font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.track-btn.active .n { color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 6px; }
.chip {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text-dim);
}
.chip:hover { border-color: var(--text-faint); color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.side-reset {
  display: block;
  margin: 4px 6px 0;
  font-size: 12px;
  color: var(--text-faint);
  text-decoration: underline;
}
.side-reset:hover { color: var(--text); }

/* ---------- Lista ---------- */

.list-head {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 10px;
  font-size: 12px; color: var(--text-faint);
}
.list-head select {
  margin-left: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 3px 6px;
  font: inherit; font-size: 12px;
  outline: none;
}

.card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg-elev);
  transition: border-color 0.12s;
}
.card:hover { border-color: var(--text-faint); }
.card.active { border-color: var(--accent); background: var(--accent-soft); }
.card.read .card-title { color: var(--text-dim); }

.card-meta {
  display: flex; align-items: center; gap: 7px;
  font-size: 10.5px; color: var(--text-faint);
  margin-bottom: 5px;
  font-variant-numeric: tabular-nums;
}
.card-meta .tk { display: flex; align-items: center; gap: 5px; font-weight: 600; letter-spacing: 0.02em; }
.card-meta .tk .sw { width: 6px; height: 6px; border-radius: 2px; }
.card-meta .sep { opacity: 0.4; }
.card-meta .readmark { margin-left: auto; color: var(--ok); }

.card-title {
  font-size: 14px; font-weight: 600;
  line-height: 1.35; margin-bottom: 4px;
  color: var(--text);
  letter-spacing: -0.005em;
}
.card-sum { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.card-foot {
  display: flex; align-items: center; gap: 6px;
  margin-top: 7px; font-size: 10.5px; color: var(--text-faint);
}
.badge {
  padding: 1px 6px; border-radius: 4px;
  background: var(--bg-elev-2); border: 1px solid var(--border-soft);
  font-size: 10px; letter-spacing: 0.02em;
}
.badge.dato { color: var(--ok); }
.badge.opinion { color: var(--warn); }
.badge.comparativa { color: var(--accent); }

.empty { padding: 40px 16px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* ---------- Lector ---------- */

.reader-inner { max-width: 760px; margin: 0 auto; padding: 30px 34px 100px; }

.doc-head { border-bottom: 1px solid var(--border); padding-bottom: 16px; margin-bottom: 24px; }
.doc-kicker {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 11px; color: var(--text-faint); margin-bottom: 9px;
  font-variant-numeric: tabular-nums;
}
.doc-kicker .tk { font-weight: 650; letter-spacing: 0.03em; text-transform: uppercase; }
h1.doc-title {
  font-size: 27px; line-height: 1.22; margin: 0 0 10px;
  letter-spacing: -0.021em; font-weight: 680;
}
.doc-sum { font-size: 15.5px; color: var(--text-dim); line-height: 1.55; margin: 0 0 14px; }

.doc-facts {
  display: flex; flex-wrap: wrap; gap: 7px;
  font-size: 11px;
}
.fact {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--border-soft);
  color: var(--text-dim); font-variant-numeric: tabular-nums;
}
.fact b { font-weight: 600; color: var(--text); }
.fact.conf-alta { color: var(--ok); border-color: rgba(111,206,159,0.3); }
.fact.conf-media { color: var(--warn); border-color: rgba(232,180,100,0.3); }
.fact.conf-baja { color: var(--danger); border-color: rgba(240,119,108,0.3); }

.doc-actions { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.doc-actions button {
  padding: 5px 12px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 12.5px; color: var(--text-dim);
}
.doc-actions button:hover { border-color: var(--accent); color: var(--accent); }
.doc-actions button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Cuerpo del artículo */
.md { font-size: 15.2px; line-height: 1.72; }
.md h2 {
  font-size: 19px; margin: 34px 0 12px; font-weight: 660;
  letter-spacing: -0.012em; padding-top: 6px;
  border-top: 1px solid var(--border-soft);
}
.md h2:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.md h3 { font-size: 15.8px; margin: 24px 0 8px; font-weight: 640; }
.md h4 { font-size: 14.2px; margin: 18px 0 6px; font-weight: 640; color: var(--text-dim); }
.md p { margin: 0 0 15px; }
.md ul, .md ol { margin: 0 0 15px; padding-left: 22px; }
.md li { margin-bottom: 6px; }
.md li > ul, .md li > ol { margin: 6px 0 0; }
.md strong { font-weight: 640; color: var(--text); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 26px 0; }

.md code {
  font-family: var(--mono); font-size: 0.875em;
  background: var(--bg-elev-2); border: 1px solid var(--border-soft);
  padding: 1px 5px; border-radius: 4px;
  word-break: break-word;
}
.md pre {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 15px;
  overflow-x: auto; margin: 0 0 16px;
  position: relative;
}
.md pre code {
  background: none; border: none; padding: 0;
  font-size: 12.8px; line-height: 1.62;
  white-space: pre; word-break: normal;
}
.copy-btn {
  position: absolute; top: 5px; right: 8px;
  font-size: 10.5px; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 2px 7px; background: var(--bg-elev-2);
  opacity: 0; transition: opacity 0.12s;
}
.md pre:hover .copy-btn, .copy-btn:focus { opacity: 1; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }

.md blockquote {
  margin: 0 0 16px; padding: 10px 16px;
  border-left: 3px solid var(--border);
  color: var(--text-dim);
}
.md blockquote p:last-child { margin-bottom: 0; }

.callout {
  margin: 0 0 16px; padding: 11px 15px;
  border-radius: var(--radius);
  background: var(--warn-soft);
  border: 1px solid rgba(232, 180, 100, 0.28);
  font-size: 14.2px;
}
.callout .ctag {
  display: block; font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--warn); margin-bottom: 4px;
}
.callout p:last-child { margin-bottom: 0; }

.md table {
  width: 100%; border-collapse: collapse;
  margin: 0 0 18px; font-size: 13.4px;
  display: block; overflow-x: auto;
}
.md th, .md td {
  border: 1px solid var(--border);
  padding: 7px 11px; text-align: left; vertical-align: top;
}
.md th {
  background: var(--bg-elev-2); font-weight: 620;
  font-size: 12.4px; white-space: nowrap;
}
.md tbody tr:nth-child(even) { background: var(--bg-elev); }

/* Sección de fuentes dentro del artículo */
.md ul.src-list { list-style: none; padding-left: 0; }
.md ul.src-list li {
  padding: 9px 12px; margin-bottom: 7px;
  border: 1px solid var(--border-soft); border-radius: 7px;
  background: var(--bg-elev); font-size: 13.2px; line-height: 1.5;
}
.md ul.src-list .src-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 4px; font-size: 11px; color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.md ul.src-list .src-meta .pub { color: var(--text-dim); }
.md ul.src-list .src-meta span + span::before { content: "·"; margin-right: 8px; opacity: 0.45; }

/* ---------- Vistas especiales ---------- */

.pane { max-width: 900px; margin: 0 auto; padding: 32px 34px 90px; }
.pane h1 { font-size: 25px; margin: 0 0 6px; letter-spacing: -0.02em; }
.pane .lede { color: var(--text-dim); font-size: 15px; margin: 0 0 26px; max-width: 62ch; }
.pane h2 { font-size: 17px; margin: 30px 0 12px; font-weight: 650; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 9px; margin-bottom: 28px; }
.stat {
  padding: 13px 15px; border: 1px solid var(--border-soft);
  border-radius: var(--radius); background: var(--bg-elev);
}
.stat .v { font-size: 25px; font-weight: 680; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; white-space: nowrap; }
.stat .v.small { font-size: 17px; line-height: 1.5; }
.stat .k { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }

.track-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 10px; }
.track-card {
  text-align: left; padding: 14px 15px;
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  background: var(--bg-elev); transition: border-color 0.12s;
}
.track-card:hover { border-color: var(--accent); }
.track-card .tc-h { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.track-card .tc-h .sw { width: 9px; height: 9px; border-radius: 3px; }
.track-card .tc-h b { font-size: 14px; font-weight: 640; }
.track-card .tc-h .n { margin-left: auto; font-size: 11px; color: var(--text-faint); }
.track-card p { margin: 0; font-size: 12.6px; color: var(--text-dim); line-height: 1.5; }

.pick-list { display: grid; gap: 8px; }
.pick {
  display: block; width: 100%; text-align: left;
  padding: 11px 14px; border: 1px solid var(--border-soft);
  border-radius: var(--radius); background: var(--bg-elev);
}
.pick:hover { border-color: var(--accent); }
.pick b { display: block; font-size: 13.8px; font-weight: 620; margin-bottom: 3px; }
.pick span { font-size: 12.4px; color: var(--text-dim); }

.src-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.src-table th, .src-table td { border-bottom: 1px solid var(--border-soft); padding: 8px 10px; text-align: left; vertical-align: top; }
.src-table th { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; white-space: nowrap; }
.src-table td.date { font-variant-numeric: tabular-nums; color: var(--text-dim); white-space: nowrap; font-family: var(--mono); font-size: 11.5px; }
.src-table td.pubr { color: var(--text-dim); white-space: nowrap; }
.src-table tr:hover td { background: var(--bg-elev); }
.src-filters { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.src-filters input, .src-filters select {
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text); border-radius: 7px; padding: 5px 9px;
  font: inherit; font-size: 13px; outline: none;
}
.src-filters input { min-width: 220px; }

/* ---------- Responsive ---------- */

.mobile-tabs { display: none; }

@media (max-width: 1100px) {
  main.cols { grid-template-columns: 190px 330px 1fr; }
  .reader-inner, .pane { padding-left: 24px; padding-right: 24px; }
}

@media (max-width: 860px) {
  main.cols { grid-template-columns: 1fr; }
  nav.side, section.list, section.reader { display: none; }
  main.cols[data-mobile="side"] nav.side,
  main.cols[data-mobile="list"] section.list,
  main.cols[data-mobile="reader"] section.reader { display: block; }
  nav.side, section.list { border-right: none; }
  .mobile-tabs {
    display: flex; gap: 4px;
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elev);
  }
  .mobile-tabs button {
    flex: 1; padding: 6px; border-radius: 7px;
    font-size: 12.5px; color: var(--text-dim);
    border: 1px solid var(--border);
  }
  .mobile-tabs button.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
  #app { grid-template-rows: auto auto 1fr; }
  header.top { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; }
  .search-wrap kbd { display: none; }
  .top-actions button { padding: 5px 8px; font-size: 12px; }
  .reader-inner, .pane { padding: 20px 16px 80px; }
  h1.doc-title { font-size: 22px; }
  .md { font-size: 15px; }
}

@media print {
  header.top, nav.side, section.list, .mobile-tabs, .doc-actions, .copy-btn { display: none !important; }
  main.cols { grid-template-columns: 1fr; }
  #app { height: auto; overflow: visible; }
  section.reader { overflow: visible; }
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

.related { margin-top: 42px; padding-top: 4px; border-top: 1px solid var(--border); }
.related h2 { font-size: 15px; font-weight: 640; margin: 18px 0 12px; color: var(--text-dim); }
