/* ============================================================
   Sistema de Publicación — móvil-first
   ============================================================ */
:root {
  --bg: #0f1115;
  --bg2: #171a21;
  --bg3: #1f2430;
  --card: #1a1e27;
  --line: #2a3040;
  --text: #eef1f6;
  --text2: #9aa3b5;
  --text3: #6b7487;
  --accent: #3b82f6;
  --accent2: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 14px;
  --nav-h: calc(60px + env(safe-area-inset-bottom));
  --cat-nacional: #3b82f6;
  --cat-internacional: #8b5cf6;
  --cat-deportes: #22c55e;
  --cat-espectaculos: #ec4899;
  --cat-entretenimiento: #f59e0b;
  --cat-local: #14b8a6;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f8; --bg2: #ffffff; --bg3: #eceef3; --card: #ffffff;
    --line: #e3e6ee; --text: #14171f; --text2: #5a6275; --text3: #8a91a3;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15.5px; line-height: 1.45;
  overscroll-behavior-y: contain;
}
#app { min-height: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg3);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
a { color: var(--accent); text-decoration: none; }
::placeholder { color: var(--text3); }

/* ── Boot / spinner ── */
.boot { display: flex; align-items: center; justify-content: center; height: 100vh; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.spinner.sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login ── */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
}
.login-logo { font-size: 42px; margin-bottom: 6px; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 2px; }
.login-sub { color: var(--text2); margin-bottom: 28px; font-size: 14px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login-card input { padding: 14px 16px; font-size: 16px; }

/* ── Botones ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; font-weight: 600;
  border-radius: 12px; padding: 13px 18px; font-size: 15.5px;
  transition: opacity .15s, transform .05s;
  min-height: 48px;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.ghost { background: var(--bg3); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--red); }
.btn.green { background: var(--green); color: #08200f; }
.btn.sm { min-height: 38px; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }

/* ── Layout de vistas ── */
.view { padding: 0 14px var(--nav-h); max-width: 760px; margin: 0 auto; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(var(--bg) 75%, transparent);
  padding: calc(12px + env(safe-area-inset-top)) 0 8px;
  display: flex; align-items: center; gap: 10px;
}
.topbar h1 { font-size: 21px; font-weight: 800; margin: 0; flex: 1; letter-spacing: -.02em; }
.topbar .sub { font-size: 12.5px; color: var(--text2); font-weight: 500; }
.iconbtn {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); border: 1px solid var(--line);
}
.iconbtn svg { width: 20px; height: 20px; stroke: var(--text2); fill: none; }
/* Los iconos son trazos, no siluetas: sin esto el fill negro por defecto
   los convierte en manchas (se notaba sólo en tema claro). Las piezas que
   sí son macizas lo piden explícitamente con fill="currentColor". */
svg [fill="currentColor"] { fill: currentColor; }
.iconbtn.spin svg { animation: spin 1s linear infinite; }

/* ── Chips de categoría ── */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 6px 0 10px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: var(--bg3); color: var(--text2); border: 1px solid var(--line);
  white-space: nowrap; min-height: 38px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip .n {
  font-size: 12px; background: var(--line); border-radius: 999px;
  padding: 1px 7px; color: var(--text2); font-weight: 700;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.on .n { background: rgba(0,0,0,.18); color: inherit; }
@media (prefers-color-scheme: dark) { .chip.on .n { background: rgba(255,255,255,.25); } }

/* ── Filtros secundarios ── */
.subfilters { display: flex; gap: 8px; padding-bottom: 10px; align-items: center; flex-wrap: wrap; }
.seg { display: flex; background: var(--bg3); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { padding: 8px 13px; font-size: 13.5px; color: var(--text2); font-weight: 600; }
.seg button.on { background: var(--accent); color: #fff; }
.seg.block { width: 100%; }
.seg.block button { flex: 1; text-align: center; }
.sched-badge { font-weight: 700; }
.sched-badge.amber { color: var(--amber); }
.sched-badge.green { color: var(--green); }
.sched-badge.red { color: var(--red); }
.sched-badge.muted { color: var(--text3); }
.grp-toggle { margin-left: auto; width: 38px; height: 38px; }
.grp-toggle.on { background: var(--accent); border-color: var(--accent); }
.grp-toggle.on svg { stroke: #fff; }

/* ── Tarjetas de noticia ── */
.cards { display: flex; flex-direction: column; gap: 10px; }
.src-group { display: flex; flex-direction: column; gap: 10px; }
.src-head {
  display: flex; align-items: center; gap: 8px; padding: 2px 2px 0;
}
.src-name { font-size: 12.5px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .03em; }
.src-n {
  font-size: 11px; font-weight: 600; color: var(--text3);
  background: var(--bg3); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px;
}
.card {
  display: flex; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; position: relative;
  transition: transform .06s;
}
.card:active { transform: scale(.99); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card .thumb {
  width: 92px; height: 92px; border-radius: 10px; flex: 0 0 auto;
  object-fit: cover; background: var(--bg3);
}
.card .noimg {
  width: 92px; height: 92px; border-radius: 10px; flex: 0 0 auto;
  background: var(--bg3); display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: var(--text3);
}
.card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card .title {
  font-weight: 650; font-size: 15px; line-height: 1.32;
  padding-right: 30px;   /* deja libre la esquina de la casilla de selección */
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 6px;
}
.card .meta {
  margin-top: auto; display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text3); flex-wrap: wrap;
}
.card .meta .catdot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.card .badge {
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  background: var(--bg3); color: var(--text2); text-transform: uppercase; letter-spacing: .03em;
}
.badge.ia { background: rgba(139, 92, 246, .18); color: #a78bfa; }
.badge.pub { background: rgba(34, 197, 94, .15); color: var(--green); }
.card .check {
  position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--bg2);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s;
}
.selectmode .card .check, .card.selected .check { opacity: 1; }
.card.selected .check { background: var(--accent); border-color: var(--accent); }
.card.selected .check::after { content: "✓"; color: #fff; font-size: 13px; font-weight: 800; }

/* ── Estados vacíos / skeleton ── */
.empty { text-align: center; color: var(--text3); padding: 60px 20px; }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.skel { border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); height: 116px; position: relative; overflow: hidden; }
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ── Barra de selección flotante ── */
.selbar {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(var(--nav-h) + 10px); z-index: 40;
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 16px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.45);
  animation: slideup .2s ease;
  max-width: 736px; margin: 0 auto;
}
@keyframes slideup { from { transform: translateY(16px); opacity: 0; } }
.selbar .count { font-weight: 700; font-size: 14.5px; flex: 1; padding-left: 6px; }

/* ── Sheet (modal deslizante) ── */
.sheet-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 60;
  animation: fadein .18s ease; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
@keyframes fadein { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  background: var(--bg2); border-radius: 22px 22px 0 0;
  max-height: 92dvh; display: flex; flex-direction: column;
  animation: sheetup .25s cubic-bezier(.2,.9,.3,1);
  max-width: 760px; margin: 0 auto;
}
@keyframes sheetup { from { transform: translateY(60%); } }
.sheet .grab { width: 40px; height: 4px; background: var(--line); border-radius: 4px; margin: 10px auto 2px; flex: 0 0 auto; }
.sheet .sheet-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px 10px; flex: 0 0 auto;
}
.sheet .sheet-head h2 { font-size: 17px; margin: 0; flex: 1; font-weight: 700; }
.sheet .sheet-body { overflow-y: auto; padding: 0 16px calc(20px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.sheet .hero { width: 100%; max-height: 210px; object-fit: cover; border-radius: 14px; margin-bottom: 12px; }
.sheet .art-title { font-size: 19px; font-weight: 750; line-height: 1.3; margin: 2px 0 8px; }
.sheet .art-meta { font-size: 12.5px; color: var(--text3); margin-bottom: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sheet .content-preview {
  font-size: 15px; color: var(--text2); line-height: 1.6;
  border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  max-height: 300px; overflow-y: auto; margin-bottom: 14px; background: var(--bg);
}
.content-preview p { margin: 0 0 .8em; }
.content-preview img { max-width: 100%; border-radius: 8px; }

/* ── Selector de sitios ── */
.sites-pick { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 14px; }
.site-row {
  display: flex; align-items: center; gap: 12px;
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px;
  background: var(--bg3); min-height: 52px;
}
.site-row .sdot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.site-row .sname { flex: 1; font-weight: 600; font-size: 15px; }
.site-row .scheck {
  width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.site-row.on { border-color: var(--accent); background: rgba(59,130,246,.08); }
.site-row.on .scheck { background: var(--accent); border-color: var(--accent); }
.site-row.on .scheck::after { content: "✓"; color: #fff; font-weight: 800; font-size: 14px; }
.site-row.dis { opacity: .45; }
.site-row .swarn { font-size: 11.5px; color: var(--amber); }

/* ── Resultados de publicación ── */
.pubres { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.pubres .pr {
  display: flex; align-items: center; gap: 10px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.pr .ok { color: var(--green); font-weight: 700; }
.pr .fail { color: var(--red); font-weight: 700; }
.pr .err-msg { color: var(--text3); font-size: 12.5px; }

/* ── Secciones / formularios ── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--text3); margin-top: 5px; }
.row2 { display: flex; gap: 10px; }
.row2 > * { flex: 1; }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.switch .lbl { font-weight: 600; font-size: 15px; }
.toggle {
  width: 50px; height: 30px; border-radius: 999px; background: var(--line);
  position: relative; transition: background .15s; flex: 0 0 auto;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%; background: #fff;
  transition: transform .15s; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.toggle.on { background: var(--green); }
.toggle.on::after { transform: translateX(20px); }

/* ── Listas (sitios, fuentes, historial) ── */
.list { display: flex; flex-direction: column; gap: 10px; }
.litem {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; align-items: center; gap: 12px;
}
.litem .li-main { flex: 1; min-width: 0; }
.litem .li-title { font-weight: 650; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.litem .li-sub { font-size: 12.5px; color: var(--text3); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.statdot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.statdot.ok { background: var(--green); }
.statdot.bad { background: var(--red); }
.statdot.unk { background: var(--text3); }

.group-title {
  font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text3); margin: 18px 2px 8px;
}

/* ── Historial ── */
.hist-item { display: flex; gap: 12px; align-items: flex-start; }
.hist-item .hi-site {
  font-size: 11px; font-weight: 800; color: #fff; padding: 3px 8px;
  border-radius: 6px; flex: 0 0 auto; margin-top: 2px;
}
.hist-item .hi-title { font-size: 14px; font-weight: 600; line-height: 1.35; }
.hist-item .hi-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 14px); left: 50%;
  transform: translateX(-50%); z-index: 100;
  background: var(--text); color: var(--bg);
  font-weight: 600; font-size: 14px; padding: 12px 20px;
  border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.4);
  max-width: 86vw; text-align: center;
  animation: toastin .2s ease;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } }
.toast.err { background: var(--red); color: #fff; }

/* ── Bottom nav ── */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex; height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--text3);
}
.nav button svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.nav button.on { color: var(--accent); }

.loadmore { text-align: center; padding: 16px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb16 { margin-bottom: 16px; }
.muted { color: var(--text3); font-size: 13px; }
.tcenter { text-align: center; }

/* Salud de fuentes */
.banner-down {
  display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--red) 16%, var(--card));
  border: 1px solid color-mix(in srgb, var(--red) 45%, var(--line));
  color: var(--text); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 10px; font-size: 13px; cursor: pointer;
}
.banner-down svg { width: 18px; height: 18px; flex: none; color: var(--red); stroke: currentColor; fill: none; }
.health-sum {
  display: flex; gap: 14px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; font-size: 14px;
}
.health-sum b { font-size: 16px; }

/* Guardrails: panel de verificación del editor */
.rv-check {
  border: 1px solid var(--line); border-left-width: 4px;
  border-radius: var(--radius); background: var(--card);
  padding: 12px 14px; margin: 4px 0 16px; font-size: 13.5px;
}
.rv-check.rv-green  { border-left-color: var(--green); }
.rv-check.rv-yellow { border-left-color: var(--amber); }
.rv-check.rv-red    { border-left-color: var(--red); }
.rv-check-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rv-sum { margin: 8px 0; color: var(--text2); }
.rv-grp { margin-top: 10px; }
.rv-grp b { display: block; margin-bottom: 3px; font-size: 13px; }
.rv-grp ul { margin: 0; padding-left: 18px; }
.rv-grp li { margin: 2px 0; color: var(--text2); }

/* Badge de evento (cluster) en las tarjetas */
.badge.clus {
  background: color-mix(in srgb, var(--accent) 18%, var(--card));
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  cursor: pointer;
}

/* ── Dock de tareas en segundo plano ── */
.jobdock {
  position: fixed; left: 10px; bottom: calc(var(--nav-h) + 10px); z-index: 55;
  width: min(340px, calc(100vw - 20px));
  display: flex; flex-direction: column-reverse; gap: 8px;
  pointer-events: none;
}
.jobdock > * { pointer-events: auto; }
.jobdock-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 13.5px;
  box-shadow: 0 6px 20px rgba(0,0,0,.35); cursor: pointer; width: 100%;
  text-align: left;
}
.jobdock-pill .jd-gear { display: flex; width: 18px; height: 18px; align-items: center; justify-content: center; color: var(--accent); }
.jobdock-pill .jd-mini { color: var(--text3); font-weight: 500; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.jobdock-pill .jd-caret { margin-left: auto; color: var(--text3); }
.jobdock-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 8px 26px rgba(0,0,0,.4); padding: 8px; max-height: 46vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.job-row { background: var(--bg3); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.job-row.job-error { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }
.job-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.job-head b { font-size: 13px; font-weight: 650; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-count { font-size: 12px; color: var(--text2); flex: none; }
.job-prog { height: 5px; background: var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.job-prog-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width .25s; }
.job-row.job-done .job-prog-bar { background: var(--green); }
.job-row.job-error .job-prog-bar { background: var(--red); }
.job-items { display: flex; flex-direction: column; gap: 3px; max-height: 140px; overflow-y: auto; }
.job-item { display: flex; gap: 7px; font-size: 12px; color: var(--text2); align-items: flex-start; }
.job-item .ji-ic { flex: none; width: 16px; text-align: center; }
.job-item.ok .ji-ic { color: var(--green); }
.job-item.fail .ji-ic { color: var(--red); }
.job-item.fail .ji-lbl { color: var(--text); }
.job-item .ji-lbl { flex: 1; line-height: 1.35; }
.job-item .ji-note { display: block; color: var(--text3); font-size: 11px; }
.job-item .ji-ic .spinner.sm { width: 13px; height: 13px; }
.job-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.job-actions:empty { display: none; }
.job-actions .btn.sm { min-height: 32px; padding: 5px 12px; font-size: 12.5px; }
