:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #7c3aed;
  --accent-soft: #ede9fe;
  --code-bg: #f1f5f9;
  --sidebar-w: 17rem;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
}

a:hover {
  text-decoration: none;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 1.25rem 1rem;
  font-weight: 700;
  font-size: 1.05rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.sidebar-brand a {
  color: var(--text);
  text-decoration: none;
}

.sidebar-brand small {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.sidebar nav {
  padding: 0 0.75rem;
}

.nav-section {
  margin-bottom: 1rem;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0.35rem 0.5rem;
}

.nav-section a {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: 0.375rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-section a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-section a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem 4rem;
  max-width: 52rem;
}

.content h1 {
  font-size: 1.85rem;
  line-height: 1.25;
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.content h2 {
  font-size: 1.35rem;
  margin-top: 2rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.content h3 {
  font-size: 1.1rem;
  margin-top: 1.5rem;
}

.content blockquote {
  margin: 0 0 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 0.375rem 0.375rem 0;
  color: #4c1d95;
}

.content blockquote p {
  margin: 0;
}

.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.content ul,
.content ol {
  padding-left: 1.35rem;
}

.content li + li {
  margin-top: 0.25rem;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.95rem;
}

.content th,
.content td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.content th {
  background: var(--code-bg);
}

.content code {
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.12em 0.35em;
  border-radius: 0.25rem;
}

.content pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem 1.15rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.5;
}

.content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.content img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  margin: 1rem 0;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

/* Tamaños opcionales: añade {.img-sm}, {.img-md} o {.img-lg} tras la imagen en Markdown */
.content img.img-sm,
.content figure.img-sm img {
  max-width: min(280px, 100%);
}

.content img.img-md,
.content figure.img-md img {
  max-width: min(480px, 100%);
}

.content img.img-lg,
.content figure.img-lg img {
  max-width: min(720px, 100%);
}

.content figure {
  margin: 1.25rem 0 1.75rem;
  max-width: 100%;
}

.content figure.img-sm {
  max-width: min(280px, 100%);
}

.content figure.img-md {
  max-width: min(480px, 100%);
}

.content figure.img-lg {
  max-width: min(720px, 100%);
}

.content figure img {
  margin: 0;
  width: 100%;
}

.content figcaption {
  margin-top: 0.5rem;
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
}

.content p img:only-child {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.page-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .content {
    padding: 1.5rem 1.25rem 3rem;
  }
}
