:root {
  --bg-light: linear-gradient(135deg, #0b3d91 0%, #1261a6 48%, #19a7ce 100%);
  --bg-accent: linear-gradient(180deg, #f4f9ff 0%, #eaf4ff 100%);
  --item-bg: #ffffff;
  --item-hover: #e8f4ff;
  --link: #0b4f8a;
  --shadow: 0 20px 54px rgba(17, 55, 93, .16);
  --radius-lg: 20px;
  --text-soft: #eaf7ff;
  --card-border: rgba(18, 97, 166, .16);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  line-height: 1.65;
  color: #17324d;
  background:
    radial-gradient(circle at top right, rgba(25, 167, 206, .16), transparent 28%),
    radial-gradient(circle at left center, rgba(18, 97, 166, .09), transparent 32%),
    linear-gradient(180deg, #f7fbff 0%, #eaf4ff 100%);
}

/* Layout */
.container#contenedor {
  max-width: 1100px;
  margin: 2rem auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.row { display: flex; flex-wrap: wrap; }
.row > .col { flex: 1 1 100%; padding: 1rem; }
.row.align-right { justify-content: flex-end; }

#fila1 { background: var(--bg-light); }
#fila2 { background: var(--bg-accent); }
#fila3 { background: var(--bg-accent); }

/* Header */
.eyebrow {
  display: inline-block;
  margin: 0 0 .75rem 0;
  padding: .35rem .8rem;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  color: var(--text-soft);
  background: rgba(255,255,255,.08);
  font-size: .95rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
h1.title {
  font-size: clamp(2rem, 6vw, 4em);
  margin: 0 0 .25em 0;
  color: #fff;
  text-shadow: 0 6px 16px rgba(0,0,0,.35);
}
.hero-text {
  max-width: 850px;
  margin: 0;
  color: var(--text-soft);
  font-size: clamp(1rem, 2vw, 1.2rem);
}
.header-actions { text-align: right; }
.header-actions a { display: inline-block; margin: .5rem 1rem .5rem 0; }

.btn {
  display: inline-block;
  padding: .5rem 1rem;
  border-radius: .375rem;
  text-decoration: none;
  font-weight: 600;
  transition: filter .15s ease-in-out;
}
.btn:hover { filter: brightness(0.95); }
.btn-success { background: #198754; color: #fff; }

.course-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.highlight-card {
  padding: 1rem 1.1rem;
  border-radius: 14px;
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(18, 97, 166, .14);
  box-shadow: 0 10px 26px rgba(17, 55, 93, .10);
}

.highlight-label {
  display: block;
  margin-bottom: .35rem;
  color: #436b8f;
  font-size: .92rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.highlight-card strong {
  color: #0b3d63;
  font-size: 1.05rem;
}

.section-intro {
  margin-bottom: 1.25rem;
}

.section-intro h2 {
  margin: 0 0 .35rem 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
  color: #0b4f8a;
}

.section-intro p {
  margin: 0;
  color: #3b6689;
}

/* Menu list */
.list-group { box-shadow: 0 10px 28px rgba(11, 33, 55, .14); border-radius: .9rem; overflow: hidden; border: 1px solid var(--card-border); }
.list-group#menu { font-size: 1.5em; }
.list-group-item {
  display: block;
  padding: 1rem 1.1rem;
  background: var(--item-bg);
  color: var(--link);
  text-decoration: none;
  border-top: 1px solid #d8e8f7;
  transition: background-color .2s ease, transform .2s ease, padding-left .2s ease;
}
.list-group-item:first-child { border-top: 0; }
.list-group-item:hover {
  background: var(--item-hover);
  transform: translateX(4px);
  padding-left: 1.2rem;
}

.list-group-item.is-active {
  background: linear-gradient(90deg, #d9efff 0%, #f3f9ff 100%);
  box-shadow: inset 4px 0 0 #168aad;
}


.text-center { text-align: center; }
.pagination { list-style: none; padding: 0; margin: 1rem 0; }
.pagination li { display: inline-block; margin: 0 .25rem; }
.pagination a { display: inline-block; padding: .5rem .75rem; background: #fff; border: 1px solid #ddd; border-radius: .25rem; text-decoration: none; color: inherit; }
.pagination .active a { background: #e9ecef; }

@media (min-width: 768px) {
  .row > .col { flex: 1 1 50%; }
  #fila1 > .col:first-child { flex: 1 1 70%; }
  #fila1 > .col:last-child { flex: 1 1 30%; }
  #fila2 .col, #fila3 .col { flex-basis: 100%; }
}

@media (min-width: 768px) {
  body.tema-page .row > .col {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

body.tema-page {
  background: #edf6ff;
}
.tema-page .container#contenedor { padding: 1rem; }
.titulodetalle {
  background: linear-gradient(135deg, #0b3d91 0%, #1261a6 52%, #19a7ce 100%);
  border-radius: 18px;
  box-shadow: 0 20px 46px rgba(17, 55, 93, .22);
  padding: 1.25rem 1.4rem;
  margin: 1rem 0 2rem 0;
}
.titulodetalle h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  color: #fff;
  text-shadow: 0 6px 16px rgba(0,0,0,.35);
}
.tema-page .titulodetalle .eyebrow { margin-bottom: .6rem; }
.tema-page .titulodetalle .hero-text {
  margin-top: .75rem;
  max-width: 900px;
}
.cuerpodetalle {
  background: linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(245, 250, 255, .98) 100%);
  border: 1px solid #d1e5f7;
  border-radius: 18px;
  padding: 1.25rem 1.4rem;
  box-shadow: 0 18px 40px rgba(17, 55, 93, .10);
  margin-bottom: 2rem;
  font-size: 1.05rem;
}
.cuerpodetalle p {
  margin: 0 0 1em 0;
  text-align: justify;
  text-justify: inter-word;
  color: #17324d;
  font-weight: 400;
}
.cuerpodetalle h2 {
  margin: 1.6rem 0 .6rem;
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  color: #0b4f8a;
}
.cuerpodetalle section:first-of-type h2 { margin-top: 0; }
.cuerpodetalle ul { padding-left: 1.25rem; margin: 0 0 1em 0; }
.cuerpodetalle ol { padding-left: 1.25rem; margin: 0 0 1em 0; }
.cuerpodetalle li { color: #17324d; font-weight: 400; }
.cuerpodetalle a { color: #0b67b2; }
.tema-page .table {
  --bs-table-striped-bg: rgba(220, 239, 255, .62);
}
.tema-page .table thead th {
  background: #d9efff;
  color: #0b3d63;
}
.recuadro {
  background: linear-gradient(180deg, #f8fcff 0%, #edf7ff 100%);
  text-align:left;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size:1rem;
  padding:.75rem 1rem;
  border: 1px solid #bdd9f0;
  border-left: 4px solid #168aad;
  border-radius: 6px;
  color: #17324d;
  box-shadow: 0 8px 20px rgba(17, 55, 93, .08);
  overflow-x:auto;
  margin: .75rem 0 1.25rem 0;
  position: relative;
}

.recuadro-codigo {
  background: #fff8c7;
  border-color: #eadf8f;
  border-left-color: #d6a700;
  cursor: text;
}

.recuadro-codigo pre,
.recuadro-codigo code {
  background: transparent;
}

.recuadro-codigo pre {
  margin: 0;
  padding: 0;
}

.recuadro-codigo code {
  display: block;
  text-indent: 0;
  white-space: pre;
  min-height: 1.65em;
  outline: none;
}

.recuadro-codigo code[contenteditable="true"],
.recuadro-codigo code[contenteditable="plaintext-only"] {
  caret-color: #0b4f8a;
}

.recuadro-codigo.is-editing {
  box-shadow: 0 0 0 3px rgba(22, 138, 173, .18), 0 8px 20px rgba(17, 55, 93, .08);
}

.recuadro-codigo:hover .run-btn,
.recuadro-codigo:focus-within .run-btn {
  opacity: 1;
  transform: translateY(0);
}

.run-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: .85rem;
  color: #0b4f8a;
  background: rgba(255,255,255,.95);
  border: 1px solid #0b4f8a;
  border-radius: 999px;
  padding: .15rem .65rem;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .2s ease, transform .2s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  cursor: pointer;
}

.run-btn:hover,
.run-btn:focus {
  opacity: 1;
  transform: translateY(-1px);
  outline: none;
}

.resultado-ejecucion {
  margin-top: -.6rem;
  background: #eef8ff;
  border-color: #bdd9f0;
  border-left-color: #168aad;
  white-space: pre-wrap;
}

.recuadrooculto { display: none; }
.botonretorno { font-size: 1.1rem; margin-top: 1rem; }
.botonretorno a {
  display: inline-block;
  padding: .7rem 1.2rem;
  background: linear-gradient(135deg, #0b4f8a 0%, #168aad 100%);
  border: 0;
  border-radius: 999px;
  text-decoration: none;
  color: #fff;
  box-shadow: 0 12px 28px rgba(17, 55, 93, .24);
}
.botonretorno a:hover { filter: none; transform: translateY(-1px); }
.botonretorno a.boton-online {
  padding: .85rem 1.4rem;
  background: linear-gradient(135deg, #0f766e 0%, #14b8a6 52%, #67e8f9 100%);
  border: 0;
  border-radius: 999px;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.botonretorno a.boton-online:hover {
  filter: none;
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(15, 118, 110, .35);
}
.botonretorno a.boton-online:active {
  transform: translateY(0);
  box-shadow: 0 10px 20px rgba(15, 118, 110, .24);
}
ul li { margin-bottom: .75rem; }

/* Responsive ad placeholders similar to tema.htm */
.uno { width: 320px; height: 100px; }
@media (min-width: 500px) { .uno { width: 320px; height: 100px; } }
@media (min-width: 800px) { .uno { width: 336px; height: 280px; } }

.dos { width: 320px; height: 100px; }
@media (min-width: 500px) { .dos { width: 320px; height: 100px;} }
@media (min-width: 800px) { .dos { width: 336px; height: 280px; } }

/* Media elements */
.cuerpodetalle img, .cuerpodetalle video { max-width: 100%; height: auto; border-radius: 4px; box-shadow: 0 0 6px #aaa; }
.modal { position: fixed; inset: 0; display: none; z-index: 1000; }
.modal.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal-dialog { position: relative; max-width: 900px; width: calc(100% - 2rem); margin: 5vh auto; background: #fff; border-radius: 8px; box-shadow: 0 20px 50px rgba(0,0,0,.25); overflow: hidden; }
.modal-header, .modal-footer { padding: .75rem 1rem; background: #f6f6f6; }
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 1rem; max-height: 70vh; overflow: auto; }
.modal-close { border: 0; background: transparent; font-size: 1.5rem; line-height: 1; cursor: pointer; }
.modal .recuadro { margin: 0; }
.cuerpodetalle .screenshot { display:block; margin:.5rem auto 1rem; }
.cuerpodetalle code {
  background: #fff9c4;
  border-radius: .25rem;
  padding: .1em .3em;
}

.cannon-game {
  margin: 1rem 0 1.25rem 0;
  border: 1px solid #bdd9f0;
  border-radius: 8px;
  background: #f8fcff;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(17, 55, 93, .08);
}

.cannon-game canvas {
  display: block;
  width: 100%;
  min-height: 260px;
  box-shadow: none;
  border-radius: 0;
}

.cannon-game__controls {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .75rem 1rem;
  border-top: 1px solid #bdd9f0;
  background: linear-gradient(180deg, #f8fcff 0%, #edf7ff 100%);
}

.cannon-game__controls button {
  border: 0;
  border-radius: 999px;
  padding: .55rem 1rem;
  color: #fff;
  background: linear-gradient(135deg, #0b4f8a 0%, #168aad 100%);
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(17, 55, 93, .22);
  cursor: pointer;
}

.cannon-game__controls button:hover {
  transform: translateY(-1px);
}

.cannon-game__controls button:disabled {
  opacity: .68;
  cursor: default;
  transform: none;
}

.cannon-game__controls span {
  color: #17324d;
  font-weight: 600;
}

pre { margin: .75rem 0 1.25rem 0; overflow-x: auto; }
pre code.hljs { display: block; padding: 1rem; border-radius: 6px; }
.recuadro pre { margin: 0; }
.recuadro pre code.hljs { padding: 0; background: transparent; }

@media (max-width: 767px) {
  .container#contenedor { margin: 1rem; }
  .list-group#menu { font-size: 1.1rem; }
  .course-highlights { grid-template-columns: 1fr 1fr; }
  .list-group-item:hover {
    transform: none;
    padding-left: 1rem;
  }
  .cannon-game__controls {
    align-items: stretch;
    flex-direction: column;
  }
  .cannon-game__controls button,
  .cannon-game__controls span {
    width: 100%;
    text-align: center;
  }
}

/* Portada del curso de Teoría de Grafos */
.course-index {
  --graph-navy: #081a2d;
  --graph-blue: #0c3559;
  --graph-cyan: #22d3c5;
  --graph-lime: #c7f464;
  --graph-paper: #f3f7f5;
  color: #172d3d;
  background: #dfe9e6;
}

.course-index .container#contenedor {
  max-width: 1180px;
  margin: 2rem auto;
  border-radius: 24px;
  background: var(--graph-paper);
  box-shadow: 0 30px 80px rgba(8, 26, 45, .2);
}

.course-index #fila1 {
  min-height: 530px;
  align-items: center;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 82% 22%, rgba(34, 211, 197, .16), transparent 27%),
    linear-gradient(135deg, #071827 0%, #0a2c49 58%, #0c4660 100%);
}

.course-index #fila1::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .12;
  background-image: radial-gradient(circle, #fff 1px, transparent 1.5px);
  background-size: 30px 30px;
}

.course-index .course-hero { position: relative; z-index: 2; padding: 4.5rem 4rem; }
.course-index h1.title { max-width: 720px; font-size: clamp(2.7rem, 6vw, 5.2rem); line-height: .98; letter-spacing: -.055em; }
.course-index h1.title span { color: var(--graph-lime); }
.course-index .hero-text { max-width: 650px; margin-top: 1.5rem; color: #c5d9df; font-size: 1.12rem; }
.course-index .eyebrow { color: var(--graph-lime); border-color: rgba(199,244,100,.35); background: rgba(199,244,100,.08); }
.hero-cta { display: inline-flex; gap: .8rem; align-items: center; margin-top: 2rem; padding: .85rem 1.25rem; border-radius: 999px; color: #071827; background: var(--graph-lime); text-decoration: none; font-weight: 800; }
.hero-cta:hover { color: #071827; transform: translateY(-2px); }

.graph-visual { min-height: 390px; position: relative; z-index: 1; }
.graph-orbit { position: absolute; border: 1px solid rgba(197,244,100,.18); border-radius: 50%; }
.orbit-one { width: 310px; height: 310px; top: 35px; left: 12px; }
.orbit-two { width: 220px; height: 220px; top: 80px; left: 58px; border-color: rgba(34,211,197,.24); }
.graph-node { position: absolute; z-index: 2; width: 25px; height: 25px; border: 6px solid #0b314d; border-radius: 50%; background: var(--graph-lime); box-shadow: 0 0 0 4px rgba(199,244,100,.14), 0 0 28px rgba(199,244,100,.35); }
.node-a { top: 68px; left: 100px; }.node-b { top: 105px; left: 257px; }.node-c { top: 226px; left: 270px; }.node-d { top: 292px; left: 120px; }.node-e { top: 185px; left: 45px; background: var(--graph-cyan); }
.graph-edge { position: absolute; z-index: 1; height: 2px; background: linear-gradient(90deg, var(--graph-cyan), rgba(199,244,100,.7)); transform-origin: left center; }
.edge-a { width: 163px; top: 84px; left: 112px; transform: rotate(14deg); }.edge-b { width: 123px; top: 116px; left: 270px; transform: rotate(83deg); }.edge-c { width: 174px; top: 236px; left: 284px; transform: rotate(157deg); }.edge-d { width: 130px; top: 304px; left: 132px; transform: rotate(213deg); }.edge-e { width: 151px; top: 195px; left: 59px; transform: rotate(-48deg); }

.course-index #fila2 { padding: 4rem 3rem; gap: 2rem; align-items: center; background: #eaf1ee; }
.course-intro { flex: 1 1 62% !important; }
.course-intro h2, .section-heading h2 { margin: 0 0 1.2rem; color: var(--graph-navy); font-size: clamp(2rem, 4vw, 3.25rem); line-height: 1.08; letter-spacing: -.04em; }
.course-intro p:not(.section-kicker) { max-width: 760px; color: #405868; font-size: 1.08rem; }
.course-intro a { color: #087b74; font-weight: 650; }
.section-kicker { margin: 0 0 .55rem; color: #087b74; font-size: .78rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.course-summary { display: grid; flex: 1 1 30% !important; grid-template-columns: 1fr 1fr; gap: .8rem; }
.summary-card { min-height: 118px; padding: 1.2rem; display: flex; flex-direction: column; justify-content: end; border: 1px solid #cbdad5; border-radius: 16px; background: rgba(255,255,255,.65); }
.summary-card:last-child { grid-column: 1 / -1; background: var(--graph-navy); }
.summary-card strong { color: #087b74; font-size: 2.1rem; line-height: 1; }.summary-card span { margin-top: .35rem; color: #58706f; font-size: .84rem; }.summary-card:last-child strong { color: var(--graph-lime); }.summary-card:last-child span { color: #b7c9cd; }

.course-index #fila3 { padding: 4rem 3rem 5rem; background: var(--graph-paper); }
.syllabus { padding: 0 !important; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }
.section-heading h2 { margin: 0; }.section-heading > p { max-width: 430px; margin: 0 0 .35rem; color: #58706f; }
.topic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.topic-module { overflow: hidden; border: 1px solid #cfddd8; border-radius: 18px; background: #fff; box-shadow: 0 12px 30px rgba(8, 26, 45, .06); }
.module-heading { display: flex; gap: 1rem; align-items: center; padding: 1.2rem 1.35rem; border-bottom: 1px solid #dce7e3; background: #eaf1ee; }
.module-heading > span { display: grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; border-radius: 50%; color: var(--graph-lime); background: var(--graph-navy); font-size: .8rem; font-weight: 800; }
.module-heading small { color: #087b74; font-size: .67rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.module-heading h3 { margin: .15rem 0 0; color: var(--graph-navy); font-size: 1.12rem; }
.module-topics .list-group-item { display: flex; gap: .85rem; align-items: baseline; padding: .85rem 1.2rem; border-top: 1px solid #edf2f0; color: #284656; font-size: .93rem; line-height: 1.4; }
.module-topics .list-group-item:first-child { border-top: 0; }
.module-topics .list-group-item > span { flex: 0 0 24px; color: #6f8987; font-size: .72rem; font-weight: 800; }
.module-topics .list-group-item:hover { padding-left: 1.35rem; color: #075f5a; background: #effaf7; transform: none; }
.course-footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.6rem 3rem; color: #9bb1b6; background: var(--graph-navy); font-size: .84rem; }
.course-footer p { margin: 0; }.course-footer strong { color: #fff; }

@media (max-width: 900px) {
  .graph-visual { display: none; }
  .course-index .course-hero { padding: 4rem 2.5rem; }
  .topic-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .course-index .container#contenedor { margin: .75rem; border-radius: 18px; }
  .course-index #fila1 { min-height: auto; }
  .course-index .course-hero { padding: 3.2rem 1.35rem; }
  .course-index h1.title { font-size: clamp(2.55rem, 13vw, 4rem); }
  .course-index #fila2, .course-index #fila3 { padding: 3rem 1.25rem; }
  .course-summary { grid-template-columns: 1fr 1fr; }
  .section-heading { display: block; }
  .section-heading > p { margin-top: 1rem; }
  .course-footer { flex-direction: column; padding: 1.5rem; }
}
