:root {
  --bg: #0e1013;
  --bg2: #161a20;
  --card: #1a1f27;
  --border: #262d38;
  --text: #e8ecf1;
  --muted: #8b95a3;
  --accent: #ff4d4d;
  --accent2: #ff8a4d;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
html, body { overflow-x: hidden; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(14, 16, 19, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 14px 18px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.brand-logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; font-size: 15px; color: #fff;
  box-shadow: 0 3px 12px rgba(255, 77, 77, .35);
}
.brand-name { font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.accent { color: var(--accent); }

.searchbox { flex: 1; max-width: 420px; margin-left: auto; }
.searchbox input {
  width: 100%; padding: 10px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text);
  font-size: 14px; outline: none; transition: border-color .15s;
}
.searchbox input:focus { border-color: var(--accent); }
.btn-reload {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; font-size: 18px;
  transition: transform .3s;
}
.btn-reload:hover { border-color: var(--accent); }
.btn-reload.spin { animation: spin .6s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Categorías */
.categories {
  max-width: 1080px; margin: 0 auto; padding: 14px 18px 4px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.pill {
  padding: 7px 15px; border-radius: 999px; cursor: pointer;
  background: var(--bg2); border: 1px solid var(--border); color: var(--muted);
  font-size: 13px; font-weight: 600; transition: all .15s;
}
.pill:hover { color: var(--text); border-color: var(--accent); }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill .count { opacity: .75; font-weight: 400; margin-left: 4px; }
.pill-loading { color: var(--muted); font-size: 13px; padding: 7px 4px; }

/* Feed */
main { flex: 1; width: 100%; }
.layout {
  display: grid; gap: 20px; max-width: 1400px; margin: 0 auto; padding: 18px;
  grid-template-columns: 1fr;
}
@media (min-width: 1200px) {
  .layout { grid-template-columns: 300px minmax(0, 1fr) 300px; }
  .main-col { min-width: 0; }
}
.rail { display: none; flex-direction: column; gap: 16px; }
@media (min-width: 1200px) { .rail { display: flex; } }
.layout.no-rails { grid-template-columns: minmax(0, 1fr); max-width: 1080px; }
.rail .ad-box { position: sticky; top: 84px; }
.feed {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); }
.card-img {
  aspect-ratio: 16/9; background: var(--bg2); position: relative; overflow: hidden;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-img .ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; opacity: .5; }
.card-img .badge {
  position: absolute; top: 10px; left: 10px;
  background: rgba(255, 77, 77, .92); color: #fff;
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .4px;
}
.badge-video { background: rgba(124, 58, 237, .92) !important; }
.card-play {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0, 0, 0, .3); z-index: 2; pointer-events: none;
}
.card-play span {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255, 77, 77, .92); color: #fff;
  display: grid; place-items: center; font-size: 20px; padding-left: 4px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .45);
}
.modal-video { margin: 8px 0 14px; }
.modal-video video {
  width: 100%; max-height: 62vh; border-radius: 12px; background: #000;
  aspect-ratio: 9/16; object-fit: contain;
}
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.card-meta .dot { opacity: .5; }
.card-source { font-weight: 700; color: var(--accent2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-title { font-size: 16px; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-summary { font-size: 13.5px; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-keywords { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.tag { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--border); color: var(--muted); }

/* Estado */
.status { text-align: center; color: var(--muted); padding: 28px 0; font-size: 14px; }
.status .loader { display: inline-block; width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin-right: 8px; vertical-align: middle; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .7); z-index: 100;
  display: grid; place-items: center; padding: 20px;
}
.modal-overlay[hidden] { display: none !important; }
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  max-width: 720px; width: 100%; max-height: 88vh; overflow-y: auto; position: relative;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text); font-size: 15px; cursor: pointer;
  display: grid; place-items: center;
}
.modal-body { padding: 6px 22px 24px; }
.modal-body img { width: 100%; border-radius: 12px; margin: 6px 0 14px; aspect-ratio: 16/9; object-fit: cover; }
.modal-title { font-size: 22px; font-weight: 800; line-height: 1.3; margin-bottom: 10px; }
.modal-meta { font-size: 13px; color: var(--muted); margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.modal-summary { font-size: 16px; line-height: 1.65; color: var(--text); margin-bottom: 16px; }
.modal-original { display: inline-block; padding: 11px 20px; border-radius: 10px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 700; font-size: 14px; }
.modal-original:hover { background: #ff6b6b; }

/* Publicidad */
.marquee-wrap { max-width: 1080px; margin: 12px auto 0; padding: 0 18px; }
.marquee {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: #fff; border-radius: 10px; overflow: hidden; white-space: nowrap;
  box-shadow: 0 3px 14px rgba(255, 77, 77, .25);
}
.marquee-track {
  display: block;
  width: max-content;
  padding: 9px 0;
  font-weight: 700;
  font-size: 14px;
  animation: marquee 28s linear infinite;
  will-change: transform;
}
.marquee-track a { color: #fff; text-decoration: none; }
.marquee-track span { padding: 0 40px; }
@keyframes marquee { from { transform: translateX(100%); } to { transform: translateX(-100%); } }

.ad-box {
  border: 1px dashed var(--border); background: var(--bg2); border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden; color: var(--muted); text-align: center;
}
.ad-box .ad-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; opacity: .55; padding: 4px 0 0; }
.ad-box a { display: block; width: 100%; flex: 1; }
.ad-box img, .ad-box video { width: 100%; height: 100%; object-fit: contain; display: block; }
.ad-top { height: 100px; margin-bottom: 18px; }
.ad-top img, .ad-top video { object-fit: cover; max-height: 100px; }
.rail .ad-box { width: 300px; height: 280px; }
.infeed-ad { height: 260px; margin: 4px 0; }

/* Carrusel de anuncios */
.carousel { position: relative; overflow: hidden; background: var(--bg2); border: 1px dashed var(--border); border-radius: 10px; }
.carousel.ad-top { height: 100px; margin-bottom: 18px; }
.carousel.rail-ad { width: 300px; height: 280px; }
.carousel.infeed-ad { height: 260px; margin: 4px 0; }
.carousel .cslides { position: relative; width: 100%; height: 100%; }
.carousel .cslide { position: absolute; inset: 0; opacity: 0; transition: opacity .45s; pointer-events: none; }
.carousel .cslide.active { opacity: 1; pointer-events: auto; }
.carousel img, .carousel video { width: 100%; height: 100%; object-fit: contain; display: block; }
.carousel a { display: block; width: 100%; height: 100%; }

/* Video con botón de sonido */
.vad { position: relative; width: 100%; height: 100%; }
.vad video { width: 100%; height: 100%; object-fit: contain; display: block; }
.vad a { display: block; width: 100%; height: 100%; }
.vad-sound {
  position: absolute; bottom: 8px; right: 8px; z-index: 6;
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(255,255,255,.35);
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 14px; cursor: pointer;
  display: grid; place-items: center; backdrop-filter: blur(2px); line-height: 1;
}
.vad-sound:hover { background: rgba(0, 0, 0, .85); }
.carousel .ad-label {
  position: absolute; top: 0; left: 0; z-index: 3;
  background: rgba(0, 0, 0, .5); color: #fff; font-size: 9px; text-transform: uppercase;
  letter-spacing: 1px; padding: 3px 8px; border-radius: 0 0 8px 0;
}
.carousel .cdot-wrap {
  position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 5px; z-index: 4; background: rgba(0,0,0,.35);
  padding: 3px 7px; border-radius: 999px;
}
.carousel .cdot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.4); cursor: pointer; }
.carousel .cdot.active { background: var(--accent); }

.footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 26px 18px; border-top: 1px solid var(--border); }

@media (max-width: 640px) {
  .feed { grid-template-columns: 1fr; }
  .brand-name { font-size: 19px; }
  .searchbox { max-width: none; }
  .marquee-wrap { padding: 0 10px; }
  .marquee-track { font-size: 12.5px; animation-duration: 20s; }
  .marquee-track span { padding: 0 24px; }
}
