:root {
  --bg: #ffffff;
  --bg-alt: #f6f7fb;
  --text: #1a1c23;
  --text-muted: #5b5f6b;
  --border: #e5e7ee;
  --brand: #4338ca;
  --brand-dark: #322a9c;
  --brand-contrast: #ffffff;
  --card-bg: #ffffff;
  --radius: 14px;
  --max-width: 1080px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101116;
    --bg-alt: #171922;
    --text: #eef0f6;
    --text-muted: #a3a7b7;
    --border: #2a2d3a;
    --brand: #8b7bff;
    --brand-dark: #a599ff;
    --brand-contrast: #12131a;
    --card-bg: #181a24;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

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

img { max-width: 100%; display: block; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 50;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--brand);
  color: var(--brand-contrast);
  font-weight: 800;
}

.site-nav {
  display: flex;
  gap: 24px;
}

.nav-link {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
}
.nav-link.active, .nav-link:hover {
  color: var(--text);
  text-decoration: none;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.nav-toggle span {
  width: 22px;
  height: 2px;
  background: var(--text);
  display: block;
}

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .site-nav {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 12px 20px 20px;
    gap: 14px;
    display: none;
  }
  .site-nav.open { display: flex; }
}

/* Hero */
.hero {
  padding: 72px 0 48px;
  text-align: center;
  background: linear-gradient(180deg, var(--bg-alt), var(--bg));
}
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  max-width: 780px;
  margin: 0 auto 16px;
}
.hero-sub {
  max-width: 620px;
  margin: 0 auto 28px;
  color: var(--text-muted);
  font-size: 1.05rem;
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

/* Sections */
.section-title {
  font-size: 1.4rem;
  margin: 48px 0 20px;
}
.page-header {
  padding: 48px 0 8px;
}
.page-header h1 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); }

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.card-link {
  display: block;
  padding: 20px;
  color: var(--text);
}
.card-link:hover { text-decoration: none; }
.card-category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand);
  margin-bottom: 8px;
}
.card h3 {
  font-size: 1.05rem;
  margin: 0 0 8px;
}
.card p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0 0 12px;
}
.card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.category-pill {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
  color: var(--text);
}
.category-pill:hover { border-color: var(--brand); text-decoration: none; }

.category-section { margin-bottom: 24px; }

/* Article */
.article { max-width: 760px; padding-top: 40px; padding-bottom: 24px; }
.article-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: 10px 0 12px;
}
.article-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.article-body h2 {
  font-size: 1.35rem;
  margin: 36px 0 12px;
}
.article-body h3 {
  font-size: 1.1rem;
  margin: 28px 0 10px;
}
.article-body p, .article-body li {
  font-size: 1.02rem;
  color: var(--text);
}
.article-body ul, .article-body ol {
  padding-left: 22px;
}
.table-wrap {
  overflow-x: auto;
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.table-wrap th, .table-wrap td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table-wrap thead th {
  background: var(--bg-alt);
  font-weight: 700;
}
.table-wrap tbody tr:last-child td {
  border-bottom: none;
}
.article-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.article-share a { font-weight: 600; }
.related { max-width: 760px; margin: 0 auto; }

.prose { max-width: 760px; }
.prose h2 { margin-top: 32px; }

/* Formulario de contacto */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 520px;
  margin: 24px 0;
}
.contact-form label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 10px;
}
.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
}
.contact-form textarea { resize: vertical; }
.contact-form button {
  margin-top: 16px;
  align-self: flex-start;
}
.contact-form button:disabled { opacity: 0.6; cursor: not-allowed; }
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.form-status { font-size: 0.9rem; min-height: 1.2em; }
.form-status-ok { color: #1a8a4a; }
.form-status-error { color: #c0392b; }
@media (prefers-color-scheme: dark) {
  .form-status-ok { color: #4ade80; }
  .form-status-error { color: #f87171; }
}

.not-found { text-align: center; padding: 80px 0; }
.not-found h1 { font-size: 4rem; margin: 0; }

/* Noticias */
.news-home { margin-top: 8px; }
.news-home-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.news-status {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.news-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.news-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
}
.news-item a {
  color: var(--text);
  font-weight: 600;
  font-size: 1rem;
}
.news-item a:hover { color: var(--brand); }
.news-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.news-empty {
  color: var(--text-muted);
  font-style: italic;
  border-bottom: none;
}

/* Ad slots */
.ad-slot {
  max-width: var(--max-width);
  margin: 32px auto;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  text-align: center;
  background: var(--bg-alt);
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.ad-slot .ad-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  margin-top: 64px;
  padding: 48px 0 24px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 32px;
}
.footer-brand p {
  color: var(--text-muted);
  max-width: 280px;
  font-size: 0.9rem;
}
.footer-links {
  display: flex;
  gap: 48px;
}
.footer-links h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 12px;
}
.footer-links a {
  display: block;
  color: var(--text);
  font-size: 0.92rem;
  margin-bottom: 8px;
}
.footer-bottom {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Cookie banner */
.cookie-banner {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  max-width: 560px;
  margin: 0 auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18);
  z-index: 100;
  font-size: 0.9rem;
}
.cookie-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  justify-content: flex-end;
}

.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
