Detailed overview of paediatric ovarian germ cell tumours, types , diagnosis, detailed medical and surgical management. Also describe how the management is different from adult ovarian germ cell tumours. Describe using tables and flow chart s wherever applicable. Give the document in pdf format

Reading File
Reading File
Finding Sources
Finding Sources
Searching PubMed

"ovarian germ cell tumors" AND pediatric AND management

Finding Sources
Finding Sources
Searching PubMed

"ovarian germ cell tumors" AND chemotherapy AND fertility

Reading File
Reading File
Reading File
Reading File
Reading File
Running Command

ls -la /home/daytona/workspace/ 2>/dev/null || mkdir -p /home/daytona/workspace/

Running Command

mkdir -p /home/daytona/workspace/paediatric-gct && python3 -c "from reportlab.lib.pagesizes import A4; print('ReportLab OK')"

Writing File

~/paediatric-gct/generate_pdf.py

#!/usr/bin/env python3
"""
Paediatric Ovarian Germ Cell Tumours - Comprehensive PDF Generator
"""

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm, mm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    PageBreak, HRFlowable, KeepTogether, ListFlowable, ListItem
)
from reportlab.platypus.flowables import Flowable
from reportlab.graphics.shapes import Drawing, Rect, String, Line, Arrow, Polygon
from reportlab.graphics import renderPDF
from reportlab.graphics.shapes import Drawing, Rect, String, Line, Circle, Group
from reportlab.lib.colors import HexColor
import os

OUTPUT_PATH = "/home/daytona/workspace/paediatric-gct/Paediatric_Ovarian_GCT.pdf"

# ─── Colour palette ────────────────────────────────────────────────────────────
TEAL       = HexColor("#006B6B")
TEAL_LIGHT = HexColor("#E0F0F0")
TEAL_MED   = HexColor("#A8D5D5")
ORANGE     = HexColor("#E07B39")
ORANGE_L   = HexColor("#FDF0E8")
BLUE_D     = HexColor("#1A3A5C")
GREY_BG    = HexColor("#F5F5F5")
GREY_LINE  = HexColor("#CCCCCC")
WHITE      = colors.white
BLACK      = colors.black
RED_LIGHT  = HexColor("#FDECEA")
RED_DARK   = HexColor("#C0392B")
GREEN_D    = HexColor("#1E7B34")
GREEN_L    = HexColor("#EAF7EC")
PURPLE     = HexColor("#6A0572")
PURPLE_L   = HexColor("#F3E5F5")

# ─── Styles ────────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()

def make_style(name, parent='Normal', **kwargs):
    return ParagraphStyle(name=name, parent=styles[parent], **kwargs)

title_style = make_style('DocTitle', 'Title',
    fontSize=26, textColor=WHITE, alignment=TA_CENTER,
    spaceAfter=4, fontName='Helvetica-Bold')

subtitle_style = make_style('DocSubtitle', 'Normal',
    fontSize=13, textColor=TEAL_LIGHT, alignment=TA_CENTER,
    spaceAfter=6, fontName='Helvetica')

h1_style = make_style('H1', fontSize=16, textColor=WHITE,
    fontName='Helvetica-Bold', spaceBefore=14, spaceAfter=4,
    leftIndent=0, leading=20)

h2_style = make_style('H2', fontSize=13, textColor=TEAL,
    fontName='Helvetica-Bold', spaceBefore=10, spaceAfter=4,
    leftIndent=0, leading=16, borderPad=3)

h3_style = make_style('H3', fontSize=11, textColor=BLUE_D,
    fontName='Helvetica-Bold', spaceBefore=8, spaceAfter=3, leading=14)

body_style = make_style('Body', fontSize=9.5, textColor=BLACK,
    fontName='Helvetica', leading=14, spaceAfter=4, alignment=TA_JUSTIFY)

bullet_style = make_style('Bullet', fontSize=9.5, textColor=BLACK,
    fontName='Helvetica', leading=13, spaceAfter=2, leftIndent=14,
    firstLineIndent=-10)

caption_style = make_style('Caption', fontSize=8.5, textColor=HexColor("#555555"),
    fontName='Helvetica-Oblique', alignment=TA_CENTER, spaceAfter=6)

table_header_style = make_style('TH', fontSize=9, textColor=WHITE,
    fontName='Helvetica-Bold', alignment=TA_CENTER, leading=11)

table_body_style = make_style('TD', fontSize=8.5, textColor=BLACK,
    fontName='Helvetica', leading=11, alignment=TA_LEFT)

note_style = make_style('Note', fontSize=8.5, textColor=HexColor("#444444"),
    fontName='Helvetica-Oblique', leading=11, leftIndent=6)

key_style = make_style('Key', fontSize=9, textColor=TEAL,
    fontName='Helvetica-Bold', leading=12)

warning_style = make_style('Warning', fontSize=9, textColor=RED_DARK,
    fontName='Helvetica-Bold', leading=12)

# ─── Helper Flowables ──────────────────────────────────────────────────────────

class SectionHeader(Flowable):
    """Coloured banner for section headings."""
    def __init__(self, text, color=TEAL, text_color=WHITE, width=None, height=28):
        Flowable.__init__(self)
        self.text = text
        self.color = color
        self.text_color = text_color
        self._width = width or (A4[0] - 3*cm)
        self.height = height

    def wrap(self, availWidth, availHeight):
        self._width = availWidth
        return self._width, self.height

    def draw(self):
        c = self.canv
        c.setFillColor(self.color)
        c.roundRect(0, 0, self._width, self.height, 4, fill=1, stroke=0)
        c.setFillColor(self.text_color)
        c.setFont('Helvetica-Bold', 13)
        c.drawString(10, 8, self.text)


class BoxedNote(Flowable):
    """Coloured note/callout box."""
    def __init__(self, text, bg=ORANGE_L, border=ORANGE, label="NOTE", width=None):
        Flowable.__init__(self)
        self.text = text
        self.bg = bg
        self.border = border
        self.label = label
        self._width = width or (A4[0] - 3*cm)
        self.height = 36

    def wrap(self, availWidth, availHeight):
        self._width = availWidth
        # estimate height
        lines = len(self.text) // 90 + 2
        self.height = max(36, lines * 13 + 14)
        return self._width, self.height

    def draw(self):
        c = self.canv
        c.setFillColor(self.bg)
        c.setStrokeColor(self.border)
        c.setLineWidth(1.5)
        c.roundRect(0, 0, self._width, self.height, 4, fill=1, stroke=1)
        c.setFillColor(self.border)
        c.setFont('Helvetica-Bold', 8.5)
        c.drawString(8, self.height - 12, self.label + ":")
        c.setFillColor(BLACK)
        c.setFont('Helvetica', 8.5)
        # Simple text wrapping
        words = self.text.split()
        line, x, y = "", 8, self.height - 25
        for word in words:
            test = (line + " " + word).strip()
            if c.stringWidth(test, 'Helvetica', 8.5) < self._width - 16:
                line = test
            else:
                c.drawString(x, y, line)
                y -= 12
                line = word
        if line:
            c.drawString(x, y, line)


def p(text, style=body_style):
    return Paragraph(text, style)

def b(text):
    return Paragraph(f"• {text}", bullet_style)

def spacer(h=0.2):
    return Spacer(1, h*cm)

def hr(color=GREY_LINE):
    return HRFlowable(width="100%", thickness=0.5, color=color, spaceAfter=4, spaceBefore=4)

def section(title, color=TEAL):
    return [spacer(0.3), SectionHeader(title, color=color), spacer(0.2)]

def subsection(title):
    return [spacer(0.15), p(f'<b><font color="#006B6B">{title}</font></b>', h2_style), hr(TEAL_MED)]

def subsubsection(title):
    return [p(f'<b>{title}</b>', h3_style)]

# ─── Table builder ─────────────────────────────────────────────────────────────

def make_table(headers, rows, col_widths=None, header_color=TEAL,
               stripe_color=GREY_BG, font_size=8.5):
    data = [[Paragraph(h, ParagraphStyle('th', parent=table_header_style, fontSize=font_size)) for h in headers]]
    for row in rows:
        data.append([Paragraph(str(c), ParagraphStyle('td', parent=table_body_style, fontSize=font_size)) for c in row])
    style = TableStyle([
        ('BACKGROUND', (0,0), (-1,0), header_color),
        ('TEXTCOLOR', (0,0), (-1,0), WHITE),
        ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
        ('FONTSIZE', (0,0), (-1,0), font_size),
        ('ALIGN', (0,0), (-1,0), 'CENTER'),
        ('VALIGN', (0,0), (-1,-1), 'TOP'),
        ('ROWBACKGROUNDS', (0,1), (-1,-1), [WHITE, stripe_color]),
        ('GRID', (0,0), (-1,-1), 0.4, GREY_LINE),
        ('LEFTPADDING', (0,0), (-1,-1), 5),
        ('RIGHTPADDING', (0,0), (-1,-1), 5),
        ('TOPPADDING', (0,0), (-1,-1), 4),
        ('BOTTOMPADDING', (0,0), (-1,-1), 4),
        ('ROUNDEDCORNERS', [3,3,3,3]),
    ])
    t = Table(data, colWidths=col_widths, repeatRows=1)
    t.setStyle(style)
    return t

# ─── Flowchart builder ─────────────────────────────────────────────────────────

class FlowChart(Flowable):
    """
    Draws a vertical flowchart with boxes and arrows.
    boxes: list of dicts with keys: text, color, text_color, shape (rect/diamond/rounded)
    arrows: list of dicts with label (optional)
    """
    def __init__(self, boxes, width=None, box_h=32, gap=18, pad=10):
        Flowable.__init__(self)
        self.boxes = boxes
        self._width = width or (A4[0] - 3.5*cm)
        self.box_h = box_h
        self.gap = gap
        self.pad = pad
        self.box_w = self._width - 2*pad
        self.total_h = len(boxes)*(box_h+gap) + gap + 10

    def wrap(self, availWidth, availHeight):
        self._width = availWidth
        self.box_w = self._width - 2*self.pad
        return self._width, self.total_h

    def draw(self):
        c = self.canv
        n = len(self.boxes)
        # draw from top to bottom
        y_top = self.total_h - self.gap - self.box_h
        for i, box in enumerate(self.boxes):
            bx = self.pad
            by = y_top - i*(self.box_h + self.gap)
            bg = box.get('color', TEAL_LIGHT)
            tc = box.get('text_color', BLACK)
            shape = box.get('shape', 'rounded')
            border_c = box.get('border', TEAL)

            c.setFillColor(bg)
            c.setStrokeColor(border_c)
            c.setLineWidth(1.2)
            if shape == 'diamond':
                cx = bx + self.box_w/2
                cy = by + self.box_h/2
                dx = self.box_w/2
                dy = self.box_h/2
                path = c.beginPath()
                path.moveTo(cx, by + self.box_h)
                path.lineTo(cx + dx, cy)
                path.lineTo(cx, by)
                path.lineTo(cx - dx, cy)
                path.close()
                c.drawPath(path, fill=1, stroke=1)
            else:
                c.roundRect(bx, by, self.box_w, self.box_h, 5, fill=1, stroke=1)

            # Text
            c.setFillColor(tc)
            text = box.get('text', '')
            lines = text.split('\n')
            fs = box.get('font_size', 8.5)
            c.setFont('Helvetica-Bold' if box.get('bold', True) else 'Helvetica', fs)
            line_h = fs + 2
            total_th = len(lines)*line_h
            start_y = by + self.box_h/2 + total_th/2 - line_h/2
            for j, line in enumerate(lines):
                tw = c.stringWidth(line, 'Helvetica-Bold' if box.get('bold', True) else 'Helvetica', fs)
                c.drawString(bx + self.box_w/2 - tw/2, start_y - j*line_h, line)

            # Arrow (downward) if not last
            if i < n - 1:
                ax = bx + self.box_w/2
                arrow_top = by
                arrow_bot = by - self.gap + 4
                c.setStrokeColor(TEAL)
                c.setLineWidth(1.5)
                c.line(ax, arrow_top, ax, arrow_bot + 5)
                # arrowhead
                c.setFillColor(TEAL)
                path = c.beginPath()
                path.moveTo(ax, arrow_bot)
                path.lineTo(ax - 5, arrow_bot + 8)
                path.lineTo(ax + 5, arrow_bot + 8)
                path.close()
                c.drawPath(path, fill=1, stroke=0)

            # Optional side label on arrow
            if i < n-1 and box.get('arrow_label'):
                lbl = box['arrow_label']
                c.setFont('Helvetica-Oblique', 7.5)
                c.setFillColor(HexColor("#555555"))
                c.drawString(bx + self.box_w/2 + 8, by - self.gap/2, lbl)


# ══════════════════════════════════════════════════════════════════════════════
#  PAGE HEADER / FOOTER
# ══════════════════════════════════════════════════════════════════════════════

def on_page(canvas, doc):
    canvas.saveState()
    w, h = A4
    # Footer
    canvas.setFillColor(TEAL)
    canvas.rect(0, 0, w, 20, fill=1, stroke=0)
    canvas.setFillColor(WHITE)
    canvas.setFont('Helvetica', 7.5)
    canvas.drawString(1.5*cm, 6, "Paediatric Ovarian Germ Cell Tumours — Clinical Overview 2025")
    canvas.drawRightString(w - 1.5*cm, 6, f"Page {doc.page}")
    canvas.restoreState()


def on_first_page(canvas, doc):
    canvas.saveState()
    w, h = A4
    # Header banner
    canvas.setFillColor(TEAL)
    canvas.rect(0, h - 5.5*cm, w, 5.5*cm, fill=1, stroke=0)
    # decorative stripe
    canvas.setFillColor(ORANGE)
    canvas.rect(0, h - 5.5*cm, w, 5, fill=1, stroke=0)
    canvas.restoreState()
    on_page(canvas, doc)


# ══════════════════════════════════════════════════════════════════════════════
#  DOCUMENT CONTENT
# ══════════════════════════════════════════════════════════════════════════════

def build_document():
    doc = SimpleDocTemplate(
        OUTPUT_PATH, pagesize=A4,
        topMargin=1.5*cm, bottomMargin=1.5*cm,
        leftMargin=1.5*cm, rightMargin=1.5*cm,
        title="Paediatric Ovarian Germ Cell Tumours",
        author="Clinical AI Summary",
    )

    story = []

    # ══ COVER ══
    story.append(Spacer(1, 4.5*cm))
    story.append(Paragraph("Paediatric Ovarian", title_style))
    story.append(Paragraph("Germ Cell Tumours", title_style))
    story.append(Spacer(1, 0.4*cm))
    story.append(Paragraph("Types · Diagnosis · Medical & Surgical Management", subtitle_style))
    story.append(Paragraph("Comparison with Adult Ovarian GCTs", subtitle_style))
    story.append(Spacer(1, 0.8*cm))
    story.append(Paragraph(
        "Based on Berek & Novak's Gynecology, Robbins Pathologic Basis of Disease, "
        "Harrison's Principles of Internal Medicine 22E, and current PubMed literature (2021–2025)",
        ParagraphStyle('covercite', parent=body_style, textColor=TEAL_LIGHT,
                       alignment=TA_CENTER, fontSize=8.5)))
    story.append(PageBreak())

    # ══ 1. INTRODUCTION & EPIDEMIOLOGY ══
    story += section("1. Introduction & Epidemiology")
    story.append(p(
        "Ovarian germ cell tumours (GCTs) arise from the primordial germ cells of the ovary. "
        "They constitute <b>15–20% of all ovarian tumours</b> but represent a disproportionately "
        "large share of ovarian malignancies in the paediatric and adolescent age group. "
        "In females under 20 years, <b>malignant GCTs account for ~70% of ovarian malignancies</b>, "
        "compared with only ~5% in the adult population overall."
    ))
    story.append(spacer(0.15))
    story += subsection("Key Epidemiological Facts")

    epi_headers = ["Parameter", "Paediatric / Adolescent (<20 yr)", "Adult (>20 yr)"]
    epi_rows = [
        ["Proportion of all ovarian tumours", "~70% of ovarian malignancies", "~5% of ovarian malignancies"],
        ["Peak age", "10–20 years (adolescence)", "20–40 years"],
        ["Bilateral disease", "~10–15% (dysgerminoma)", "~10–15% (dysgerminoma)"],
        ["Most common benign GCT", "Mature cystic teratoma (dermoid)", "Mature cystic teratoma (dermoid)"],
        ["Most common malignant GCT", "Dysgerminoma / immature teratoma", "Dysgerminoma"],
        ["Overall survival (stage I)", ">95% with modern therapy", ">90% with modern therapy"],
        ["Fertility preservation priority", "Extremely high", "High"],
        ["Bilateral oophorectomy", "Avoided whenever possible", "Avoided whenever possible"],
    ]
    story.append(make_table(epi_headers, epi_rows, col_widths=[5*cm, 6*cm, 6*cm]))
    story.append(spacer(0.1))
    story.append(p(
        "The vast majority of advances in management have been extrapolated from testicular GCT "
        "experience, since ovarian GCTs are one-tenth as common as their testicular counterparts. "
        "Germ cell migration from the caudal yolk sac through the dorsal mesentery to the developing "
        "gonad explains why extragonadal GCTs can also occur in the mediastinum and retroperitoneum.",
        body_style))

    # ══ 2. CLASSIFICATION & TYPES ══
    story += section("2. WHO Classification & Tumour Types")
    story.append(p(
        "The 2020 WHO Classification (updated from 2014) divides ovarian GCTs into three broad categories:"
    ))

    class_headers = ["Category", "Subtypes", "Key Features"]
    class_rows = [
        ["<b>1. Primitive Germ Cell Tumours</b>",
         "Dysgerminoma\nYolk sac tumour (endodermal sinus)\nEmbryonal carcinoma\nPolyembryoma\nNon-gestational choriocarcinoma\nMixed GCT",
         "Undifferentiated or primitive differentiation; most are malignant; AFP/hCG markers useful"],
        ["<b>2. Biphasic / Triphasic Teratoma</b>",
         "Immature teratoma (grades 1–3)\nMature teratoma — solid\nMature teratoma — cystic (dermoid cyst)\nFetiform teratoma (homunculus)",
         "Contain elements of ≥2 germ layers; maturity determines malignant potential; graded by amount of neuroepithelium"],
        ["<b>3. Monodermal Teratoma & Somatic-type Tumours</b>",
         "Struma ovarii (benign/malignant)\nCarcinoid\nNeuroectodermal tumour\nCarcinoma\nMelanocytic, sarcoma, sebaceous, pituitary-type",
         "Differentiated along one tissue lineage; rare; may present with specific clinical syndromes"],
    ]
    story.append(make_table(class_headers, class_rows, col_widths=[5*cm, 6*cm, 6*cm]))
    story.append(Paragraph("Source: WHO Classification of Tumours of Female Reproductive Organs; Berek & Novak's Gynecology, Table 39-5", caption_style))

    story += subsection("2.1 Dysgerminoma")
    story.append(p(
        "<b>Dysgerminoma</b> is the most common malignant GCT in children/adolescents and the ovarian "
        "counterpart of testicular seminoma. Key features:"
    ))
    for item in [
        "Accounts for ~50% of malignant GCTs in females under 20 years.",
        "Peak incidence: second and third decades. Rare before age 10.",
        "~10–15% bilateral at presentation; contralateral ovary must be carefully evaluated.",
        "Pure dysgerminoma does <b>not</b> secrete AFP; ~3–5% secrete hCG (syncytiotrophoblastic giant cells).",
        "Highly radiosensitive and chemosensitive — excellent prognosis.",
        "Associated with gonadal dysgenesis (46,XY phenotypic females; gonadoblastoma precursor).",
        "Histology: large, uniform cells with clear cytoplasm, prominent nucleoli, fibrous stroma with lymphocytic infiltrate."
    ]:
        story.append(b(item))
    story.append(spacer(0.1))

    story += subsection("2.2 Yolk Sac Tumour (Endodermal Sinus Tumour)")
    story.append(p(
        "<b>Yolk sac tumour (YST)</b> is the second most common malignant GCT. It differentiates toward "
        "extraembryonic yolk sac structures. Key features:"
    ))
    for item in [
        "Most common in the first two decades of life; median age ~19 years.",
        "Almost always unilateral.",
        "Produces <b>AFP (alpha-fetoprotein)</b> — a reliable serum tumour marker for diagnosis and follow-up.",
        "Rapid growth; often presents as a large, solid-cystic pelvic/abdominal mass.",
        "Histological patterns: reticular (most common), Schiller-Duval bodies (pathognomonic), solid, polyvesicular-vitelline.",
        "Schiller-Duval body = perivascular arrangement resembling glomerulus with central vessel and tumour cells.",
        "Prognosis: historically poor, now dramatically improved with BEP chemotherapy (>80% 5-yr survival)."
    ]:
        story.append(b(item))
    story.append(spacer(0.1))

    story += subsection("2.3 Immature Teratoma")
    story.append(p(
        "<b>Immature teratoma</b> contains embryonal or fetal elements alongside more mature tissues. "
        "It is the second most common malignant ovarian tumour in women <20 years."
    ))
    for item in [
        "~50% occur between ages 10–20; rare in postmenopausal women.",
        "Graded by amount of immature neuroepithelium per low-power field (Norris grading).",
        "Grade 1 (<1 LPF of neuroepithelium): >95% survival with surgery alone.",
        "Grades 2 & 3 (higher neuroepithelium): ~85% survival; adjuvant chemotherapy considered.",
        "<b>Important paediatric distinction:</b> Children (<10 yr) with immature teratoma have excellent outcomes with surgery alone regardless of grade.",
        "May be associated with gliomatosis peritonei — mature glial implants, a favourable prognostic sign.",
        "AFP may be mildly elevated; LDH may be raised.",
        "Growing teratoma syndrome: paradoxical enlargement of lesions during/after chemotherapy due to mature element growth."
    ]:
        story.append(b(item))

    # Grading table
    grade_headers = ["Grade", "Neuroepithelium (LPF x4)", "Management", "Prognosis"]
    grade_rows = [
        ["Grade 1 (Low)", "<1 low-power field", "Surgery alone (unilateral salpingo-oophorectomy)", ">95% 5-yr OS"],
        ["Grade 2 (High)", "1–3 low-power fields", "Surgery + adjuvant BEP (3 cycles) if residual/recurrent", "~85% 5-yr OS"],
        ["Grade 3 (High)", ">3 low-power fields", "Surgery + adjuvant BEP (3–4 cycles)", "~85% 5-yr OS"],
    ]
    story.append(make_table(grade_headers, grade_rows, col_widths=[3*cm, 5.5*cm, 5.5*cm, 3*cm]))
    story.append(spacer(0.1))

    story += subsection("2.4 Embryonal Carcinoma")
    for item in [
        "Rare pure form; usually component of mixed GCT.",
        "Occurs in adolescents and young adults (median ~15 years).",
        "Secretes both <b>AFP and hCG</b>; may cause isosexual precocious puberty.",
        "Highly aggressive; requires BEP-based chemotherapy."
    ]:
        story.append(b(item))
    story.append(spacer(0.1))

    story += subsection("2.5 Non-Gestational Choriocarcinoma")
    for item in [
        "Extremely rare pure ovarian choriocarcinoma (must exclude gestational origin).",
        "Secretes high levels of <b>hCG</b> — causes isosexual precocious puberty in premenarchal girls.",
        "Aggressive; often presents with metastases.",
        "Treated with BEP; EMA-CO regimen is an alternative (borrowed from gestational trophoblastic disease management)."
    ]:
        story.append(b(item))
    story.append(spacer(0.1))

    story += subsection("2.6 Mixed Germ Cell Tumours")
    story.append(p(
        "Mixed GCTs contain ≥2 different GCT components. Dysgerminoma + YST is the most common combination. "
        "Management is guided by the most malignant component. Markers reflect all components present."
    ))
    story.append(spacer(0.1))

    story += subsection("2.7 Mature Cystic Teratoma (Dermoid Cyst)")
    for item in [
        "Most common benign ovarian tumour in females <20 years.",
        "Contains ectodermal, mesodermal, and endodermal elements in mature form — hair, sebum, teeth, neural tissue.",
        "Bilateral in ~10–15% of cases.",
        "Complication: ovarian torsion (most common surgical emergency in girls with ovarian cysts).",
        "Malignant transformation: rare (<2%), usually squamous cell carcinoma in adults >40 years.",
        "Surgery: cystectomy with ovarian conservation wherever possible."
    ]:
        story.append(b(item))

    # ══ 3. CLINICAL PRESENTATION ══
    story += section("3. Clinical Presentation & Diagnosis")
    story += subsection("3.1 Symptoms & Signs")
    story.append(p("Paediatric ovarian GCTs typically present acutely or subacutely:"))

    pres_headers = ["Feature", "Frequency", "Notes"]
    pres_rows = [
        ["Abdominal/pelvic mass", "Most common (~85%)", "Often large; rapidly growing; may cross midline"],
        ["Abdominal pain", "~75%", "Acute (torsion/rupture) or subacute distension"],
        ["Abdominal distension", "Common", "Ascites present in advanced disease"],
        ["Nausea, vomiting", "~30%", "Mechanical or hCG-mediated"],
        ["Isosexual precocious puberty", "If hCG/oestrogen-secreting", "Choriocarcinoma, embryonal carcinoma, YST"],
        ["Menstrual irregularity", "Adolescents", "Amenorrhoea or irregular menses"],
        ["Acute abdomen (torsion)", "~20%", "Particularly dermoid/immature teratoma"],
        ["Fever, weight loss", "Advanced disease", "Constitutional B symptoms"],
        ["Virilis ation", "Rare", "Sex cord-stromal tumours more typical"],
    ]
    story.append(make_table(pres_headers, pres_rows, col_widths=[5.5*cm, 3.5*cm, 8*cm]))

    story += subsection("3.2 Tumour Markers")
    story.append(p(
        "Serum tumour markers are essential for diagnosis, staging, and monitoring. They should be "
        "drawn <b>before surgery</b>."
    ))
    markers_headers = ["Marker", "Tumour Type", "Paediatric Notes"]
    markers_rows = [
        ["AFP (alpha-fetoprotein)", "YST, embryonal carcinoma, mixed GCT", "Normally elevated in neonates (up to 100,000 ng/mL); must use age-adjusted norms. AFP >1000 ng/mL strongly suggests YST."],
        ["hCG (beta-hCG)", "Choriocarcinoma, embryonal carcinoma, dysgerminoma (small %)", "Elevated hCG in premenarchal girls causes isosexual precocious puberty"],
        ["LDH (lactate dehydrogenase)", "Dysgerminoma (most sensitive)", "Non-specific but important for dysgerminoma staging and monitoring"],
        ["PLAP (placental alkaline phosphatase)", "Dysgerminoma", "Less widely used; helps confirm dysgerminoma diagnosis"],
        ["CA-125", "Non-specific; any GCT", "Useful for monitoring if elevated at diagnosis"],
        ["Inhibin B", "Sex cord-stromal tumours", "Not typical for GCTs; important differential"],
    ]
    story.append(make_table(markers_headers, markers_rows, col_widths=[4*cm, 5*cm, 8*cm]))
    story.append(BoxedNote(
        "CRITICAL: AFP is physiologically elevated in neonates and infants up to age 2. Age-adjusted reference ranges MUST be used. "
        "An AFP of 50 ng/mL is normal in a 1-month-old but highly suspicious in a 5-year-old.",
        bg=RED_LIGHT, border=RED_DARK, label="CRITICAL"))
    story.append(spacer(0.1))

    story += subsection("3.3 Imaging")
    story.append(p("Imaging is used for diagnosis, staging, surgical planning, and response assessment:"))
    img_headers = ["Modality", "Role", "Typical Findings"]
    img_rows = [
        ["Pelvic/Abdominal Ultrasound (USS)",
         "First-line investigation",
         "Complex adnexal mass with solid and cystic components; calcifications (teeth in dermoid); Doppler assesses vascularity"],
        ["CT Chest/Abdomen/Pelvis",
         "Staging (lymph nodes, liver, lung metastases)",
         "Retroperitoneal lymphadenopathy; peritoneal deposits; omental caking in advanced disease"],
        ["MRI Pelvis",
         "Local anatomy, fertility-sparing surgery planning",
         "Superior soft tissue contrast; identifies relationship to uterus and contralateral ovary; fat signal in teratoma"],
        ["PET-CT",
         "Dysgerminoma staging/response", "High FDG avidity in dysgerminoma; less reliable for mature teratoma"],
        ["Chest X-ray",
         "Basic staging, pulmonary metastases",
         "Mediastinal adenopathy in advanced dysgerminoma"],
    ]
    story.append(make_table(img_headers, img_rows, col_widths=[4.5*cm, 4*cm, 8.5*cm]))

    # ══ 4. STAGING ══
    story += section("4. Staging (FIGO 2014)")
    story.append(p(
        "Ovarian GCTs are staged according to the FIGO 2014 system (applied at surgery). "
        "Complete surgical staging is important for management decisions."
    ))
    figo_headers = ["Stage", "Description"]
    figo_rows = [
        ["I", "Tumour confined to the ovary/ovaries"],
        ["IA", "Tumour limited to one ovary; capsule intact; no tumour on surface; no malignant cells in ascites/peritoneal washings"],
        ["IB", "Tumour in both ovaries; capsule intact; no surface tumour; no malignant cells in washings"],
        ["IC1", "Surgical spill"],
        ["IC2", "Capsule rupture before surgery or tumour on ovarian surface"],
        ["IC3", "Malignant cells in ascites or peritoneal washings"],
        ["II", "Tumour involves one or both ovaries with pelvic extension (below pelvic brim)"],
        ["IIA", "Extension/implants on uterus and/or fallopian tubes"],
        ["IIB", "Extension to other pelvic intraperitoneal tissues"],
        ["III", "Tumour involves one or both ovaries with confirmed spread to the peritoneum outside the pelvis and/or retroperitoneal lymph nodes"],
        ["IIIA1", "Positive retroperitoneal lymph nodes only"],
        ["IIIA2", "Microscopic extrapelvic peritoneal involvement ± positive nodes"],
        ["IIIB", "Macroscopic peritoneal metastases ≤2 cm ± positive nodes"],
        ["IIIC", "Macroscopic peritoneal metastases >2 cm ± positive nodes"],
        ["IV", "Distant metastases (parenchymal liver/splenic metastases, extra-abdominal organs, pleural effusion with positive cytology)"],
    ]
    story.append(make_table(figo_headers, figo_rows, col_widths=[2.5*cm, 14.5*cm]))

    # ══ 5. SURGICAL MANAGEMENT ══
    story += section("5. Surgical Management")
    story.append(p(
        "Surgery serves as both the diagnostic (staging) and primary therapeutic intervention. "
        "A fundamental principle in paediatric patients is <b>fertility preservation</b>: "
        "because GCTs are predominantly unilateral and highly chemosensitive, radical surgery is rarely needed."
    ))

    story += subsection("5.1 Principles of Surgery in Paediatric GCTs")
    for item in [
        "<b>Unilateral salpingo-oophorectomy (USO)</b> is the standard surgical procedure for paediatric and adolescent GCTs — even in advanced-stage disease.",
        "The contralateral ovary and uterus are preserved to maintain fertility and hormonal function.",
        "Routine biopsy of normal-appearing contralateral ovary is NOT recommended (risks adhesions, premature ovarian failure).",
        "Biopsy of contralateral ovary is recommended only if it appears abnormal on inspection.",
        "If bilateral tumours are found, bilateral ovarian cystectomy (not bilateral oophorectomy) should be attempted to preserve function.",
        "Complete surgical staging: peritoneal washings, omental biopsy/omentectomy, peritoneal biopsies, pelvic and para-aortic lymph node sampling.",
        "Systematic lymphadenectomy is not routinely required in paediatric patients with apparent early-stage disease.",
        "Ruptured tumours or those causing ascites require more thorough staging.",
        "Minimally invasive surgery (laparoscopy) may be appropriate for smaller lesions but must not compromise oncological principles (intact tumour removal is essential).",
    ]:
        story.append(b(item))
    story.append(spacer(0.1))

    story += subsection("5.2 Surgical Approach by Stage")
    sx_headers = ["Stage", "Surgical Procedure", "Additional Steps", "Adjuvant Chemotherapy?"]
    sx_rows = [
        ["IA (USO, intact)", "Unilateral salpingo-oophorectomy", "Peritoneal washings, peritoneal biopsies, omental biopsy, lymph node sampling", "No (most GCT subtypes); surveillance"],
        ["IB (bilateral)", "Bilateral cystectomy/USO (attempt conservation)", "Full staging", "Yes (BEP x3)"],
        ["IC", "USO", "Full staging; careful peritoneal assessment", "Yes (BEP x3)"],
        ["II", "USO + debulking of pelvic implants", "Full staging", "Yes (BEP x3–4)"],
        ["III/IV", "USO + optimal debulking (cytoreduction to <1 cm residual)", "Full staging; omentectomy, peritoneal debulking", "Yes (BEP x4)"],
        ["Recurrence", "Secondary cytoreduction if resectable", "Re-staging", "Salvage chemotherapy (TIP/VeIP/high-dose)"],
    ]
    story.append(make_table(sx_headers, sx_rows, col_widths=[2.5*cm, 4.5*cm, 5*cm, 5*cm]))
    story.append(spacer(0.1))

    story += subsection("5.3 Special Surgical Considerations in Paediatrics")
    story.append(p("<b>Ovarian Torsion:</b> Common emergency presentation. Detorsion (untwisting) should always be attempted "
        "first, regardless of appearance. Oophorectomy is reserved for frankly necrotic ovary. "
        "Concomitant ovarian cystectomy can be performed if feasible."))
    story.append(spacer(0.05))
    story.append(p("<b>Gonadal Dysgenesis / DSD:</b> Girls with 46,XY DSD (e.g., complete androgen insensitivity, "
        "Swyer syndrome) have a ~25–30% risk of gonadoblastoma/dysgerminoma in dysgenetic gonads. "
        "Prophylactic gonadectomy is recommended after puberty (or earlier if gonadoblastoma detected)."))
    story.append(spacer(0.05))
    story.append(p("<b>Laparoscopy vs. Laparotomy:</b> For tumours >8–10 cm or with solid components suggesting "
        "malignancy, laparotomy (midline or Pfannenstiel incision) is preferred to ensure intact removal "
        "and adequate staging. Laparoscopy is appropriate for small cystic lesions with low malignancy risk."))

    # Surgical Flowchart
    story += subsubsection("Surgical Decision Algorithm for Paediatric Ovarian Mass")
    story.append(spacer(0.1))
    flowchart_boxes = [
        {"text": "Paediatric/Adolescent Ovarian Mass Detected", "color": TEAL, "text_color": WHITE, "border": TEAL},
        {"text": "Baseline: USS, CT/MRI, Tumour Markers (AFP, hCG, LDH, CA-125)\nBefore Surgery", "color": TEAL_LIGHT, "text_color": BLUE_D, "border": TEAL},
        {"text": "Suspicious for Malignancy?\n(Solid component, ↑Markers, Large size, Ascites)", "color": ORANGE_L, "text_color": BLUE_D, "border": ORANGE, "shape": "diamond"},
        {"text": "Unilateral Salpingo-Oophorectomy (USO) + Full Surgical Staging\n(Peritoneal washings, biopsies, lymph node sampling, omental biopsy)", "color": TEAL_LIGHT, "text_color": BLUE_D, "border": TEAL},
        {"text": "Histopathology & Final Staging\n(Send fresh tissue for cytogenetics if DSD suspected)", "color": GREY_BG, "text_color": BLACK, "border": GREY_LINE},
        {"text": "Multidisciplinary Team Discussion\n(Paediatric Oncology + Gynaecology + Pathology)", "color": PURPLE_L, "text_color": PURPLE, "border": PURPLE},
        {"text": "Stage IA/IB: Surveillance\nStage IC+: BEP Chemotherapy (3–4 cycles)", "color": GREEN_L, "text_color": GREEN_D, "border": GREEN_D},
    ]
    fc = FlowChart(flowchart_boxes, box_h=36, gap=20)
    story.append(fc)
    story.append(Paragraph("Figure 1: Surgical decision algorithm for paediatric ovarian mass", caption_style))

    # ══ 6. MEDICAL (CHEMOTHERAPY) MANAGEMENT ══
    story += section("6. Medical Management — Chemotherapy")
    story.append(p(
        "The introduction of cisplatin-based combination chemotherapy transformed the prognosis of "
        "malignant ovarian GCTs. The BEP regimen (bleomycin, etoposide, cisplatin) is the "
        "<b>standard first-line treatment</b> for all malignant GCTs requiring adjuvant or primary chemotherapy."
    ))

    story += subsection("6.1 BEP Regimen (Standard First-Line)")
    bep_headers = ["Drug", "Dose", "Route", "Schedule", "Mechanism"]
    bep_rows = [
        ["Bleomycin (B)", "30 units/week", "IV bolus", "Days 1, 8, 15 of each 21-day cycle", "DNA strand breaks via free radical generation"],
        ["Etoposide (E)", "100 mg/m²/day × 5 days", "IV infusion", "Days 1–5 of each 21-day cycle", "Topoisomerase II inhibitor"],
        ["Cisplatin (P)", "20 mg/m²/day × 5 days", "IV infusion (with hydration)", "Days 1–5 of each 21-day cycle", "DNA crosslinking (intrastrand/interstrand)"],
    ]
    story.append(make_table(bep_headers, bep_rows, col_widths=[3*cm, 3.5*cm, 3*cm, 4.5*cm, 3*cm]))
    story.append(spacer(0.1))

    story.append(p("<b>Number of cycles:</b>"))
    cycles_headers = ["Stage / Risk", "Number of BEP Cycles", "Evidence"]
    cycles_rows = [
        ["Stage IA — completely resected (dysgerminoma / grade 1 IT)", "0 (surveillance)", "GOG/COG data; >95% OS without chemo"],
        ["Stage IA — dysgerminoma, recurrent after surveillance", "3 BEP", "Excellent salvage response"],
        ["Stage IA YST / embryonal / choriocarcinoma", "3 BEP", "YST recurrence risk without chemo is high"],
        ["Stage IC – II (any malignant GCT)", "3 BEP", "Standard; near-100% remission rate"],
        ["Stage III – IV", "4 BEP", "Optimal cytoreduction + 4 cycles"],
        ["Recurrence — platinum-sensitive", "TIP: Paclitaxel + Ifosfamide + Cisplatin", "Standard salvage"],
        ["Recurrence — high-risk/refractory", "High-dose chemotherapy + ASCT", "COG/AGCT protocols"],
    ]
    story.append(make_table(cycles_rows, [], col_widths=[5.5*cm, 4*cm, 7.5*cm],
                            header_color=TEAL))
    # Fix: use make_table properly
    story.pop()  # remove bad table
    story.append(make_table(["Stage / Risk", "Number of BEP Cycles", "Evidence"], cycles_rows,
                            col_widths=[5.5*cm, 4*cm, 7.5*cm]))

    story += subsection("6.2 Toxicity & Paediatric Considerations")
    tox_headers = ["Drug", "Acute Toxicities", "Long-term Toxicities", "Paediatric Considerations"]
    tox_rows = [
        ["Bleomycin", "Pulmonary toxicity (pneumonitis), fever, Raynaud's, skin changes",
         "Pulmonary fibrosis (cumulative dose-dependent; avoid >300 units lifetime)",
         "Growing lungs especially vulnerable; PFTs before/during; may omit in low-risk cases"],
        ["Etoposide", "Myelosuppression, nausea, alopecia, mucositis",
         "Secondary leukaemia (AML; cumulative dose-related; risk ~0.4%)",
         "Secondary malignancy risk relevant in long-lived children; minimise cumulative dose"],
        ["Cisplatin", "N&V, nephrotoxicity, electrolyte wasting (Mg, K), ototoxicity, peripheral neuropathy",
         "Sensorineural hearing loss (audiological monitoring required), renal impairment, subfertility",
         "Children have higher risk of cisplatin-induced hearing loss; audiometry mandatory. Carboplatin sometimes substituted."],
        ["BEP overall", "G-CSF-supported; febrile neutropenia manageable", "Ovarian function usually preserved",
         "~80–90% of paediatric patients retain menstrual function and fertility"],
    ]
    story.append(make_table(tox_headers, tox_rows, col_widths=[3*cm, 5*cm, 4*cm, 5*cm]))
    story.append(spacer(0.1))

    story += subsection("6.3 Alternative Chemotherapy Regimens")
    alt_headers = ["Regimen", "Drugs", "Indication", "Advantage / Notes"]
    alt_rows = [
        ["Carboplatin + Etoposide", "Carboplatin AUC 5–6 + Etoposide 120 mg/m²/day × 3",
         "Alternative in young children or when cisplatin toxicity is a concern",
         "Less nephrotoxicity, less ototoxicity; used in COG AGCT0132 for low-risk paediatric GCT"],
        ["TIP", "Paclitaxel 175 mg/m², Ifosfamide 1500 mg/m²/day × 5, Cisplatin 20 mg/m²/day × 5",
         "1st-line salvage for recurrent/refractory disease",
         "Standard salvage for platinum-sensitive recurrence"],
        ["VeIP", "Vinblastine, Ifosfamide, Cisplatin",
         "Salvage; especially testicular GCT literature-derived",
         "Alternative if taxane not used"],
        ["EMA-CO", "Etoposide, Methotrexate, Actinomycin-D / Cyclophosphamide, Vincristine",
         "Non-gestational choriocarcinoma",
         "Borrowed from gestational trophoblastic disease protocols"],
        ["High-dose chemo + ASCT", "Carboplatin, Etoposide, Ifosfamide + autologous stem cell transplant",
         "Platinum-refractory recurrence",
         "Considered in relapsed/refractory disease in fit patients"],
    ]
    story.append(make_table(alt_headers, alt_rows, col_widths=[3*cm, 4.5*cm, 4*cm, 5.5*cm]))

    story += subsection("6.4 Radiation Therapy")
    story.append(p(
        "Radiation therapy has a very limited role in modern management of paediatric ovarian GCTs. "
        "It was historically used for dysgerminoma (highly radiosensitive) but has been replaced "
        "by BEP chemotherapy due to long-term gonadal and bowel toxicity. Radiotherapy may still "
        "be considered for:"
    ))
    for item in [
        "CNS metastases from dysgerminoma (whole-brain or stereotactic radiotherapy).",
        "Rare refractory cases where chemotherapy has failed.",
        "Dysgerminoma in patients unable to receive BEP chemotherapy."
    ]:
        story.append(b(item))

    # Chemotherapy flowchart
    story += subsubsection("Chemotherapy Decision Algorithm")
    story.append(spacer(0.1))
    chemo_boxes = [
        {"text": "Malignant Ovarian GCT — Post-surgical Staging Complete", "color": TEAL, "text_color": WHITE, "border": TEAL},
        {"text": "Stage IA Dysgerminoma or Grade 1 Immature Teratoma?", "color": ORANGE_L, "text_color": BLUE_D, "border": ORANGE, "shape": "diamond"},
        {"text": "Surveillance Protocol\n(3-monthly markers + imaging for 2 years, then 6-monthly)", "color": GREEN_L, "text_color": GREEN_D, "border": GREEN_D},
        {"text": "Any other malignant GCT (Stage IC+, YST, Embryonal, Choriocarcinoma, Mixed)", "color": TEAL_LIGHT, "text_color": BLUE_D, "border": TEAL},
        {"text": "BEP Chemotherapy\nStage IC–II: 3 cycles | Stage III–IV: 4 cycles", "color": BLUE_D, "text_color": WHITE, "border": BLUE_D},
        {"text": "Response Assessment: AFP/hCG/LDH normalisation + CT/MRI", "color": GREY_BG, "text_color": BLACK, "border": GREY_LINE},
        {"text": "Complete Remission → Surveillance\nResidual Disease → Second-look surgery / Salvage TIP", "color": PURPLE_L, "text_color": PURPLE, "border": PURPLE},
    ]
    fc2 = FlowChart(chemo_boxes, box_h=36, gap=18)
    story.append(fc2)
    story.append(Paragraph("Figure 2: Chemotherapy decision algorithm for paediatric malignant ovarian GCT", caption_style))

    # ══ 7. FERTILITY & HORMONAL CONSIDERATIONS ══
    story += section("7. Fertility Preservation & Hormonal Considerations")
    story.append(p(
        "Preservation of fertility and ovarian endocrine function is a paramount goal in the management "
        "of paediatric and adolescent patients with ovarian GCTs. Modern multidisciplinary approaches "
        "achieve this in the vast majority of cases."
    ))

    story += subsection("7.1 Fertility Outcomes")
    story.append(p(
        "A 2025 systematic review (<i>Cancer Causes Control</i>, PMID 41068325) spanning a decade of "
        "data confirmed that fertility-sparing surgery + BEP chemotherapy preserves menstrual function "
        "in ~80–90% of patients. Key data:"
    ))
    for item in [
        "USO preserves fertility in the vast majority; contralateral ovary compensates.",
        "BEP chemotherapy causes transient amenorrhoea in ~50%; most resume normal cycles within 6–12 months of completing treatment.",
        "Premature ovarian failure is uncommon (<10%) with standard BEP doses.",
        "Pregnancy rates post-treatment: ~70–80% in those attempting conception.",
        "Carboplatin-based regimens may have slightly better gonadal preservation than cisplatin-based in young children.",
        "Gonadotrophin (FSH/LH) and AMH (anti-Mullerian hormone) monitoring recommended post-treatment."
    ]:
        story.append(b(item))
    story.append(spacer(0.1))

    story += subsection("7.2 Hormonal Replacement")
    story.append(p(
        "In the rare cases requiring bilateral oophorectomy (bilateral disease unresponsive to conservation, "
        "or prophylactic gonadectomy in DSD), hormone replacement therapy (HRT) is required:"
    ))
    for item in [
        "Prepubertal girls: HRT to induce puberty at appropriate age (oestrogen ± progesterone).",
        "Post-pubertal girls: Combined HRT (oestrogen + progesterone) to maintain bone density and cardiovascular health.",
        "Psychological support and appropriate counselling regarding fertility implications.",
        "Surrogacy or adoption counselling if uterus retained but ovaries removed."
    ]:
        story.append(b(item))

    # ══ 8. SURVEILLANCE ══
    story += section("8. Surveillance After Treatment")
    story.append(p("Surveillance protocols are individualised based on tumour type, stage, and treatment received:"))

    surv_headers = ["Interval", "Tumour Markers", "Imaging", "Clinical Review"]
    surv_rows = [
        ["Months 1–6 (post-treatment)", "Monthly AFP, hCG, LDH", "CT C/A/P at 3 months", "Monthly clinical review"],
        ["Months 7–24", "3-monthly", "CT or MRI at 6, 12, 24 months", "3-monthly"],
        ["Years 3–5", "6-monthly", "Imaging if markers rise or symptoms", "6-monthly"],
        ["After 5 years", "Annual (dysgerminoma may have late relapse)", "Imaging if indicated", "Annual"],
    ]
    story.append(make_table(surv_headers, surv_rows, col_widths=[4.5*cm, 4.5*cm, 4*cm, 4*cm]))
    story.append(BoxedNote(
        "Dysgerminoma has the highest risk of late relapse (up to 25% without adjuvant chemo in stage IA). "
        "However, >75% of relapses are salvaged with BEP chemotherapy. Close long-term follow-up is therefore essential.",
        bg=ORANGE_L, border=ORANGE, label="NOTE"))
    story.append(spacer(0.1))

    story += subsection("8.1 Growing Teratoma Syndrome (GTS)")
    story.append(p(
        "GTS is characterised by enlarging tumour masses during or after chemotherapy for immature teratoma, "
        "in the context of normalising serum AFP. The enlarging lesions consist entirely of mature teratomatous "
        "elements. Management is surgical resection; chemotherapy is ineffective. GTS does not imply chemotherapy "
        "failure and prognosis is excellent after complete resection."
    ))

    # ══ 9. PROGNOSIS ══
    story += section("9. Prognosis")
    story.append(p(
        "Modern multimodal treatment has transformed the prognosis of paediatric ovarian GCTs — "
        "once a feared diagnosis now carries excellent survival rates."
    ))
    prog_headers = ["Tumour Type", "Stage", "5-Year Survival", "Notes"]
    prog_rows = [
        ["Dysgerminoma", "IA", ">95%", "Surgery alone; surveillance"],
        ["Dysgerminoma", "II–IV", "85–95%", "BEP chemotherapy; very high salvage rate"],
        ["Immature Teratoma (Grade 1)", "I", ">95%", "Surgery alone in paediatrics"],
        ["Immature Teratoma (Grade 2–3)", "I–II", "~85–90%", "Adjuvant BEP"],
        ["Immature Teratoma", "III–IV", "~75–85%", "Surgery + BEP"],
        ["Yolk Sac Tumour", "I", "~85–90%", "USO + BEP x3"],
        ["Yolk Sac Tumour", "II–IV", "~65–80%", "USO + BEP x3–4"],
        ["Mixed GCT", "All stages", "~70–85%", "Depends on components"],
        ["Non-gestational choriocarcinoma", "All", "~50–70%", "High-risk; often presents late"],
        ["Embryonal carcinoma", "All", "~60–75%", "Requires BEP; rare"],
    ]
    story.append(make_table(prog_headers, prog_rows, col_widths=[5.5*cm, 2.5*cm, 4*cm, 5*cm]))

    # ══ 10. PAEDIATRIC vs. ADULT — COMPARATIVE TABLE ══
    story.append(PageBreak())
    story += section("10. Paediatric vs. Adult Ovarian GCTs — Key Differences", color=BLUE_D)
    story.append(p(
        "Although ovarian GCTs share the same WHO classification across age groups, there are "
        "important biological, clinical, and management differences between paediatric and adult patients:"
    ))

    comp_headers = ["Parameter", "Paediatric (<20 years)", "Adult (>20 years)"]
    comp_rows = [
        ["<b>Most common malignant GCT</b>", "Dysgerminoma; immature teratoma",
         "Dysgerminoma (but epithelial tumours dominate ovarian malignancies overall)"],
        ["<b>YST prevalence</b>",
         "More common; more aggressive presentation", "Less common; generally similar behaviour"],
        ["<b>Immature teratoma grading</b>",
         "Grade has less prognostic significance; children do well with surgery alone regardless of grade",
         "Grading is more prognostically significant; high-grade requires chemotherapy"],
        ["<b>Bilateral disease</b>",
         "~10–15%; attempt conservation with bilateral cystectomy",
         "Similar; approach identical"],
        ["<b>Fertility concerns</b>",
         "Paramount — most have not yet completed puberty or reproduction",
         "Important but patient may have completed family"],
        ["<b>AFP interpretation</b>",
         "MUST use age-adjusted norms (physiologically elevated up to age 2)",
         "Adult norms apply (upper limit ~10 ng/mL)"],
        ["<b>Cisplatin ototoxicity</b>",
         "Higher risk in developing auditory system; audiometry mandatory; consider carboplatin substitution",
         "Less sensitive; standard cisplatin dosing generally tolerated"],
        ["<b>Bleomycin pulmonary toxicity</b>",
         "Growing lungs may be more susceptible; omit bleomycin in low-risk cases (COG approach)",
         "Standard BEP used; omit bleomycin only if pulmonary compromise"],
        ["<b>Secondary malignancy (etoposide)</b>",
         "Higher relative risk due to longer remaining life; AML risk ~0.4% with standard doses",
         "Lower absolute residual risk; standard dosing"],
        ["<b>Gonadal dysgenesis / DSD</b>",
         "More clinically relevant; evaluate karyotype; 46,XY DSD requires prophylactic gonadectomy",
         "Less common; DSD typically diagnosed in childhood"],
        ["<b>Surgical approach (laparoscopy)</b>",
         "Acceptable for small lesions; laparotomy preferred for large/solid masses",
         "Similar approach; laparoscopic experience often greater"],
        ["<b>Omentectomy</b>",
         "Omental biopsy preferred over complete omentectomy to reduce morbidity",
         "Infracolic omentectomy standard at staging laparotomy"],
        ["<b>Lymph node dissection</b>",
         "Sampling (not systematic dissection) sufficient for apparent early-stage disease",
         "Para-aortic and pelvic lymph node sampling/dissection at staging"],
        ["<b>Chemotherapy regimen</b>",
         "BEP standard; COG protocols use carboplatin/etoposide for low-risk (AGCT0132)",
         "BEP (3–4 cycles) standard across all risk groups"],
        ["<b>Surveillance post-stage IA</b>",
         "Active surveillance preferred over adjuvant chemo for dysgerminoma/grade 1 IT",
         "Surveillance approach similar; lower threshold for chemo in some adult protocols"],
        ["<b>Role of second-look surgery</b>",
         "Limited; residual mature teratoma masses may need resection (GTS)",
         "Similarly limited; GTS recognised in adults too"],
        ["<b>Psychosocial impact</b>",
         "Body image, pubertal development, academic disruption; specialised paediatric support essential",
         "Fertility anxiety, relationship impact; adult oncology psychosocial support"],
        ["<b>Long-term follow-up institution</b>",
         "Paediatric oncology long-term follow-up clinic (LTFU) — transition to adult at 16–18 years",
         "Adult oncology follow-up"],
    ]
    story.append(make_table(comp_headers, comp_rows, col_widths=[5.5*cm, 5.5*cm, 6*cm]))
    story.append(Paragraph("Sources: Berek & Novak's Gynecology; COG AGCT protocols; Weil et al., Semin Pediatr Surg 2023 (PMID 38039829); De Maria et al., J Gynecol Oncol 2025 (PMID 40275685)", caption_style))

    # ══ 11. MULTIDISCIPLINARY MANAGEMENT ══
    story += section("11. Multidisciplinary Team (MDT) Approach")
    story.append(p(
        "Optimal management of paediatric ovarian GCTs requires a dedicated MDT at a specialist centre:"
    ))
    mdt_headers = ["Team Member", "Role"]
    mdt_rows = [
        ["Paediatric/Adolescent Oncologist", "Overall treatment coordination, chemotherapy prescription, trial enrolment"],
        ["Paediatric/Gynaecological Surgeon", "Primary surgery, staging, fertility-preserving technique"],
        ["Histopathologist (specialist GYN/paediatric)", "Accurate diagnosis, tumour grading, molecular markers"],
        ["Diagnostic Radiologist", "Imaging interpretation, staging, response assessment, USS-guided procedures"],
        ["Clinical Nurse Specialist", "Patient/family education, symptom management, psychological support"],
        ["Fertility Specialist / Reproductive Endocrinologist", "Pre-treatment fertility counselling and preservation planning"],
        ["Clinical Geneticist", "Karyotype evaluation, DSD assessment, familial risk counselling"],
        ["Psychologist / Child Psychiatrist", "Psychological support for child and family"],
        ["Endocrinologist", "HRT management if ovarian failure; pubertal induction"],
        ["Audiologist", "Cisplatin ototoxicity monitoring (before, during, after treatment)"],
        ["Long-Term Follow-Up Team", "Late effects monitoring, transition to adult care"],
    ]
    story.append(make_table(mdt_headers, mdt_rows, col_widths=[6.5*cm, 10.5*cm]))

    # ══ 12. EMERGING CONCEPTS ══
    story += section("12. Emerging Concepts & Current Research")
    story += subsection("12.1 Controversies in Management (2025)")
    story.append(p(
        "A 2025 review in <i>International Journal of Gynaecological Cancer</i> (Seckl et al., PMID 40020416) "
        "highlights ongoing controversies:"
    ))
    for item in [
        "<b>Carboplatin vs. cisplatin:</b> Carboplatin offers equivalent efficacy with less ototoxicity/nephrotoxicity in good-risk disease, but cisplatin remains standard in high-risk/advanced stages.",
        "<b>Bleomycin omission:</b> COG AGCT0132 trial demonstrated that carboplatin + etoposide (without bleomycin) may be sufficient for low-risk paediatric GCTs, avoiding pulmonary toxicity.",
        "<b>Surveillance vs. adjuvant chemo in stage IA:</b> For YST, increasing evidence supports immediate BEP (3 cycles) rather than surveillance, given high relapse risk (~25%) and excellent salvage.",
        "<b>Number of chemotherapy cycles:</b> Ongoing debate about whether 3 vs. 4 cycles is optimal in stage III/IV, balancing cure rates against cumulative toxicity.",
        "<b>Laparoscopic staging:</b> Concern about port-site metastases and tumour spillage; standardised laparoscopic staging protocols needed.",
        "<b>Molecular biomarkers:</b> isochromosome 12p (i[12p]) characteristic of adult testicular GCTs; less consistent in paediatric ovarian GCTs (especially prepubertal). May indicate biologically distinct entity.",
        "<b>Immunotherapy:</b> PD-L1 expression in some GCTs; early trials investigating checkpoint inhibitors in refractory disease."
    ]:
        story.append(b(item))

    story += subsection("12.2 Recurrent / Refractory Disease (2024 Review)")
    story.append(p(
        "Nasioudis & Pashankar (Int J Gynecol Cancer 2024, PMID 38991656) reviewed management of recurrent/persistent GCTs:"
    ))
    for item in [
        "Platinum-sensitive recurrence (>4 weeks from last cisplatin): TIP regimen (paclitaxel + ifosfamide + cisplatin) — response rate ~65–80%.",
        "Platinum-refractory disease: High-dose chemotherapy (carboplatin, etoposide, ifosfamide) + autologous stem cell transplant (ASCT) in eligible patients.",
        "Surgical resection of residual disease after salvage chemotherapy improves outcomes.",
        "Paediatric patients with recurrence have higher salvage rates than adults.",
        "Gemcitabine + oxaliplatin (GEMOX) is an option in heavily pre-treated patients."
    ]:
        story.append(b(item))

    # ══ 13. REFERENCES ══
    story += section("13. Key References")
    refs = [
        "1. Berek JS, et al. Berek & Novak's Gynecology, 16th ed. Wolters Kluwer, 2020. Chapter 39: Germ Cell Malignancies.",
        "2. Kumar V, et al. Robbins & Cotran Pathologic Basis of Disease, 10th ed. Elsevier, 2021. Chapter 22: Female Genital System.",
        "3. Harrison's Principles of Internal Medicine, 22nd ed. McGraw-Hill, 2025. Uncommon Ovarian Tumours.",
        "4. Weil BR, Rich BS, Madenci AL. Critical elements in the operative management of pediatric malignant ovarian germ cell tumors. Semin Pediatr Surg. 2023 Oct;32(5). PMID: 38039829.",
        "5. Nasioudis D, Pashankar FD. Management of recurrent and persistent malignant ovarian germ cell tumors: a narrative review. Int J Gynecol Cancer. 2024 Sep;34(9). PMID: 38991656.",
        "6. Seckl MJ, Kaur B, Ghorani E. Controversies in malignant ovarian germ cell tumors. Int J Gynecol Cancer. 2025 Mar. PMID: 40020416.",
        "7. De Maria F, Amant F, Chiappa V, et al. Malignant germ cell tumor of the ovary. J Gynecol Oncol. 2025 May. PMID: 40275685.",
        "8. Zerdeva E, et al. Fertility preservation in rare ovarian malignancies: a decade-spanning systematic review. Cancer Causes Control. 2025. PMID: 41068325.",
        "9. Children's Oncology Group (COG). AGCT0132 Protocol: Carboplatin and Etoposide for Paediatric GCTs.",
        "10. WHO Classification of Tumours of Female Reproductive Organs, 5th ed. IARC, 2020.",
    ]
    for ref in refs:
        story.append(p(ref, note_style))
        story.append(spacer(0.05))

    # BUILD
    doc.build(story, onFirstPage=on_first_page, onLaterPages=on_page)
    print(f"PDF generated: {OUTPUT_PATH}")

if __name__ == "__main__":
    build_document()
Running Command

cd /home/daytona/workspace/paediatric-gct && python3 generate_pdf.py 2>&1

Editing File

~/paediatric-gct/generate_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/paediatric-gct/generate_pdf.py'
Running Command

cd /home/daytona/workspace/paediatric-gct && python3 generate_pdf.py 2>&1

Editing File

~/paediatric-gct/generate_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/paediatric-gct/generate_pdf.py'
Editing File

~/paediatric-gct/generate_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/paediatric-gct/generate_pdf.py'
Running Command

cd /home/daytona/workspace/paediatric-gct && python3 generate_pdf.py 2>&1

The PDF has been generated successfully. Here is your download link:

Paediatric Ovarian GCT

PDF Document · PDF


What the document covers

The PDF is a comprehensive, fully structured clinical reference built from Berek & Novak's Gynecology, Robbins Pathologic Basis of Disease, Harrison's 22E, and PubMed literature up to 2025. It includes:

Sections & Key Content

SectionContent
1. EpidemiologyIncidence table comparing paediatric vs adult, age peaks, prognosis overview
2. WHO Classification & TypesFull WHO classification table; detailed entries for dysgerminoma, YST (Schiller-Duval bodies), immature teratoma with Norris grading table, embryonal carcinoma, choriocarcinoma, mixed GCTs, dermoid cysts
3. Clinical Presentation & DiagnosisSymptoms frequency table; tumour markers table (AFP with age-adjusted norms caveat for infants - critical boxed note); imaging modality table
4. FIGO 2014 StagingFull stage IA through IV staging table
5. Surgical ManagementPrinciples of USO + conservation; stage-by-stage surgical approach table; DSD/gonadal dysgenesis; flowchart for surgical decision-making
6. ChemotherapyBEP regimen table (dose/route/mechanism); cycles-by-stage table; toxicity table with paediatric-specific notes (ototoxicity, secondary leukaemia, pulmonary); alternative regimens (carboplatin/etoposide, TIP, EMA-CO, HDCT/ASCT); radiation role; chemotherapy decision flowchart
7. Fertility & HormonesFertility outcomes data (2025 systematic review); HRT for bilateral oophorectomy cases
8. SurveillanceTime-based surveillance protocol table; growing teratoma syndrome
9. PrognosisSurvival by tumour type and stage
10. Paediatric vs Adult Comparison18-row detailed comparison table covering biology, markers, grading significance, cisplatin ototoxicity, bleomycin omission, etoposide secondary malignancy, DSD, surgical approach, follow-up
11. MDT11-member team roles table
12. Emerging Concepts2025 controversies (carboplatin vs cisplatin, bleomycin omission, surveillance vs chemo in stage IA YST, immunotherapy); recurrence management
13. References10 key references including PMIDs for recent literature

I can't open above PDF

Running Command

ls -lh /home/daytona/workspace/paediatric-gct/Paediatric_Ovarian_GCT.pdf && python3 -c "from pypdf import PdfReader; r=PdfReader('/home/daytona/workspace/paediatric-gct/Paediatric_Ovarian_GCT.pdf'); print(f'Pages: {len(r.pages)}, Valid PDF')"

Running Command

cp /home/daytona/workspace/paediatric-gct/Paediatric_Ovarian_GCT.pdf /home/daytona/workspace/Paediatric_Ovarian_GCT.pdf && ls -lh /home/daytona/workspace/Paediatric_Ovarian_GCT.pdf

The file is confirmed valid (14 pages). Try this direct path link:

Paediatric Ovarian GCT

PDF Document · PDF


If that still doesn't work, here are a few things to try:
Option 1 - Right-click the link above and choose "Save link as..." to download it directly.
Option 2 - Check your browser: Some browsers block downloads from sandbox paths. Try a different browser (Chrome or Firefox work best).
Option 3 - The content is complete regardless. Here is the full clinical summary in text form so you have all the information immediately:

Quick Text Summary of All Key Content

Types of Paediatric Ovarian GCTs

TypeKey MarkerMalignant?
DysgerminomaLDH, PLAPYes
Yolk Sac TumourAFPYes
Immature TeratomaAFP (mild)Yes (grade-dependent)
Embryonal CarcinomaAFP + hCGYes
ChoriocarcinomahCGYes
Mature Cystic TeratomaNoneNo (benign)
Mixed GCTMultipleYes

Standard Chemotherapy - BEP

  • Bleomycin 30 units IV - Days 1, 8, 15
  • Etoposide 100 mg/m²/day IV - Days 1–5
  • Platinum (cisplatin) 20 mg/m²/day IV - Days 1–5
  • Cycle length: 21 days | Stage IC–II: 3 cycles | Stage III–IV: 4 cycles

Key Paediatric vs Adult Differences

  • AFP must use age-adjusted norms in children under 2
  • Children with immature teratoma do well with surgery alone regardless of grade
  • Higher risk of cisplatin ototoxicity - audiometry mandatory
  • COG protocols use carboplatin + etoposide (no bleomycin) for low-risk paediatric cases
  • Fertility preservation is paramount - USO always preferred over bilateral oophorectomy
Would you like me to try generating the document in a different format (e.g., Word .docx) that may be easier to open?

Yes, generate in word format

Reading File
Running Command

ls /home/daytona/skills/docx/scripts/office/ && node --version

Running Command

cd /home/daytona/workspace/paediatric-gct && npm install docx 2>&1 | tail -5

Running Command

python3 -c "from docx import Document; from docx.shared import Pt, RGBColor, Cm, Inches; from docx.enum.text import WD_ALIGN_PARAGRAPH; print('python-docx OK')"

Running Command

pip install --user python-docx 2>&1 | tail -5

Writing File

~/paediatric-gct/generate_docx.py

#!/usr/bin/env python3
"""
Paediatric Ovarian Germ Cell Tumours - Word Document Generator
"""
from docx import Document
from docx.shared import Pt, RGBColor, Cm, Inches, Twips
from docx.enum.text import WD_ALIGN_PARAGRAPH, WD_LINE_SPACING
from docx.enum.table import WD_TABLE_ALIGNMENT, WD_ALIGN_VERTICAL
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
import copy

OUTPUT = "/home/daytona/workspace/paediatric-gct/Paediatric_Ovarian_GCT.docx"

# ── Colours ────────────────────────────────────────────────────────────────────
TEAL      = RGBColor(0x00, 0x6B, 0x6B)
TEAL_L    = RGBColor(0xE0, 0xF0, 0xF0)
ORANGE    = RGBColor(0xE0, 0x7B, 0x39)
ORANGE_L  = RGBColor(0xFD, 0xF0, 0xE8)
BLUE_D    = RGBColor(0x1A, 0x3A, 0x5C)
WHITE     = RGBColor(0xFF, 0xFF, 0xFF)
BLACK     = RGBColor(0x00, 0x00, 0x00)
GREY_BG   = RGBColor(0xF5, 0xF5, 0xF5)
RED_D     = RGBColor(0xC0, 0x39, 0x2B)
RED_L     = RGBColor(0xFD, 0xEC, 0xEA)
GREEN_D   = RGBColor(0x1E, 0x7B, 0x34)
GREEN_L   = RGBColor(0xEA, 0xF7, 0xEC)
PURPLE    = RGBColor(0x6A, 0x05, 0x72)

def hex_to_str(c: RGBColor) -> str:
    return f"{c[0]:02X}{c[1]:02X}{c[2]:02X}"

# ── Helpers ────────────────────────────────────────────────────────────────────

def set_cell_bg(cell, color: RGBColor):
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    shd = OxmlElement('w:shd')
    shd.set(qn('w:val'), 'clear')
    shd.set(qn('w:color'), 'auto')
    shd.set(qn('w:fill'), hex_to_str(color))
    tcPr.append(shd)

def set_cell_border(cell, **kwargs):
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    tcBorders = OxmlElement('w:tcBorders')
    for edge in ('top','left','bottom','right','insideH','insideV'):
        if edge in kwargs:
            tag = OxmlElement(f'w:{edge}')
            for attr, val in kwargs[edge].items():
                tag.set(qn(f'w:{attr}'), val)
            tcBorders.append(tag)
    tcPr.append(tcBorders)

def set_run_font(run, size_pt, bold=False, italic=False, color=None, font_name='Calibri'):
    run.font.name = font_name
    run.font.size = Pt(size_pt)
    run.font.bold = bold
    run.font.italic = italic
    if color:
        run.font.color.rgb = color

def add_heading(doc, text, level=1, color=TEAL, size=None):
    """Add a styled heading paragraph."""
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(14 if level == 1 else 8)
    p.paragraph_format.space_after  = Pt(4)
    run = p.add_run(text)
    if level == 1:
        run.font.size = Pt(size or 15)
        run.font.color.rgb = WHITE
        run.font.bold = True
        run.font.name = 'Calibri'
        # Shade the paragraph background
        pPr = p._p.get_or_add_pPr()
        shd = OxmlElement('w:shd')
        shd.set(qn('w:val'), 'clear')
        shd.set(qn('w:color'), 'auto')
        shd.set(qn('w:fill'), hex_to_str(color))
        pPr.append(shd)
        p.paragraph_format.left_indent = Cm(0.3)
    elif level == 2:
        run.font.size = Pt(size or 12)
        run.font.color.rgb = color
        run.font.bold = True
        run.font.name = 'Calibri'
    elif level == 3:
        run.font.size = Pt(size or 10.5)
        run.font.color.rgb = BLUE_D
        run.font.bold = True
        run.font.name = 'Calibri'
    return p

def add_body(doc, text, bold_parts=None, indent=False):
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(2)
    p.paragraph_format.space_after  = Pt(3)
    if indent:
        p.paragraph_format.left_indent = Cm(0.5)
    run = p.add_run(text)
    run.font.size = Pt(9.5)
    run.font.name = 'Calibri'
    run.font.color.rgb = BLACK
    return p

def add_bullet(doc, text, level=0):
    p = doc.add_paragraph(style='List Bullet')
    p.paragraph_format.space_before = Pt(1)
    p.paragraph_format.space_after  = Pt(1)
    p.paragraph_format.left_indent  = Cm(0.6 + level*0.4)
    run = p.add_run(text)
    run.font.size = Pt(9.5)
    run.font.name = 'Calibri'
    return p

def add_note_box(doc, text, label="NOTE", bg=ORANGE_L, label_color=ORANGE):
    """Simulate a callout box using a single-cell table."""
    tbl = doc.add_table(rows=1, cols=1)
    tbl.alignment = WD_TABLE_ALIGNMENT.CENTER
    cell = tbl.rows[0].cells[0]
    set_cell_bg(cell, bg)
    # border
    for edge in ['top','left','bottom','right']:
        set_cell_border(cell, **{edge: {'val':'single','sz':'12','color':hex_to_str(label_color),'space':'0'}})
    cell.paragraphs[0].clear()
    p = cell.paragraphs[0]
    p.paragraph_format.space_before = Pt(3)
    p.paragraph_format.space_after  = Pt(3)
    run_label = p.add_run(f"{label}: ")
    run_label.font.bold = True
    run_label.font.color.rgb = label_color
    run_label.font.size = Pt(9)
    run_label.font.name = 'Calibri'
    run_text = p.add_run(text)
    run_text.font.size = Pt(9)
    run_text.font.name = 'Calibri'
    run_text.font.color.rgb = BLACK
    doc.add_paragraph()  # spacing after box
    return tbl

def make_table(doc, headers, rows, col_widths=None, hdr_bg=TEAL, stripe=GREY_BG, font_size=8.5):
    """Create a styled table."""
    num_cols = len(headers)
    tbl = doc.add_table(rows=1, cols=num_cols)
    tbl.alignment = WD_TABLE_ALIGNMENT.CENTER
    tbl.style = 'Table Grid'

    # Header row
    hdr_row = tbl.rows[0]
    for i, h in enumerate(headers):
        cell = hdr_row.cells[i]
        set_cell_bg(cell, hdr_bg)
        cell.paragraphs[0].clear()
        p = cell.paragraphs[0]
        p.alignment = WD_ALIGN_PARAGRAPH.CENTER
        run = p.add_run(h)
        run.font.bold = True
        run.font.size = Pt(font_size)
        run.font.color.rgb = WHITE
        run.font.name = 'Calibri'
        cell.vertical_alignment = WD_ALIGN_VERTICAL.CENTER

    # Data rows
    for ri, row in enumerate(rows):
        tr = tbl.add_row()
        bg = GREY_BG if ri % 2 == 1 else WHITE
        for ci, cell_text in enumerate(row):
            cell = tr.cells[ci]
            set_cell_bg(cell, bg)
            cell.paragraphs[0].clear()
            p = cell.paragraphs[0]
            p.alignment = WD_ALIGN_PARAGRAPH.LEFT
            # Handle bold markers
            if cell_text.startswith('<b>') and '</b>' in cell_text:
                bold_part = cell_text[3:cell_text.index('</b>')]
                rest = cell_text[cell_text.index('</b>')+4:]
                run = p.add_run(bold_part)
                run.font.bold = True
                run.font.size = Pt(font_size)
                run.font.name = 'Calibri'
                if rest:
                    run2 = p.add_run(rest)
                    run2.font.size = Pt(font_size)
                    run2.font.name = 'Calibri'
            else:
                run = p.add_run(cell_text)
                run.font.size = Pt(font_size)
                run.font.name = 'Calibri'
            cell.vertical_alignment = WD_ALIGN_VERTICAL.TOP

    # Set column widths
    if col_widths:
        for i, width in enumerate(col_widths):
            for row in tbl.rows:
                row.cells[i].width = width

    doc.add_paragraph()  # spacing after table
    return tbl

def add_caption(doc, text):
    p = doc.add_paragraph()
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    p.paragraph_format.space_before = Pt(0)
    p.paragraph_format.space_after = Pt(6)
    run = p.add_run(text)
    run.font.italic = True
    run.font.size = Pt(8.5)
    run.font.color.rgb = RGBColor(0x55, 0x55, 0x55)
    run.font.name = 'Calibri'
    return p

def add_flowchart_text(doc, steps, title=""):
    """Render flowchart as styled sequential paragraphs (since true drawing is complex)."""
    if title:
        p = doc.add_paragraph()
        run = p.add_run(title)
        run.font.bold = True
        run.font.size = Pt(9.5)
        run.font.color.rgb = BLUE_D
        run.font.name = 'Calibri'
        p.paragraph_format.space_after = Pt(3)

    for i, step in enumerate(steps):
        # Box as single-cell table
        tbl = doc.add_table(rows=1, cols=1)
        tbl.alignment = WD_TABLE_ALIGNMENT.CENTER
        cell = tbl.rows[0].cells[0]
        bg = step.get('color', TEAL_L)
        set_cell_bg(cell, bg)
        tc = step.get('text_color', BLACK)
        for edge in ['top','left','bottom','right']:
            bc = step.get('border_color', TEAL)
            set_cell_border(cell, **{edge: {'val':'single','sz':'12','color':hex_to_str(bc),'space':'0'}})
        p = cell.paragraphs[0]
        p.alignment = WD_ALIGN_PARAGRAPH.CENTER
        p.paragraph_format.space_before = Pt(4)
        p.paragraph_format.space_after  = Pt(4)
        run = p.add_run(step['text'])
        run.font.size = Pt(9)
        run.font.bold = step.get('bold', True)
        run.font.color.rgb = tc
        run.font.name = 'Calibri'

        # Arrow between steps
        if i < len(steps) - 1:
            ap = doc.add_paragraph()
            ap.alignment = WD_ALIGN_PARAGRAPH.CENTER
            ap.paragraph_format.space_before = Pt(0)
            ap.paragraph_format.space_after  = Pt(0)
            arun = ap.add_run("▼")
            arun.font.color.rgb = TEAL
            arun.font.size = Pt(12)
            arun.font.name = 'Calibri'

    doc.add_paragraph()

# ══════════════════════════════════════════════════════════════════════════════
#  BUILD DOCUMENT
# ══════════════════════════════════════════════════════════════════════════════

WHITE_RGB = RGBColor(0xFF, 0xFF, 0xFF)
TEAL_L = RGBColor(0xE0, 0xF0, 0xF0)

def build():
    doc = Document()

    # Page margins
    for section in doc.sections:
        section.top_margin    = Cm(2)
        section.bottom_margin = Cm(2)
        section.left_margin   = Cm(2)
        section.right_margin  = Cm(2)

    # ── TITLE PAGE ────────────────────────────────────────────────────────────
    doc.add_paragraph()
    title_p = doc.add_paragraph()
    title_p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    tr1 = title_p.add_run("Paediatric Ovarian Germ Cell Tumours")
    tr1.font.size = Pt(26)
    tr1.font.bold = True
    tr1.font.color.rgb = TEAL
    tr1.font.name = 'Calibri'

    sub_p = doc.add_paragraph()
    sub_p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    sr1 = sub_p.add_run("Types · Diagnosis · Medical & Surgical Management")
    sr1.font.size = Pt(13)
    sr1.font.color.rgb = BLUE_D
    sr1.font.name = 'Calibri'

    sub_p2 = doc.add_paragraph()
    sub_p2.alignment = WD_ALIGN_PARAGRAPH.CENTER
    sr2 = sub_p2.add_run("Comparison with Adult Ovarian GCTs")
    sr2.font.size = Pt(13)
    sr2.font.color.rgb = BLUE_D
    sr2.font.name = 'Calibri'

    doc.add_paragraph()
    cite_p = doc.add_paragraph()
    cite_p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    cr = cite_p.add_run(
        "Based on Berek & Novak's Gynecology · Robbins Pathologic Basis of Disease · "
        "Harrison's Principles of Internal Medicine 22E · PubMed Literature 2021–2025"
    )
    cr.font.size = Pt(9)
    cr.font.italic = True
    cr.font.color.rgb = RGBColor(0x55,0x55,0x55)
    cr.font.name = 'Calibri'

    doc.add_page_break()

    # ══ 1. INTRODUCTION ══════════════════════════════════════════════════════
    add_heading(doc, "1. Introduction & Epidemiology")
    add_body(doc,
        "Ovarian germ cell tumours (GCTs) arise from the primordial germ cells of the ovary. "
        "They constitute 15–20% of all ovarian tumours but represent a disproportionately large "
        "share of ovarian malignancies in the paediatric and adolescent age group. In females under "
        "20 years, malignant GCTs account for approximately 70% of ovarian malignancies, compared "
        "with only ~5% in the adult population overall."
    )
    add_heading(doc, "Key Epidemiological Comparison", level=2)
    make_table(doc,
        ["Parameter", "Paediatric / Adolescent (<20 yr)", "Adult (>20 yr)"],
        [
            ["Proportion of ovarian malignancies", "~70%", "~5%"],
            ["Peak age", "10–20 years (adolescence)", "20–40 years"],
            ["Most common malignant GCT", "Dysgerminoma / Immature teratoma", "Dysgerminoma"],
            ["Bilateral disease", "~10–15% (dysgerminoma)", "~10–15% (dysgerminoma)"],
            ["Overall survival (stage I)", ">95% with modern therapy", ">90% with modern therapy"],
            ["Fertility preservation priority", "Extremely high", "High"],
        ],
        col_widths=[Cm(6), Cm(6), Cm(6)]
    )

    # ══ 2. CLASSIFICATION ════════════════════════════════════════════════════
    add_heading(doc, "2. WHO Classification & Tumour Types")
    add_body(doc,
        "The 2020 WHO Classification divides ovarian GCTs into three broad categories:"
    )
    make_table(doc,
        ["Category", "Subtypes", "Key Features"],
        [
            ["<b>1. Primitive Germ Cell Tumours",
             "Dysgerminoma\nYolk sac tumour\nEmbryonal carcinoma\nPolyembryoma\nNon-gestational choriocarcinoma\nMixed GCT",
             "Undifferentiated; most malignant; AFP/hCG markers useful"],
            ["<b>2. Biphasic/Triphasic Teratoma",
             "Immature teratoma (grades 1–3)\nMature teratoma — solid/cystic (dermoid)\nFetiform teratoma",
             "Contain elements of ≥2 germ layers; maturity determines malignant potential"],
            ["<b>3. Monodermal Teratoma & Somatic-type",
             "Struma ovarii\nCarcinoid\nNeuroectodermal tumour\nMelanocytic, sarcoma, sebaceous",
             "Differentiated along one lineage; rare; specific clinical syndromes"],
        ],
        col_widths=[Cm(5), Cm(6), Cm(7)]
    )
    add_caption(doc, "Table 1: WHO Classification of Ovarian GCTs (adapted from Berek & Novak's Gynecology, Table 39-5)")

    # ── 2.1 Dysgerminoma
    add_heading(doc, "2.1 Dysgerminoma", level=2)
    for item in [
        "Most common malignant GCT in children/adolescents (~50% of malignant GCTs in females <20 yr).",
        "Peak incidence: second and third decades; rare before age 10.",
        "~10–15% bilateral at presentation; contralateral ovary must be evaluated.",
        "Pure dysgerminoma does NOT secrete AFP; ~3–5% secrete hCG (syncytiotrophoblastic giant cells).",
        "Highly radiosensitive and chemosensitive — excellent prognosis.",
        "Associated with gonadal dysgenesis (46,XY phenotypic females; gonadoblastoma precursor).",
        "Histology: large uniform cells with clear cytoplasm, prominent nucleoli, fibrous stroma with lymphocytes.",
        "LDH is the primary serum marker for diagnosis and monitoring.",
    ]: add_bullet(doc, item)

    # ── 2.2 Yolk Sac Tumour
    add_heading(doc, "2.2 Yolk Sac Tumour (Endodermal Sinus Tumour)", level=2)
    for item in [
        "Second most common malignant GCT; most common in first two decades (median age ~19 yr).",
        "Almost always unilateral.",
        "Produces AFP (alpha-fetoprotein) — reliable serum tumour marker for diagnosis and follow-up.",
        "Rapid growth; often presents as a large solid-cystic pelvic/abdominal mass.",
        "Histological hallmark: Schiller-Duval bodies (perivascular glomeruloid structures).",
        "Prognosis dramatically improved with BEP chemotherapy (>80% 5-year survival).",
    ]: add_bullet(doc, item)

    # ── 2.3 Immature Teratoma
    add_heading(doc, "2.3 Immature Teratoma", level=2)
    for item in [
        "Second most common malignant ovarian tumour in women <20 years.",
        "~50% occur between ages 10–20; rare in postmenopausal women.",
        "Graded by amount of immature neuroepithelium (Norris grading system).",
        "CRITICAL paediatric distinction: children (<10 yr) have excellent outcomes with surgery alone regardless of grade.",
        "May be associated with gliomatosis peritonei (mature glial implants) — a favourable sign.",
        "Growing teratoma syndrome: paradoxical enlargement during/after chemotherapy from mature element growth.",
    ]: add_bullet(doc, item)

    add_heading(doc, "Immature Teratoma Grading & Management", level=3)
    make_table(doc,
        ["Grade", "Neuroepithelium (LPF ×4)", "Management", "5-yr OS"],
        [
            ["Grade 1 (Low)", "<1 low-power field", "Surgery alone (USO)", ">95%"],
            ["Grade 2 (High)", "1–3 low-power fields", "Surgery + BEP ×3 (if adult/recurrent)", "~85–90%"],
            ["Grade 3 (High)", ">3 low-power fields", "Surgery + BEP ×3–4", "~85%"],
        ],
        col_widths=[Cm(3), Cm(4.5), Cm(7), Cm(2.5)]
    )
    add_caption(doc, "Table 2: Norris grading of immature teratoma and management implications")

    # ── 2.4 Embryonal Carcinoma
    add_heading(doc, "2.4 Embryonal Carcinoma", level=2)
    for item in [
        "Rare pure form; usually a component of mixed GCT.",
        "Occurs in adolescents (median ~15 years).",
        "Secretes both AFP and hCG; may cause isosexual precocious puberty.",
        "Highly aggressive; requires BEP-based chemotherapy.",
    ]: add_bullet(doc, item)

    # ── 2.5 Choriocarcinoma
    add_heading(doc, "2.5 Non-Gestational Choriocarcinoma", level=2)
    for item in [
        "Extremely rare; must exclude gestational origin.",
        "Secretes high levels of hCG — causes isosexual precocious puberty in premenarchal girls.",
        "Aggressive; often presents with metastases.",
        "Treated with BEP; EMA-CO regimen is an alternative.",
    ]: add_bullet(doc, item)

    # ── 2.6 Mixed GCT
    add_heading(doc, "2.6 Mixed Germ Cell Tumours", level=2)
    add_body(doc,
        "Mixed GCTs contain ≥2 different GCT components. Dysgerminoma + YST is the most common "
        "combination. Management is guided by the most malignant component. Markers reflect all components present."
    )

    # ── 2.7 Mature Cystic Teratoma
    add_heading(doc, "2.7 Mature Cystic Teratoma (Dermoid Cyst)", level=2)
    for item in [
        "Most common benign ovarian tumour in females <20 years.",
        "Contains ectodermal, mesodermal, and endodermal elements — hair, sebum, teeth, neural tissue.",
        "Bilateral in ~10–15% of cases.",
        "Complication: ovarian torsion (most common surgical emergency in girls with ovarian cysts).",
        "Malignant transformation rare (<2%); surgery: cystectomy with ovarian conservation.",
    ]: add_bullet(doc, item)

    doc.add_page_break()

    # ══ 3. CLINICAL PRESENTATION ═════════════════════════════════════════════
    add_heading(doc, "3. Clinical Presentation & Diagnosis")
    add_heading(doc, "3.1 Symptoms & Signs", level=2)
    make_table(doc,
        ["Feature", "Frequency", "Notes"],
        [
            ["Abdominal/pelvic mass", "~85%", "Often large; rapidly growing; may cross midline"],
            ["Abdominal pain", "~75%", "Acute (torsion/rupture) or subacute distension"],
            ["Abdominal distension", "Common", "Ascites in advanced disease"],
            ["Nausea, vomiting", "~30%", "Mechanical or hCG-mediated"],
            ["Isosexual precocious puberty", "hCG/oestrogen-secreting tumours", "Choriocarcinoma, embryonal carcinoma, YST"],
            ["Menstrual irregularity", "Adolescents", "Amenorrhoea or irregular cycles"],
            ["Acute abdomen (torsion)", "~20%", "Particularly dermoid/immature teratoma"],
            ["Constitutional symptoms", "Advanced disease", "Fever, weight loss, fatigue"],
        ],
        col_widths=[Cm(5.5), Cm(4), Cm(8.5)]
    )
    add_caption(doc, "Table 3: Clinical features of paediatric ovarian GCTs")

    add_heading(doc, "3.2 Tumour Markers", level=2)
    add_body(doc, "Serum tumour markers must be drawn BEFORE surgery. They are essential for diagnosis, staging, and monitoring.")
    make_table(doc,
        ["Marker", "Tumour Type", "Paediatric Notes"],
        [
            ["AFP (alpha-fetoprotein)", "YST, embryonal carcinoma, mixed GCT",
             "Normally elevated in neonates (up to 100,000 ng/mL); use age-adjusted norms. AFP >1000 ng/mL strongly suggests YST."],
            ["hCG (beta-hCG)", "Choriocarcinoma, embryonal carcinoma, dysgerminoma (~3–5%)",
             "Elevated hCG in premenarchal girls causes isosexual precocious puberty"],
            ["LDH", "Dysgerminoma (most sensitive marker)", "Non-specific but essential for dysgerminoma staging/monitoring"],
            ["PLAP", "Dysgerminoma", "Less widely used; helps confirm diagnosis"],
            ["CA-125", "Non-specific; any GCT", "Useful if elevated at diagnosis for monitoring"],
            ["Inhibin B", "Sex cord-stromal tumours (not GCT)", "Important differential marker"],
        ],
        col_widths=[Cm(4), Cm(5), Cm(9)]
    )
    add_note_box(doc,
        "AFP is physiologically elevated in neonates and infants up to age 2 years. "
        "Age-adjusted reference ranges MUST be used. An AFP of 50 ng/mL is normal in a 1-month-old "
        "but highly suspicious in a 5-year-old.",
        label="CRITICAL", bg=RED_L, label_color=RED_D)

    add_heading(doc, "3.3 Imaging", level=2)
    make_table(doc,
        ["Modality", "Role", "Typical Findings"],
        [
            ["Pelvic/Abdominal USS", "First-line", "Complex adnexal mass; solid and cystic components; calcifications (teeth in dermoid)"],
            ["CT Chest/Abdomen/Pelvis", "Staging", "Retroperitoneal lymphadenopathy; peritoneal deposits; omental caking"],
            ["MRI Pelvis", "Surgical planning", "Superior soft-tissue contrast; fat signal in teratoma; relationship to uterus/contralateral ovary"],
            ["PET-CT", "Dysgerminoma staging/response", "High FDG avidity in dysgerminoma; less reliable for mature teratoma"],
            ["Chest X-ray", "Basic staging", "Mediastinal adenopathy in advanced dysgerminoma"],
        ],
        col_widths=[Cm(4), Cm(4), Cm(10)]
    )
    add_caption(doc, "Table 4: Imaging modalities in paediatric ovarian GCTs")

    # ══ 4. STAGING ═══════════════════════════════════════════════════════════
    add_heading(doc, "4. FIGO 2014 Staging")
    make_table(doc,
        ["Stage", "Description"],
        [
            ["I", "Tumour confined to the ovary/ovaries"],
            ["IA", "Limited to one ovary; capsule intact; no surface tumour; no malignant cells in washings"],
            ["IB", "Both ovaries; capsule intact; no surface tumour; no malignant cells in washings"],
            ["IC1", "Surgical spill"],
            ["IC2", "Capsule rupture before surgery or tumour on ovarian surface"],
            ["IC3", "Malignant cells in ascites or peritoneal washings"],
            ["II", "Extension within the pelvis (below pelvic brim)"],
            ["IIA", "Extension/implants on uterus and/or fallopian tubes"],
            ["IIB", "Extension to other pelvic intraperitoneal tissues"],
            ["III", "Confirmed spread to peritoneum outside pelvis and/or retroperitoneal lymph nodes"],
            ["IIIA1", "Positive retroperitoneal lymph nodes only"],
            ["IIIA2", "Microscopic extrapelvic peritoneal involvement ± positive nodes"],
            ["IIIB", "Macroscopic peritoneal metastases ≤2 cm"],
            ["IIIC", "Macroscopic peritoneal metastases >2 cm"],
            ["IV", "Distant metastases (parenchymal liver/spleen, extra-abdominal, pleural effusion with positive cytology)"],
        ],
        col_widths=[Cm(2.5), Cm(15.5)]
    )
    add_caption(doc, "Table 5: FIGO 2014 staging of ovarian tumours")

    doc.add_page_break()

    # ══ 5. SURGICAL MANAGEMENT ════════════════════════════════════════════════
    add_heading(doc, "5. Surgical Management")
    add_body(doc,
        "Surgery serves as both the diagnostic (staging) and primary therapeutic intervention. "
        "A fundamental principle in paediatric patients is fertility preservation: because GCTs are "
        "predominantly unilateral and highly chemosensitive, radical surgery is rarely required."
    )

    add_heading(doc, "5.1 Principles of Paediatric Ovarian GCT Surgery", level=2)
    for item in [
        "Unilateral salpingo-oophorectomy (USO) is the standard procedure — even in advanced-stage disease.",
        "The contralateral ovary and uterus are preserved to maintain fertility and hormonal function.",
        "Routine biopsy of normal-appearing contralateral ovary is NOT recommended (risk: adhesions, premature ovarian failure).",
        "Biopsy of contralateral ovary only if it appears abnormal on inspection.",
        "If bilateral tumours found: bilateral ovarian cystectomy (not oophorectomy) to preserve function.",
        "Complete surgical staging: peritoneal washings, omental biopsy, peritoneal biopsies, pelvic and para-aortic lymph node sampling.",
        "Systematic lymphadenectomy not routinely required in apparent early-stage disease.",
        "Minimally invasive surgery acceptable for smaller lesions; laparotomy preferred for large/solid masses >8–10 cm.",
        "Intact tumour removal is mandatory — spillage upstages to IC1.",
    ]: add_bullet(doc, item)

    add_heading(doc, "5.2 Surgical Approach by Stage", level=2)
    make_table(doc,
        ["Stage", "Surgical Procedure", "Additional Steps", "Adjuvant Chemo?"],
        [
            ["IA (intact)", "USO", "Peritoneal washings, biopsies, omental biopsy, lymph node sampling", "No (surveillance)"],
            ["IB (bilateral)", "Bilateral cystectomy/USO (attempt conservation)", "Full staging", "Yes — BEP ×3"],
            ["IC", "USO", "Full staging; careful peritoneal assessment", "Yes — BEP ×3"],
            ["II", "USO + pelvic implant debulking", "Full staging", "Yes — BEP ×3–4"],
            ["III/IV", "USO + optimal cytoreduction (<1 cm residual)", "Full staging; omentectomy; peritoneal debulking", "Yes — BEP ×4"],
            ["Recurrence", "Secondary cytoreduction if resectable", "Re-staging", "Salvage TIP/VeIP/HDCT"],
        ],
        col_widths=[Cm(2), Cm(4.5), Cm(5.5), Cm(4)]
    )
    add_caption(doc, "Table 6: Stage-by-stage surgical approach in paediatric ovarian GCTs")

    add_heading(doc, "5.3 Special Surgical Considerations", level=2)
    for item in [
        "Ovarian Torsion: Detorsion (untwisting) should always be attempted first regardless of ovarian appearance. Oophorectomy reserved for frankly necrotic ovary.",
        "Gonadal Dysgenesis/DSD: Girls with 46,XY DSD (Swyer syndrome, CAIS) have ~25–30% risk of gonadoblastoma/dysgerminoma. Prophylactic gonadectomy recommended.",
        "Laparoscopy vs. Laparotomy: Laparotomy preferred for tumours >8–10 cm or with solid components suggesting malignancy to ensure intact removal and adequate staging.",
    ]: add_bullet(doc, item)

    # Surgical Flowchart
    add_heading(doc, "Surgical Decision Algorithm", level=3)
    add_flowchart_text(doc, [
        {"text": "Paediatric/Adolescent Ovarian Mass Detected",
         "color": TEAL, "text_color": WHITE, "border_color": TEAL},
        {"text": "Baseline Assessment: USS, CT/MRI, Tumour Markers (AFP, hCG, LDH, CA-125) — Draw BEFORE Surgery",
         "color": RGBColor(0xE0,0xF0,0xF0), "text_color": BLUE_D, "border_color": TEAL},
        {"text": "Suspicious for Malignancy? (Solid component, Elevated markers, Large size >8 cm, Ascites, Bilateral)",
         "color": RGBColor(0xFD,0xF0,0xE8), "text_color": BLUE_D, "border_color": ORANGE},
        {"text": "Unilateral Salpingo-Oophorectomy (USO) + Full Surgical Staging\n(Peritoneal washings, biopsies, lymph node sampling, omental biopsy)",
         "color": RGBColor(0xE0,0xF0,0xF0), "text_color": BLUE_D, "border_color": TEAL},
        {"text": "Histopathology & Final Staging — Send fresh tissue for cytogenetics if DSD suspected",
         "color": RGBColor(0xF5,0xF5,0xF5), "text_color": BLACK, "border_color": RGBColor(0xCC,0xCC,0xCC)},
        {"text": "Multidisciplinary Team Discussion (Paediatric Oncology + Gynaecology + Pathology + Radiology)",
         "color": RGBColor(0xF3,0xE5,0xF5), "text_color": PURPLE, "border_color": PURPLE},
        {"text": "Stage IA / Grade 1 IT: Surveillance\nStage IC+, YST, Embryonal, Choriocarcinoma: BEP Chemotherapy",
         "color": RGBColor(0xEA,0xF7,0xEC), "text_color": GREEN_D, "border_color": GREEN_D},
    ], title="Figure 1: Surgical Decision Algorithm for Paediatric Ovarian Mass")

    doc.add_page_break()

    # ══ 6. MEDICAL MANAGEMENT ═══════════════════════════════════════════════
    add_heading(doc, "6. Medical Management — Chemotherapy")
    add_body(doc,
        "The BEP regimen (bleomycin, etoposide, cisplatin) is the standard first-line treatment "
        "for all malignant ovarian GCTs requiring adjuvant or primary chemotherapy. It was developed "
        "from testicular GCT experience and has transformed survival outcomes."
    )

    add_heading(doc, "6.1 BEP Regimen — Standard First-Line", level=2)
    make_table(doc,
        ["Drug", "Dose", "Route", "Schedule", "Mechanism"],
        [
            ["Bleomycin (B)", "30 units/week", "IV bolus", "Days 1, 8, 15 per 21-day cycle", "DNA strand breaks via free radicals"],
            ["Etoposide (E)", "100 mg/m²/day × 5 days", "IV infusion", "Days 1–5 per cycle", "Topoisomerase II inhibitor"],
            ["Cisplatin (P)", "20 mg/m²/day × 5 days", "IV + hydration", "Days 1–5 per cycle", "DNA intrastrand/interstrand crosslinks"],
        ],
        col_widths=[Cm(3), Cm(3.5), Cm(2.5), Cm(4.5), Cm(4.5)]
    )
    add_caption(doc, "Table 7: BEP chemotherapy regimen")

    add_heading(doc, "6.2 Number of Cycles by Stage / Risk Group", level=2)
    make_table(doc,
        ["Stage / Risk Group", "Cycles", "Regimen", "Evidence / Notes"],
        [
            ["Stage IA — dysgerminoma or grade 1 IT (completely resected)", "0 (surveillance)", "Observation", "GOG/COG data: >95% OS without chemo"],
            ["Stage IA — YST, embryonal, choriocarcinoma", "3", "BEP", "High recurrence risk (~25%) without chemo"],
            ["Stage IB (bilateral)", "3", "BEP", "After bilateral cystectomy"],
            ["Stage IC – II (any malignant GCT)", "3", "BEP", "Near-100% remission rate"],
            ["Stage III – IV", "4", "BEP", "Optimal cytoreduction + 4 cycles"],
            ["Recurrence — platinum-sensitive", "3–4", "TIP (paclitaxel + ifosfamide + cisplatin)", "Standard salvage; ~65–80% response"],
            ["Recurrence — platinum-refractory", "Variable", "HDCT + autologous SCT", "In eligible patients"],
        ],
        col_widths=[Cm(6), Cm(1.5), Cm(3), Cm(7.5)]
    )
    add_caption(doc, "Table 8: Chemotherapy cycles by stage and risk group")

    add_heading(doc, "6.3 Toxicity & Paediatric-Specific Considerations", level=2)
    make_table(doc,
        ["Drug", "Acute Toxicities", "Long-term Toxicities", "Paediatric Notes"],
        [
            ["Bleomycin", "Pulmonary pneumonitis, fever, Raynaud's, skin changes",
             "Pulmonary fibrosis (cumulative; avoid >300 units lifetime)",
             "Growing lungs vulnerable; PFTs mandatory; may omit in low-risk cases (COG protocols)"],
            ["Etoposide", "Myelosuppression, nausea, alopecia, mucositis",
             "Secondary AML (cumulative dose; risk ~0.4%)",
             "Secondary malignancy risk significant in long-lived children; minimise cumulative dose"],
            ["Cisplatin", "N&V, nephrotoxicity, electrolyte wasting (Mg, K), neuropathy",
             "Sensorineural hearing loss, renal impairment, subfertility",
             "HIGHER risk of ototoxicity in developing auditory system — audiometry MANDATORY throughout; carboplatin substitution may be considered"],
            ["BEP overall", "Febrile neutropenia (G-CSF support)", "Ovarian function usually preserved",
             "~80–90% of paediatric patients retain menstrual function and fertility after treatment"],
        ],
        col_widths=[Cm(3), Cm(4), Cm(4), Cm(7)]
    )
    add_caption(doc, "Table 9: Chemotherapy toxicity with paediatric-specific considerations")

    add_heading(doc, "6.4 Alternative Chemotherapy Regimens", level=2)
    make_table(doc,
        ["Regimen", "Drugs", "Indication", "Notes"],
        [
            ["Carboplatin + Etoposide", "Carboplatin AUC 5–6\nEtoposide 120 mg/m²/day × 3",
             "Low-risk paediatric GCT; cisplatin toxicity concern",
             "COG AGCT0132 protocol; less nephrotoxicity and ototoxicity"],
            ["TIP", "Paclitaxel 175 mg/m²\nIfosfamide 1500 mg/m²/day × 5\nCisplatin 20 mg/m²/day × 5",
             "First-line salvage — recurrent/refractory",
             "Standard salvage for platinum-sensitive recurrence"],
            ["VeIP", "Vinblastine + Ifosfamide + Cisplatin",
             "Salvage if taxane not used",
             "Testicular GCT literature-derived"],
            ["EMA-CO", "Etoposide, Methotrexate, Actinomycin-D / Cyclophosphamide, Vincristine",
             "Non-gestational choriocarcinoma",
             "Borrowed from gestational trophoblastic disease protocols"],
            ["HDCT + ASCT", "Carboplatin + Etoposide + Ifosfamide + autologous SCT",
             "Platinum-refractory recurrence",
             "In fit patients; specialist centre"],
        ],
        col_widths=[Cm(3.5), Cm(4.5), Cm(5), Cm(5)]
    )
    add_caption(doc, "Table 10: Alternative chemotherapy regimens")

    # Chemotherapy flowchart
    add_heading(doc, "Chemotherapy Decision Algorithm", level=3)
    add_flowchart_text(doc, [
        {"text": "Malignant Ovarian GCT — Post-surgical Staging Complete",
         "color": TEAL, "text_color": WHITE, "border_color": TEAL},
        {"text": "Stage IA Dysgerminoma OR Grade 1 Immature Teratoma? (completely resected, paediatric)",
         "color": RGBColor(0xFD,0xF0,0xE8), "text_color": BLUE_D, "border_color": ORANGE},
        {"text": "YES → Surveillance Protocol\n(3-monthly markers + imaging for 2 years, then 6-monthly for 3 years)",
         "color": GREEN_L, "text_color": GREEN_D, "border_color": GREEN_D},
        {"text": "NO → Any other malignant GCT (Stage IC+, YST, Embryonal, Choriocarcinoma, Mixed GCT, or Recurrent)",
         "color": RGBColor(0xE0,0xF0,0xF0), "text_color": BLUE_D, "border_color": TEAL},
        {"text": "BEP Chemotherapy\nStage IC–II: 3 cycles  |  Stage III–IV: 4 cycles\n(Cisplatin 20 mg/m²/day × 5, Etoposide 100 mg/m²/day × 5, Bleomycin 30 units days 1,8,15)",
         "color": BLUE_D, "text_color": WHITE, "border_color": BLUE_D},
        {"text": "Response Assessment: AFP/hCG/LDH normalisation + CT/MRI at cycle 3 and end of treatment",
         "color": RGBColor(0xF5,0xF5,0xF5), "text_color": BLACK, "border_color": RGBColor(0xCC,0xCC,0xCC)},
        {"text": "Complete Remission → Surveillance\nResidual/Recurrent Disease → Salvage TIP or HDCT+ASCT",
         "color": RGBColor(0xF3,0xE5,0xF5), "text_color": PURPLE, "border_color": PURPLE},
    ], title="Figure 2: Chemotherapy Decision Algorithm for Paediatric Malignant Ovarian GCT")

    doc.add_page_break()

    # ══ 7. FERTILITY & HORMONAL ════════════════════════════════════════════════
    add_heading(doc, "7. Fertility Preservation & Hormonal Considerations")
    add_body(doc,
        "Preservation of fertility and ovarian endocrine function is a paramount goal in paediatric "
        "and adolescent patients with ovarian GCTs. Modern multidisciplinary approaches achieve this "
        "in the vast majority of cases."
    )
    add_heading(doc, "7.1 Fertility Outcomes", level=2)
    for item in [
        "USO preserves fertility in the vast majority; contralateral ovary compensates adequately.",
        "BEP chemotherapy causes transient amenorrhoea in ~50%; most resume normal cycles within 6–12 months of completing treatment.",
        "Premature ovarian failure is uncommon (<10%) with standard BEP doses.",
        "Pregnancy rates post-treatment: ~70–80% in those attempting conception (systematic review PMID 41068325, 2025).",
        "Carboplatin-based regimens may have slightly better gonadal preservation than cisplatin-based in young children.",
        "Post-treatment monitoring: FSH, LH, oestradiol, and AMH (anti-Mullerian hormone).",
    ]: add_bullet(doc, item)

    add_heading(doc, "7.2 Hormonal Replacement (When Bilateral Oophorectomy Required)", level=2)
    for item in [
        "Prepubertal girls: HRT to induce puberty at appropriate age (oestrogen ± progesterone).",
        "Post-pubertal: Combined HRT (oestrogen + progesterone) for bone density and cardiovascular health.",
        "Psychological support and counselling regarding fertility implications.",
        "If uterus retained but ovaries removed: surrogacy is a viable option.",
    ]: add_bullet(doc, item)

    # ══ 8. SURVEILLANCE ════════════════════════════════════════════════════════
    add_heading(doc, "8. Surveillance After Treatment")
    make_table(doc,
        ["Interval", "Tumour Markers", "Imaging", "Clinical Review"],
        [
            ["Months 1–6 (post-treatment)", "Monthly AFP, hCG, LDH", "CT C/A/P at 3 months", "Monthly clinical review"],
            ["Months 7–24", "Every 3 months", "CT or MRI at 6, 12, 24 months", "Every 3 months"],
            ["Years 3–5", "Every 6 months", "Imaging if markers rise or symptoms develop", "Every 6 months"],
            ["After 5 years", "Annual (dysgerminoma: late relapse possible)", "Imaging if clinically indicated", "Annual review"],
        ],
        col_widths=[Cm(4.5), Cm(4.5), Cm(5), Cm(4)]
    )
    add_caption(doc, "Table 11: Surveillance protocol after treatment of paediatric ovarian GCTs")
    add_note_box(doc,
        "Dysgerminoma has the highest risk of late relapse (up to 25% without adjuvant chemo in stage IA). "
        "However, >75% of relapses are salvaged with BEP chemotherapy. Close long-term follow-up is essential.",
        label="NOTE", bg=ORANGE_L, label_color=ORANGE)

    add_heading(doc, "8.1 Growing Teratoma Syndrome (GTS)", level=2)
    add_body(doc,
        "GTS is characterised by enlarging tumour masses during or after chemotherapy for immature "
        "teratoma, with normalising serum AFP. Enlarging lesions consist entirely of mature teratomatous "
        "elements. Management is surgical resection; chemotherapy is ineffective. GTS does not imply "
        "chemotherapy failure and prognosis is excellent after complete resection."
    )

    # ══ 9. PROGNOSIS ══════════════════════════════════════════════════════════
    add_heading(doc, "9. Prognosis")
    make_table(doc,
        ["Tumour Type", "Stage", "5-Year Survival", "Notes"],
        [
            ["Dysgerminoma", "IA", ">95%", "Surgery alone; surveillance"],
            ["Dysgerminoma", "II–IV", "85–95%", "BEP; very high salvage rate"],
            ["Immature Teratoma (Grade 1)", "I", ">95%", "Surgery alone in paediatrics"],
            ["Immature Teratoma (Grade 2–3)", "I–II", "~85–90%", "Adjuvant BEP"],
            ["Immature Teratoma", "III–IV", "~75–85%", "Surgery + BEP"],
            ["Yolk Sac Tumour", "I", "~85–90%", "USO + BEP ×3"],
            ["Yolk Sac Tumour", "II–IV", "~65–80%", "USO + BEP ×3–4"],
            ["Mixed GCT", "All stages", "~70–85%", "Depends on components"],
            ["Non-gestational choriocarcinoma", "All", "~50–70%", "High-risk; often presents late"],
            ["Embryonal carcinoma", "All", "~60–75%", "Requires BEP; rare"],
        ],
        col_widths=[Cm(5.5), Cm(2.5), Cm(4), Cm(6)]
    )
    add_caption(doc, "Table 12: Prognosis of paediatric ovarian GCTs by tumour type and stage")

    doc.add_page_break()

    # ══ 10. PAEDIATRIC vs ADULT ══════════════════════════════════════════════
    add_heading(doc, "10. Paediatric vs. Adult Ovarian GCTs — Key Differences", color=BLUE_D)
    add_body(doc,
        "Although ovarian GCTs share the same WHO classification across age groups, there are "
        "important biological, clinical, and management differences between paediatric and adult patients."
    )
    make_table(doc,
        ["Parameter", "Paediatric (<20 years)", "Adult (>20 years)"],
        [
            ["<b>Most common malignant GCT", "Dysgerminoma; immature teratoma",
             "Dysgerminoma (but epithelial tumours dominate all ovarian malignancies)"],
            ["<b>YST prevalence", "More common and more aggressive presentation", "Less common; similar behaviour"],
            ["<b>Immature teratoma grading", "Grade has LESS prognostic significance; surgery alone regardless of grade in children <10 yr",
             "Grading is more prognostically significant; high-grade requires adjuvant chemotherapy"],
            ["<b>AFP interpretation", "MUST use age-adjusted norms (physiologically elevated up to age 2)", "Adult norms apply (ULN ~10 ng/mL)"],
            ["<b>Cisplatin ototoxicity", "HIGHER risk in developing auditory system; audiometry mandatory; carboplatin substitution may be considered",
             "Less sensitive; standard cisplatin dosing generally tolerated"],
            ["<b>Bleomycin pulmonary toxicity", "Growing lungs more susceptible; COG protocols omit bleomycin in low-risk cases",
             "Standard BEP used; bleomycin omitted only if pulmonary compromise"],
            ["<b>Secondary malignancy (etoposide)", "Higher relative risk due to longer remaining life; AML risk ~0.4% with standard doses",
             "Lower absolute residual risk; standard dosing"],
            ["<b>Chemotherapy regimen", "BEP standard; COG AGCT0132 uses carboplatin/etoposide (no bleomycin) for low-risk",
             "BEP (3–4 cycles) standard across all risk groups"],
            ["<b>Gonadal dysgenesis/DSD", "More clinically relevant; karyotype evaluation; 46,XY DSD requires prophylactic gonadectomy",
             "DSD typically diagnosed in childhood; less common at adult presentation"],
            ["<b>Bilateral disease management", "Bilateral cystectomy to conserve ovarian tissue; oophorectomy only if necrotic or no cyst possible",
             "Similar approach; bilateral conservation attempted"],
            ["<b>Lymph node dissection", "Sampling only (not systematic dissection) in apparent early-stage",
             "Para-aortic and pelvic lymph node sampling/dissection at staging"],
            ["<b>Omentectomy", "Omental biopsy preferred over complete omentectomy to reduce morbidity",
             "Infracolic omentectomy standard at staging laparotomy"],
            ["<b>Surveillance post-stage IA", "Active surveillance preferred; adjuvant chemo withheld for dysgerminoma/grade 1 IT",
             "Similar approach; some adult protocols have lower threshold for adjuvant chemo"],
            ["<b>Fertility priority", "Paramount — most have not yet completed puberty or family",
             "Important but patient may have completed family"],
            ["<b>Psychosocial impact", "Body image, pubertal development, academic disruption; paediatric-specific psychological support",
             "Fertility anxiety, relationship impact; adult oncology psychosocial support"],
            ["<b>Follow-up institution", "Paediatric oncology LTFU clinic; transition to adult care at 16–18 years",
             "Adult oncology follow-up"],
        ],
        col_widths=[Cm(5.5), Cm(6), Cm(6.5)]
    )
    add_caption(doc,
        "Table 13: Key differences between paediatric and adult ovarian GCTs\n"
        "Sources: Berek & Novak's Gynecology; COG AGCT protocols; Weil et al. Semin Pediatr Surg 2023 (PMID 38039829); "
        "De Maria et al. J Gynecol Oncol 2025 (PMID 40275685)")

    # ══ 11. MDT ═══════════════════════════════════════════════════════════════
    add_heading(doc, "11. Multidisciplinary Team (MDT) Approach")
    make_table(doc,
        ["Team Member", "Role"],
        [
            ["Paediatric/Adolescent Oncologist", "Overall treatment coordination, chemotherapy prescription, clinical trial enrolment"],
            ["Paediatric/Gynaecological Surgeon", "Primary surgery, staging, fertility-preserving technique"],
            ["Specialist Histopathologist", "Accurate diagnosis, tumour grading, molecular markers, WHO classification"],
            ["Diagnostic Radiologist", "Imaging interpretation, staging, response assessment, USS-guided procedures"],
            ["Clinical Nurse Specialist", "Patient/family education, symptom management, psychological support"],
            ["Fertility Specialist / Reproductive Endocrinologist", "Pre-treatment fertility counselling and preservation planning"],
            ["Clinical Geneticist", "Karyotype evaluation, DSD assessment, familial risk counselling"],
            ["Psychologist / Child Psychiatrist", "Psychological support for child and family throughout treatment and follow-up"],
            ["Endocrinologist", "HRT management if ovarian failure; pubertal induction"],
            ["Audiologist", "Cisplatin ototoxicity monitoring — baseline and throughout treatment"],
            ["Long-Term Follow-Up (LTFU) Team", "Late effects monitoring, transition to adult care at 16–18 years"],
        ],
        col_widths=[Cm(6.5), Cm(11.5)]
    )
    add_caption(doc, "Table 14: Multidisciplinary team composition for paediatric ovarian GCT management")

    # ══ 12. EMERGING CONCEPTS ═════════════════════════════════════════════════
    add_heading(doc, "12. Emerging Concepts & Current Research (2024–2025)")
    add_heading(doc, "12.1 Controversies in Management", level=2)
    add_body(doc,
        "A 2025 review in International Journal of Gynaecological Cancer (Seckl et al., PMID 40020416) "
        "highlights ongoing controversies:"
    )
    for item in [
        "Carboplatin vs. cisplatin: Carboplatin offers equivalent efficacy with less ototoxicity/nephrotoxicity in good-risk disease, but cisplatin remains standard in high-risk/advanced stages.",
        "Bleomycin omission: COG AGCT0132 demonstrated carboplatin + etoposide (without bleomycin) may be sufficient for low-risk paediatric GCTs, avoiding pulmonary toxicity.",
        "Surveillance vs. adjuvant chemo in stage IA YST: Increasing evidence supports immediate BEP (3 cycles) rather than surveillance, given ~25% relapse risk and excellent salvage.",
        "3 vs. 4 cycles in stage III/IV: Ongoing debate balancing cure rates against cumulative toxicity.",
        "Laparoscopic staging: Concern about port-site metastases and tumour spillage; standardised protocols needed.",
        "Molecular biomarkers: Isochromosome 12p (i[12p]) characteristic of adult testicular GCTs; inconsistent in paediatric ovarian GCTs (especially prepubertal), suggesting a biologically distinct entity.",
        "Immunotherapy: PD-L1 expression in some GCTs; early trials investigating checkpoint inhibitors in refractory disease.",
    ]: add_bullet(doc, item)

    add_heading(doc, "12.2 Recurrent/Refractory Disease", level=2)
    add_body(doc,
        "Nasioudis & Pashankar (Int J Gynecol Cancer 2024, PMID 38991656) reviewed management "
        "of recurrent/persistent GCTs:"
    )
    for item in [
        "Platinum-sensitive recurrence (>4 weeks from last cisplatin): TIP regimen — response rate ~65–80%.",
        "Platinum-refractory: High-dose chemotherapy + ASCT in eligible patients.",
        "Surgical resection of residual disease after salvage chemotherapy improves outcomes.",
        "Paediatric patients with recurrence have higher salvage rates than adults.",
        "GEMOX (gemcitabine + oxaliplatin) is an option in heavily pre-treated patients.",
    ]: add_bullet(doc, item)

    # ══ 13. REFERENCES ════════════════════════════════════════════════════════
    add_heading(doc, "13. Key References")
    refs = [
        "1. Berek JS, et al. Berek & Novak's Gynecology, 16th ed. Wolters Kluwer, 2020. Chapter 39: Germ Cell Malignancies.",
        "2. Kumar V, et al. Robbins & Cotran Pathologic Basis of Disease, 10th ed. Elsevier, 2021. Chapter 22: Female Genital System.",
        "3. Harrison's Principles of Internal Medicine, 22nd ed. McGraw-Hill, 2025. Uncommon Ovarian Tumours.",
        "4. Weil BR, Rich BS, Madenci AL. Critical elements in the operative management of pediatric malignant ovarian germ cell tumors. Semin Pediatr Surg. 2023 Oct. PMID: 38039829.",
        "5. Nasioudis D, Pashankar FD. Management of recurrent and persistent malignant ovarian germ cell tumors: a narrative review. Int J Gynecol Cancer. 2024 Sep. PMID: 38991656.",
        "6. Seckl MJ, Kaur B, Ghorani E. Controversies in malignant ovarian germ cell tumors. Int J Gynecol Cancer. 2025 Mar. PMID: 40020416.",
        "7. De Maria F, Amant F, Chiappa V, et al. Malignant germ cell tumor of the ovary. J Gynecol Oncol. 2025 May. PMID: 40275685.",
        "8. Zerdeva E, et al. Fertility preservation in rare ovarian malignancies: decade-spanning systematic review. Cancer Causes Control. 2025. PMID: 41068325.",
        "9. Children's Oncology Group (COG). AGCT0132 Protocol: Carboplatin and Etoposide for Paediatric GCTs.",
        "10. WHO Classification of Tumours of Female Reproductive Organs, 5th ed. IARC, 2020.",
    ]
    for ref in refs:
        p = doc.add_paragraph()
        p.paragraph_format.space_before = Pt(1)
        p.paragraph_format.space_after  = Pt(2)
        r = p.add_run(ref)
        r.font.size = Pt(8.5)
        r.font.name = 'Calibri'
        r.font.color.rgb = RGBColor(0x33,0x33,0x33)
        r.font.italic = True

    doc.save(OUTPUT)
    print(f"Word document saved: {OUTPUT}")

if __name__ == "__main__":
    build()
Running Command

cd /home/daytona/workspace/paediatric-gct && python3 generate_docx.py 2>&1

Running Command

cd /home/daytona/workspace/paediatric-gct && python3 -c " import sys sys.path.insert(0, '.') # Patch output path to /tmp first import generate_docx as gd gd.OUTPUT = '/tmp/Paediatric_Ovarian_GCT.docx' gd.build() " 2>&1

Running Command

cp /tmp/Paediatric_Ovarian_GCT.docx /home/daytona/workspace/Paediatric_Ovarian_GCT.docx && ls -lh /home/daytona/workspace/Paediatric_Ovarian_GCT.docx && python3 -c " from docx import Document doc = Document('/home/daytona/workspace/Paediatric_Ovarian_GCT.docx') print(f'Paragraphs: {len(doc.paragraphs)}, Tables: {len(doc.tables)} — Valid DOCX') "

The Word document is ready — 187 paragraphs, 32 tables, fully valid:

Paediatric Ovarian GCT

Word Document · DOCX


The document contains all 13 sections with full formatting:
SectionIncludes
1. EpidemiologyComparison table paediatric vs adult
2. WHO Classification & TypesClassification table + detailed entries for all 7 tumour types; Norris grading table for immature teratoma
3. Clinical PresentationSymptoms table; tumour markers table with age-adjusted AFP warning box; imaging table
4. FIGO 2014 StagingFull staging table (IA through IV)
5. Surgical ManagementPrinciples; stage-by-stage surgical table; special considerations; flowchart
6. ChemotherapyBEP regimen table; cycles-by-stage table; toxicity table; alternatives table; flowchart
7. Fertility & HormonesOutcomes data; HRT guidance
8. SurveillanceProtocol table; growing teratoma syndrome
9. PrognosisSurvival table by type and stage
10. Paediatric vs Adult16-row detailed comparison table
11. MDTTeam roles table
12. Emerging Concepts2024–2025 controversies; recurrence management
13. References10 key references with PMIDs
This is a shared conversation. Sign in to Orris to start your own chat.