:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #1f2a27;
  --muted: #5d6b66;
  --line: #e6e0d6;
  --brand: #2f6b5a;
  --brand-ink: #ffffff;
  --brand-soft: #e3efe9;
  --accent: #c8643f;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 6px 20px rgb(31 42 39 / 0.06);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141917;
    --surface: #1c2320;
    --ink: #e8ece9;
    --muted: #a3b0ab;
    --line: #2c3632;
    --brand: #7cc2a8;
    --brand-ink: #10201a;
    --brand-soft: #1f3029;
    --accent: #f0a07f;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.65 var(--sans);
  text-rendering: optimizeLegibility;
}
img, video, iframe { max-width: 100%; display: block; }
img { height: auto; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 4.5vw, 3rem); margin: 0.2em 0 0.4em; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 1.8em 0 0.5em; }
h3 { font-size: 1.3rem; margin: 1.5em 0 0.4em; }
h4 { font-size: 1.1rem; margin: 1.3em 0 0.3em; }

.wrap { width: min(1160px, 100% - 32px); margin-inline: auto; }
.narrow { width: min(760px, 100% - 32px); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; color: var(--muted); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; z-index: 99; background: var(--surface); padding: 8px 12px; }

/* Cabecera */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.brand { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.site-header nav ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; justify-content: flex-end; }
.site-header nav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 0.93rem; }
.site-header nav a:hover, .site-header nav a[aria-current] { background: var(--brand-soft); color: var(--brand); }
.menu-btn { display: none; }
@media (max-width: 960px) {
  .menu-btn {
    display: block; background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font: inherit; cursor: pointer;
  }
  .site-header nav { position: absolute; inset: 64px 0 auto 0; background: var(--bg); border-bottom: 1px solid var(--line); display: none; }
  .site-header nav.open { display: block; }
  .site-header nav ul { flex-direction: column; padding: 8px 16px 16px; }
  .site-header nav a { padding: 12px; font-size: 1rem; }
}

/* Portada */
.hero { background: linear-gradient(180deg, var(--brand-soft), transparent); padding: clamp(32px, 6vw, 80px) 0 32px; }
.hero-inner { display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(24px, 4vw, 56px); align-items: center; }
.hero h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); }
.kicker { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.78rem; font-weight: 700; color: var(--accent); margin: 0; }
.lead { font-size: 1.1rem; color: var(--muted); }
.checks { list-style: none; padding: 0; margin: 16px 0 24px; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.checks li::before { content: '✓ '; color: var(--brand); font-weight: 700; }
.hero-img img { border-radius: 24px; box-shadow: var(--shadow); width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-block; background: var(--brand); color: var(--brand-ink); text-decoration: none;
  padding: 12px 22px; border-radius: 999px; font-weight: 600; border: 2px solid var(--brand);
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
@media (max-width: 860px) { .hero-inner { grid-template-columns: 1fr; } }

.patches { margin: 8px auto 32px; }
.patch-strip { list-style: none; margin: 0; padding: 4px 2px 12px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(140px, 42%); gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.patch-strip li { scroll-snap-align: start; }
.patch { display: flex; flex-direction: column; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--ink); text-decoration: none; box-shadow: var(--shadow); transition: transform 0.15s ease, border-color 0.15s ease; }
.patch:hover { transform: translateY(-2px); border-color: var(--brand); }
.patch img { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--brand-soft); }
.patch-name { padding: 10px 12px 0; font-family: var(--serif); font-size: 1.05rem; font-weight: 600; }
.patch-use { padding: 2px 12px 12px; font-size: 0.82rem; color: var(--muted); line-height: 1.35; }
@media (min-width: 640px) { .patch-strip { grid-auto-columns: minmax(150px, 23%); } }
@media (min-width: 1000px) { .patch-strip { grid-auto-flow: row; grid-template-columns: repeat(7, 1fr); overflow: visible; } }
.quick { margin-top: 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.tile {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; text-decoration: none; color: var(--ink); font-weight: 600; box-shadow: var(--shadow);
}
.tile:hover { border-color: var(--brand); color: var(--brand); }
.home-content { margin-top: 32px; }
.latest { margin: 56px auto 72px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section-head h2 { margin: 0 0 16px; }

/* Tarjetas */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow); transition: transform 0.15s ease, border-color 0.15s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--brand); color: var(--ink); }
.card-img { aspect-ratio: 16 / 10; background: var(--brand-soft); overflow: hidden; display: grid; place-items: center; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-ph { font-size: 2.6rem; }
.card-body { padding: 14px 16px 18px; }
.card-body h3 { font-size: 1.08rem; margin: 2px 0 8px; }
.card time { font-size: 0.8rem; color: var(--muted); }
.tags { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { font-size: 0.75rem; background: var(--brand-soft); color: var(--brand); padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.db { margin: 8px 0 32px; }
/* las rejillas de bases de datos rompen el ancho de lectura */
.prose .db { width: min(1160px, 100vw - 32px); margin-left: 50%; transform: translateX(-50%); }
.db-title { font-size: 1.4rem; }

/* Página */
.cover { height: clamp(160px, 26vw, 300px); overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.page { padding-bottom: 64px; }
.page-head { margin: 28px 0 8px; }
.cover + .wrap .page-head { margin-top: 0; }
.page-icon { font-size: 3rem; display: block; margin-top: 24px; }
.cover + .wrap .page-icon { margin-top: -28px; position: relative; }
.meta { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; color: var(--muted); font-size: 0.9rem; }
.crumbs { font-size: 0.85rem; color: var(--muted); margin-top: 20px; }
.crumbs a { color: var(--muted); }

.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1em; }
.prose li { margin: 0.25em 0; }
.prose figure { margin: 1.6em 0; }
.prose figure img { border-radius: 12px; margin-inline: auto; }
figcaption { font-size: 0.85rem; color: var(--muted); text-align: center; margin-top: 8px; }
blockquote { margin: 1.4em 0; padding: 0.2em 0 0.2em 1.1em; border-left: 4px solid var(--brand); font-family: var(--serif); font-size: 1.12rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
code { font-size: 0.9em; background: var(--brand-soft); padding: 0.1em 0.35em; border-radius: 5px; }
pre { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); padding: 14px; border-radius: 10px; }
pre code { background: none; padding: 0; }
.indent { padding-left: 1.4em; }
.callout { display: flex; gap: 12px; padding: 14px 18px; border-radius: 12px; margin: 1.2em 0; }
.callout > div > :last-child { margin-bottom: 0; }
.callout h2, .callout h3, .callout h4 { margin-top: 0; }
.callout-icon { font-size: 1.3rem; line-height: 1.4; }
details.toggle { border: 1px solid var(--line); border-radius: 12px; padding: 4px 16px; margin: 1em 0; background: var(--surface); }
details.toggle > summary { cursor: pointer; padding: 10px 0; font-weight: 600; }
details.toggle > summary > h2, details.toggle > summary > h3, details.toggle > summary > h4 { display: inline; margin: 0; }
details.toggle[open] > summary { margin-bottom: 6px; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; margin: 1em 0; }
.table-wrap { overflow-x: auto; margin: 1.2em 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--brand-soft); }
.todos { list-style: none; padding-left: 0 !important; }
.todo .box { display: inline-grid; place-items: center; width: 1.1em; height: 1.1em; border: 1.5px solid var(--muted); border-radius: 4px; font-size: 0.8em; }
.todo.done { color: var(--muted); text-decoration: line-through; }

.subpage, .bookmark {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; margin: 10px 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink);
}
.subpage { flex-direction: row; gap: 10px; font-weight: 600; }
.subpage:hover, .bookmark:hover { border-color: var(--brand); color: var(--brand); }
.bm-title { font-weight: 600; overflow-wrap: anywhere; }
.bm-note, .bm-host { font-size: 0.82rem; color: var(--muted); }
.mention { font-weight: 600; }

.embed .frame { width: 100%; border-radius: 12px; overflow: hidden; background: #000; }
.embed iframe { width: 100%; height: 100%; border: 0; }
.embed video, .embed audio { width: 100%; border-radius: 12px; }
.yt { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0; border-radius: 12px; overflow: hidden; cursor: pointer; background: #000; }
.yt img { width: 100%; height: 100%; object-fit: cover; opacity: 0.88; }
.yt .play { position: absolute; inset: 0; margin: auto; width: 72px; height: 50px; background: #e62117; border-radius: 14px; }
.yt .play::after { content: ''; position: absolute; inset: 0; margin: auto; width: 0; height: 0; border-style: solid; border-width: 11px 0 11px 19px; border-color: transparent transparent transparent #fff; transform: translateX(3px); }
.yt:hover .play { background: #ff0000; }
.vid-drive { background: radial-gradient(circle at 30% 30%, #6f9a7d, #2f4f3c); }
.vid-drive .play { background: rgba(255, 255, 255, 0.92); border-radius: 50%; width: 68px; height: 68px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); }
.vid-drive .play::after { border-color: transparent transparent transparent #2f4f3c; }
.vid-drive:hover .play { background: #fff; transform: scale(1.06); }
.vid-label { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; color: #fff; font-weight: 600; font-size: 0.95rem; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5); }

/* Colores de Notion */
.c-gray { color: #787774; } .c-brown { color: #9f6b53; } .c-orange { color: #d9730d; } .c-yellow { color: #cb912f; }
.c-green { color: #448361; } .c-blue { color: #337ea9; } .c-purple { color: #9065b0; } .c-pink { color: #c14c8a; } .c-red { color: #d44c47; }
.bg-gray { background: #f1f1ef; } .bg-brown { background: #f4eeee; } .bg-orange { background: #fbecdd; } .bg-yellow { background: #fbf3db; }
.bg-green { background: #edf3ec; } .bg-blue { background: #e7f3f8; } .bg-purple { background: #f6f3f9; } .bg-pink { background: #faf1f5; } .bg-red { background: #fdebec; }
span[class^='bg-'] { padding: 0 0.2em; border-radius: 4px; }
@media (prefers-color-scheme: dark) {
  .bg-gray, .bg-brown, .bg-orange, .bg-yellow, .bg-green, .bg-blue, .bg-purple, .bg-pink, .bg-red { background: var(--brand-soft); }
  .c-gray, .c-brown, .c-orange, .c-yellow, .c-green, .c-blue, .c-purple, .c-pink, .c-red { filter: brightness(1.4); }
}

/* Pie */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 40px 0 28px; margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 32px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 24px; }
.site-footer li { margin: 0 0 8px; break-inside: avoid; }
.site-footer a { color: var(--ink); }
.disclaimer { font-size: 0.85rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 18px; margin-top: 24px; }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr; } }

.notfound { padding: 80px 0; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card { transition: none; }
}
