:root {
  --bg: #fbfaf7;
  --bg-elev: #ffffff;
  --sidebar-bg: #f1efe9;
  --text: #1f2430;
  --text-soft: #5b6172;
  --text-faint: #9aa0b0;
  --accent: #b4441f;
  --accent-soft: #f3ddd3;
  --border: #e3e0d6;
  --done: #2f7d4f;
  --done-soft: #dff0e4;
  --code-bg: #2b2b2b;
  --code-text: #f3f3f3;
  --radius: 8px;
  --sidebar-w: 320px;
}

[data-tema="oscuro"] {
  --bg: #15171c;
  --bg-elev: #1c1f26;
  --sidebar-bg: #111318;
  --text: #e7e6e1;
  --text-soft: #a8acb8;
  --text-faint: #6b7080;
  --accent: #e07a4f;
  --accent-soft: #3a2519;
  --border: #2a2e38;
  --done: #5cc585;
  --done-soft: #1d2e22;
  --code-bg: #0f1115;
  --code-text: #e7e6e1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

.skip-link {
  position: absolute;
  left: -999px;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 10;
  background: var(--accent);
  color: #fff;
  padding: .5rem 1rem;
  border-radius: var(--radius);
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.sidebar__title {
  font-size: 1.15rem;
  margin: 0;
  letter-spacing: .01em;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.sidebar__title:hover { color: var(--accent); }

.sidebar__acciones { display: flex; gap: .4rem; }

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  padding: .3rem .5rem;
  cursor: pointer;
  color: var(--text);
}
.icon-btn:hover { border-color: var(--accent); }

.progreso-global { margin-bottom: 1.25rem; }
.progreso-global__barra {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progreso-global__fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--done);
  transition: width .35s ease;
}
.progreso-global__texto {
  margin: .4rem 0 0;
  font-size: .8rem;
  color: var(--text-soft);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.indice { font-family: ui-sans-serif, system-ui, sans-serif; }

.indice__curso { margin: 0; }
.indice__curso > summary {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-faint);
  cursor: pointer;
  padding: .4rem 0;
}

.indice__asig { margin: .25rem 0 .75rem; }
.indice__asig > summary {
  font-weight: 600;
  font-size: .9rem;
  padding: .35rem .25rem;
  cursor: pointer;
  border-radius: var(--radius);
  list-style: none;
}
.indice__asig > summary::-webkit-details-marker { display: none; }
.indice__asig > summary:hover { background: var(--bg-elev); }

.indice__asig-prog {
  font-size: .72rem;
  color: var(--text-faint);
  font-weight: 400;
  margin-left: .35rem;
}

.indice__lista { list-style: none; margin: .15rem 0 0; padding: 0 0 0 .35rem; }

.tema-btn {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  padding: .35rem .5rem;
  cursor: pointer;
  color: var(--text-soft);
  font-size: .85rem;
  font-family: inherit;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.tema-btn:hover { background: var(--bg-elev); color: var(--text); }
.tema-btn[aria-current="true"] {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
.tema-btn__num { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.tema-btn--pendiente { opacity: .55; }
.tema-btn--hecho .tema-btn__num::after { content: " ✓"; color: var(--done); }

/* ---------- Contenido ---------- */
.contenido { padding: 3rem clamp(1rem, 5vw, 5rem); outline: none; }
.lectura { max-width: 72ch; margin: 0 auto; }

.lectura h1, .lectura h2, .lectura h3 { line-height: 1.25; }
.lectura h1 { font-size: 2rem; margin-top: 0; }
.lectura h2 { font-size: 1.45rem; margin-top: 2.2rem; border-bottom: 1px solid var(--border); padding-bottom: .3rem; }
.lectura h3 { font-size: 1.15rem; margin-top: 1.6rem; }
.lectura a { color: var(--accent); }
.lectura code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--accent-soft);
  padding: .1rem .35rem;
  border-radius: 4px;
  font-size: .9em;
}
.lectura pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  overflow-x: auto;
}
.lectura pre code { background: none; padding: 0; color: inherit; font-size: .85rem; }
.lectura blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.2rem 0;
  padding: .3rem 1rem;
  color: var(--text-soft);
  background: var(--bg-elev);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.lectura table { border-collapse: collapse; width: 100%; font-family: ui-sans-serif, system-ui, sans-serif; font-size: .9rem; }
.lectura th, .lectura td { border: 1px solid var(--border); padding: .5rem .7rem; text-align: left; }
.lectura th { background: var(--bg-elev); }

/* ---------- Hero / landing ---------- */
.hero { animation: subir .5s ease both; }
.hero__eyebrow {
  font-family: ui-sans-serif, system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .72rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 .75rem;
}
.hero__titulo {
  font-size: clamp(2.1rem, 5vw, 3.1rem);
  line-height: 1.1;
  margin: 0 0 1rem;
  letter-spacing: -.01em;
}
.hero__lede {
  font-size: 1.2rem;
  color: var(--text-soft);
  max-width: 60ch;
  margin: 0 0 2.5rem;
}
.hero__que h2 {
  font-size: 1rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-faint);
  border: none;
  margin: 0 0 .75rem;
  padding: 0;
}
.hero__lista {
  list-style: none;
  padding: 0;
  margin: 0 0 2.5rem;
  display: grid;
  gap: .85rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.hero__lista li {
  position: relative;
  padding-left: 1.6rem;
  color: var(--text-soft);
}
.hero__lista li::before {
  content: "›";
  position: absolute;
  left: 0;
  top: -.05rem;
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 700;
}
.hero__lista strong { color: var(--text); }
.hero__nota {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  color: var(--text);
  font-size: .95rem;
  margin: 0 0 2.5rem;
}
.hero__footer {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .9rem;
  color: var(--text-soft);
}
.hero__link { color: var(--accent); text-decoration: none; font-weight: 600; }
.hero__link:hover { text-decoration: underline; }

@keyframes subir {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.aviso-pendiente {
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  color: var(--text-soft);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .contenido { padding: 2rem 1.25rem; }
}
