:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --ink: #1c1e26;
  --muted: #6b7280;
  --brand: #1a2040;
  --brand2: #e97451;
  --accent: #e97451;
  --border: #e3e6ea;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .16);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  min-height: 100vh;
}
img, video { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--brand);
  color: #fff;
  padding: env(safe-area-inset-top) 16px 0;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.topbar-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand-text { font-weight: 800; font-size: 19px; letter-spacing: .2px; }
.brand-text span { color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: rgba(255,255,255,.12); color: #fff; border: none; border-radius: 50%;
  width: 42px; height: 42px; display: grid; place-items: center; cursor: pointer; position: relative;
}
.icon-btn:active { transform: scale(.95); }
.user-chip { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.12); padding: 5px 12px 5px 5px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14px; color: #fff; }
.chip-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: #fff; }
.has-cnt::after {
  content: ''; position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: #ff5252; border: 1.5px solid #fff;
}

/* ---------- Layout ---------- */
.layout { max-width: 1200px; margin: 0 auto; padding: 16px 12px 80px; display: grid; grid-template-columns: 240px 1fr 300px; gap: 16px; }
.sidebar { position: sticky; top: 76px; align-self: start; display: flex; flex-direction: column; gap: 12px; }
.sidebar nav { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px;
  color: var(--ink); font-weight: 600; font-size: 15px;
}
.sidebar nav a:hover { background: #f0f2f5; }
.sidebar nav a.active { background: #fff0ea; color: var(--brand2); }
.n-ico { font-size: 18px; }
.badge {
  margin-left: auto; background: var(--accent); color: #fff; font-size: 10px; font-weight: 800;
  padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .4px;
}
.sidebar-footer { font-size: 12px; color: var(--muted); text-align: center; padding: 8px; }

.content { min-width: 0; }
.right-rail { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Cards / posts ---------- */
.feed-item, .card, .side-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.feed-item { margin-bottom: 14px; }
.post-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 4px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: #e5e7eb; }
.post-author { font-weight: 700; font-size: 14.5px; }
.post-author small { font-weight: 500; color: var(--muted); }
.post-time { font-size: 12px; color: var(--muted); }
.post-cat {
  margin-left: auto; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  background: #eef2ff; color: #3b4db8; padding: 3px 9px; border-radius: 999px;
}
.post-cat.noticias { background: #ffebee; color: #d32f2f; }
.post-cat.memes { background: #fff8e1; color: #b8860b; }
.post-cat.chismes { background: #f3e8ff; color: #7b1fa2; }
.post-cat.eventos { background: #e0f7fa; color: #00838f; }
.post-cat.clasificados { background: #e8f5e9; color: #2e7d32; }
.post-body { padding: 8px 16px 6px; font-size: 15.5px; white-space: pre-wrap; word-break: break-word; }
.post-media { margin: 6px 0 0; background: #000; }
.post-media img, .post-media video { width: 100%; max-height: 480px; object-fit: contain; }
.post-source { padding: 4px 16px 0; font-size: 12px; color: var(--muted); }
.post-source a { color: var(--muted); text-decoration: underline; }
.post-actions { display: flex; border-top: 1px solid var(--border); margin-top: 8px; }
.pa {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px; background: none; border: none; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--muted); font-size: 14px;
}
.pa:hover { background: #f7f8fa; }
.pa.liked { color: #e0574c; }
.pa .cnt { font-variant-numeric: tabular-nums; }
.comments { border-top: 1px solid var(--border); background: #fafbfc; padding: 10px 14px 14px; }
.cmt { display: flex; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.cmt .avatar { width: 32px; height: 32px; }
.cmt-bubble { background: #eef1f5; border-radius: 12px; padding: 8px 12px; }
.cmt-bubble b { font-size: 13px; }
.ia-tag {
  display: inline-block; vertical-align: middle; margin-left: 5px;
  background: #e0e7ff; color: #4f46e5; font-size: 9.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .3px; padding: 1px 6px; border-radius: 999px;
}
.cmt-thread { margin-left: 40px; margin-top: 2px; }
.cmt-reply { margin-bottom: 6px; }
.cmt-reply .cmt-bubble { background: #e9eef6; }
.cmt-input { display: flex; gap: 8px; margin-top: 8px; }
.cmt-input input {
  flex: 1; border: 1px solid var(--border); border-radius: 999px; padding: 9px 14px; font: inherit; outline: none;
}
.cmt-input input:focus { border-color: var(--accent); }

/* ---------- Compose box ---------- */
.compose {
  display: flex; gap: 12px; padding: 14px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px;
}
.compose > div { flex: 1; min-width: 0; }
.compose textarea {
  flex: 1; width: 100%; box-sizing: border-box; border: none; outline: none; resize: vertical; font: inherit; font-size: 15px; line-height: 1.5; min-height: 68px; padding: 10px 2px;
}
.compose-sel { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.compose-sel select { border: 1px solid var(--border); border-radius: 999px; padding: 6px 10px; font: inherit; font-size: 13px; background: #fff; }
.compose-video { margin-top: 6px; }
.compose-video input {
  width: 100%; border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 13px; color: var(--muted); outline: none;
}
.compose-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.media-actions { display: flex; gap: 6px; }
.media-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 999px; width: 40px; height: 40px;
  display: grid; place-items: center; cursor: pointer; font-size: 18px;
}
.media-btn:disabled { opacity: .4; cursor: not-allowed; }
.media-preview { margin-top: 8px; position: relative; max-width: 260px; }
.media-preview img, .media-preview video { border-radius: 10px; max-height: 200px; }
.media-preview button { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.65); color: #fff; border: none; border-radius: 50%; width: 26px; height: 26px; cursor: pointer; }

/* ---------- Buttons ---------- */
.btn {
  border: none; cursor: pointer; font: inherit; font-weight: 700; border-radius: 999px;
  padding: 10px 18px; font-size: 14.5px; transition: .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #232a55; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(1.08); }
.btn-ghost { background: #eef1f5; color: var(--ink); }
.btn-block { display: block; width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; background: rgba(12,14,24,.55); padding: 16px; backdrop-filter: blur(3px); }
.modal.open { display: flex; }
.modal-card {
  background: #fff; border-radius: 18px; max-width: 430px; width: 100%; max-height: 92vh; overflow: auto;
  padding: 26px 24px; box-shadow: var(--shadow-lg); position: relative;
}
.modal-card h2 { font-size: 22px; margin-bottom: 4px; }
.modal-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px; padding: 11px 13px; font: inherit; outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--brand2); }
.form-err { color: #d32f2f; font-size: 13px; margin-bottom: 10px; min-height: 18px; }
.modal-foot { text-align: center; margin-top: 14px; font-size: 13.5px; color: var(--muted); }
.modal-foot a { font-weight: 700; }
.close-x { position: absolute; top: 14px; right: 14px; background: #f0f2f5; border: none; border-radius: 50%; width: 32px; height: 32px; cursor: pointer; font-size: 16px; }

/* ---------- Profile ---------- */
.profile-banner {
  background: linear-gradient(120deg, #1a2040, #e97451); height: 130px; border-radius: var(--radius) var(--radius) 0 0;
}
.profile-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 16px; }
.profile-info { padding: 0 18px 18px; position: relative; }
.profile-info .avatar { width: 92px; height: 92px; margin-top: -46px; border: 4px solid #fff; }
.profile-info h2 { margin-top: 6px; font-size: 20px; }
.profile-info .btn { float: right; margin-top: 8px; }
.profile-bio { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ---------- News header ---------- */
.news-flag {
  display: flex; align-items: center; gap: 10px; background: linear-gradient(100deg, #461a1a, #d32f2f);
  color: #fff; padding: 14px 18px; border-radius: var(--radius); margin-bottom: 14px; box-shadow: var(--shadow);
}
.news-flag h2 { font-size: 19px; }
.news-flag p { opacity: .85; font-size: 13px; }

/* ---------- Ads ---------- */
.ad-slot {
  background: #fff; border: 1px dashed #d7dbe0; border-radius: 10px;
  display: grid; place-items: center; color: var(--muted); font-size: 12px; overflow: hidden;
}
/* Sin anuncio servido el hueco no debe verse: AdSense pone data-ad-status="unfilled". */
.ad-slot:has(ins[data-ad-status="unfilled"]) { display: none; }
.ad-slot ins { display: block; width: 100%; }
.ad-slot-rail { min-height: 250px; }
.side-card { padding: 18px; }
.side-card h4 { font-size: 16px; margin-bottom: 6px; }
.side-card .muted { font-size: 13.5px; margin-bottom: 14px; }

/* ---------- In-feed ad ---------- */
.feed-ad { padding: 0; border: 1px dashed #d5dae1; background: #fff; min-height: 0; }
.feed-ad:has(ins[data-ad-status="unfilled"]) { display: none; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: #1c1e26; color: #fff; padding: 11px 20px; border-radius: 999px; font-size: 14px; font-weight: 600;
  z-index: 200; opacity: 0; transition: .3s; pointer-events: none; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.skeleton { background: linear-gradient(90deg,#eef1f4 25%,#f7f8fa 50%,#eef1f4 75%); background-size: 400% 100%; animation: sh 1.4s infinite; border-radius: 10px; height: 100px; margin-bottom: 12px; }
@keyframes sh { 0%{background-position:100% 0} 100%{background-position:-100% 0} }

/* ---------- Video embed ---------- */
.video-embed-wrap { position: relative; margin: 8px 0 0; background: #0b0d12; }
.video-frame { position: relative; padding-top: 56.25%; border-radius: 12px; overflow: hidden; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-thumb {
  position: relative; padding-top: 56.25%; cursor: pointer; background: #0b0d12; border-radius: 12px; overflow: hidden;
}
.video-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .92; }
.play-btn {
  position: absolute; inset: 0; margin: auto; width: 62px; height: 62px; border-radius: 50%;
  background: rgba(233,116,81,.95); color: #fff; font-size: 24px;
  display: grid; place-items: center; box-shadow: 0 4px 18px rgba(0,0,0,.4);
  transition: transform .15s;
}
.video-thumb:hover .play-btn { transform: scale(1.1); }

/* ---------- Leer más ---------- */
.post-body.clamp-news {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; position: relative;
}
.post-body.clamp-news.expanded { display: block; overflow: visible; -webkit-line-clamp: unset; }
.more-btn {
  display: inline-block; margin-top: 6px; background: none; border: none; cursor: pointer;
  color: var(--accent); font: inherit; font-weight: 700; font-size: 14px; padding: 0;
}
.more-btn:hover { text-decoration: underline; }

/* ---------- Mobile ---------- */
@media (max-width: 1024px) {
  .right-rail { display: none; }
  .layout { grid-template-columns: 70px 1fr; padding: 12px 8px 90px; }
  .sidebar nav a span:not(.n-ico) { display: none; }
  .sidebar nav a { justify-content: center; }
  .brand-text { display: none; }
}
@media (max-width: 620px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
@media (min-width: 300px) and (max-width: 620px) {
  .ad-slot-rail { display: none; }
}
.pillar-ico { color: var(--accent); display: flex; align-items: center; margin-right: 4px; }
