Thyroid eye disease

Reading File
Finding Sources
Finding Sources
Searching PubMed

"thyroid eye disease" OR "Graves ophthalmopathy"

Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Loading Image
Reading File
Loading Image
I now have comprehensive information to write a complete, well-structured answer. Let me compile it.

Thyroid Eye Disease (TED)

Also known as: Thyroid-Associated Orbitopathy (TAO), Graves' Ophthalmopathy
Bilateral eyelid retraction and proptosis in thyroid-related orbitopathy
Bilateral eyelid retraction with prominent proptosis - classic TED appearance (Wills Eye Manual)

Definition & Epidemiology

TED is the most common cause of both bilateral and unilateral proptosis in adults. It is predominantly associated with Graves' disease but can also occur in euthyroid (5-10%) and hypothyroid/treated-hypothyroid patients. Women are 5x more likely to be affected, largely reflecting the higher incidence of Graves' disease in women. Approximately 50% of patients with thyroid disease will develop orbital manifestations; serious long-term ocular problems occur in only ~10%.
  • Kanski's Clinical Ophthalmology, 10e, p.132

Pathogenesis

TED is an organ-specific autoimmune disorder. The key steps:
  1. Autoantibody-driven activation: Anti-TSH-receptor (TSHR) antibodies react against both thyroid gland cells and orbital fibroblasts. IGF-1 receptor (IGF-1R) and TSHR are upregulated in orbital and brow fat.
  2. Orbital infiltration: T lymphocytes and macrophages infiltrate the orbital tissue.
  3. Glycosaminoglycan (GAG) deposition: Increased GAG secretion leads to osmotic fluid imbibition - muscles can swell to 8x normal size.
  4. Lipogenesis: Fibroblast/preadipocyte-driven orbital fat enlargement.
  5. Raised intraorbital pressure: From the increased volume in the fixed bony orbit, impairing venous drainage → chemosis and periorbital edema.
  6. Fibrosis: Eventual muscle fibre degeneration leads to fibrosis, producing restrictive myopathy.
  • Scott-Brown's Otorhinolaryngology, Vol. 1, p.1295; Kanski's, p.133

Risk Factors

FactorDetails
SmokingSingle most important modifiable risk; dose-dependent effect; cessation reduces risk
Radioactive iodine (RAI) therapyCan worsen pre-existing TED; protect with oral steroids if RAI is given
Female sex5x more common
Vitamin D deficiencyIncreases risk of progressive orbitopathy

Disease Phases

TED has two distinct phases:
  1. Inflammatory (congestive) phase - lasts 6 months to 3 years; active inflammation, fibrosis, and adipogenesis produce changing findings; eyes are red and painful
  2. Burnt-out (fibrotic/quiescent) phase - eyes are white; ocular findings stable for ≥6 months; painless motility defects may persist

Clinical Features

1. Soft Tissue Involvement

  • Grittiness, redness, lacrimation, photophobia, puffy lids, retrobulbar discomfort
  • Epibulbar hyperaemia (focal hyperaemia outlining horizontal recti insertions - sensitive activity sign)
  • Periorbital swelling, chemosis
  • Tear insufficiency, superior limbic keratoconjunctivitis, punctate epithelial erosions

2. Eyelid Retraction (in ~50% of Graves' patients)

  • Von Graefe sign: eyelid lag on downward gaze (pathognomonic)
  • Lateral flare of upper eyelids (highly specific)
  • Mechanisms: sympathetic overstimulation of Müller's muscle + fibrotic contracture of levator palpebrae
  • Lagophthalmos → exposure keratopathy

3. Proptosis (Exophthalmos)

  • Unilateral or bilateral axial proptosis
  • Resistance to retropulsion
  • Bacterial keratitis may occur in severe cases from exposure
  • Two variants on CT:
    • Myogenic: thickened EOMs, apical crowding, minimal proptosis
    • Lipogenic: increased orbital fat, minimal muscle involvement, severe proptosis

4. Restrictive Myopathy

Extraocular muscle involvement in order of frequency: inferior > medial > superior > lateral rectus (mnemonic: "I'M SLow"). Tendon sparing is characteristic.
  • Elevation defect (fibrosis of inferior rectus) - most common; mimics superior rectus palsy
  • Abduction defect (medial rectus fibrosis) - mimics 6th nerve palsy
  • Depression defect (superior rectus fibrosis)
  • Diplopia, resistance on forced duction testing

5. Compressive Optic Neuropathy (5-7% of TED patients)

The most serious complication - must be ruled out at every visit.
Compression occurs from enlargement of EOMs at the orbital apex, often WITHOUT significant proptosis.
Signs of optic neuropathy:
  • Reduced visual acuity
  • Colour desaturation (sensitive early sign)
  • Relative afferent pupillary defect (RAPD) - cause for marked concern
  • Visual field defects (central, paracentral, nerve fibre bundle)
  • Reduced light brightness appreciation
  • Disc swelling or, rarely, atrophy
  • Kanski's, p.135-136; Wills Eye Manual, p.424-425

EUGOGO Classification (2021)

Activity Score (Clinical Activity Score - CAS)

One point each for:
  1. Spontaneous retrobulbar pain
  2. Pain on attempted gaze (up or down)
  3. Redness of eyelids
  4. Redness of conjunctiva
  5. Chemosis
  6. Swelling of conjunctiva/plica
  7. Swelling of eyelids
Score ≥3/7 = active disease warranting immunosuppression. Follow-up adds points for: proptosis increase ≥2 mm, uniocular excursion decrease ≥8°, Snellen acuity decrease ≥1 line (total 10 points).

Severity Classification

GradeDescription
MildMinor impact on daily life
Moderate-severeSoft tissue involvement (moderate-severe), lid retraction ≥2 mm, diplopia, and/or proptosis ≥3 mm above normal
Sight-threateningOptic neuropathy or corneal breakdown

Workup / Investigations

  1. Thyroid function tests - TSH, free T3/T4; also TSI (thyroid-stimulating immunoglobulin) and TPO antibodies
  2. Serum vitamin D
  3. CT orbit (axial + coronal, without contrast) - preferred imaging; identifies muscle belly enlargement with tendon sparing; assesses apical crowding and optic nerve compression; MRI also used
  4. Visual field testing - if optic nerve compromise suspected
  5. Visual evoked potentials - in optic neuropathy
  6. Forced duction testing - distinguishes restrictive from paretic strabismus
  7. Screen for myasthenia gravis if diplopia with fluctuation or ptosis (not retraction)
CT scan showing muscle enlargement in TED: (A) axial view with fusiform medial rectus enlargement; (B) coronal view showing symmetric involvement of multiple muscles
CT orbit in TED showing fusiform enlargement of extraocular muscle bellies with tendon sparing - (A) axial; (B) coronal (Kanski's 10e)

Management

All Patients

  • Smoking cessation - first and most important intervention in every patient
  • Thyroid function control - refer to endocrinologist; euthyroid TED patients need TFTs every 6-12 months
  • If RAI is given - cover with oral steroids to prevent TED exacerbation

Mild Active Disease

  • Artificial tears / lubricating eye drops
  • Eyelid taping at night for exposure keratopathy
  • Head elevation at night (3 pillows) to reduce periorbital oedema
  • Selenium (sodium selenite 200 µg/day x 6 months) in selenium-deficient regions - reduces severity/progression of mild-moderate TED
  • Vitamin D supplementation if deficient

Moderate-Severe Active Disease (CAS ≥3)

Anti-inflammatory/immunosuppressives are most effective within 18 months of onset:
AgentRegimen
IV methylprednisolone (first-line)0.5 g weekly x 6 weeks, then 0.25 g weekly x 6 weeks (max cumulative dose <8 g to protect liver)
IV methylprednisolone + mycophenolate sodiumSuperior to IV steroids alone; 0.72 g/day x 24 weeks - regimen of choice in specialist centres
Oral prednisolone60-80 mg/day, tapered; inferior tolerability to IV route
Orbital radiotherapySecond-line; 20 Gy in 10-14 fractions; 40% non-responders; avoid in diabetics (retinopathy risk); maximal effect at 4 months
Combined (RT + azathioprine + low-dose prednisolone)More effective than monotherapy in some settings
Contraindications to IV steroids: significant hepatic dysfunction, uncontrolled HTN, DM, significant cardiovascular disease.

Compressive Optic Neuropathy (Emergency)

  • Pulsed IV methylprednisolone 0.5-1 g for 3 consecutive days (or on alternate days x3-6), then oral prednisolone 40 mg/day
  • If steroids fail or are contraindicated (20%): orbital decompression surgery (posterior/medial wall - NOT anterior, which is ineffective for optic neuropathy)
  • Orbital radiotherapy as adjunct only (too slow for acute vision loss)

Targeted Biologic Therapy

DrugTargetStatus
TeprotumumabIGF-1R inhibitor (monoclonal Ab)FDA-approved January 2020; effective for proptosis, diplopia, and optic neuropathy in moderate-severe TED
RituximabAnti-CD20 (B cell depletion)Off-label; some evidence
TocilizumabIL-6 receptor antagonistOff-label; growing evidence
Recent meta-analyses (2025) comparing rituximab, tocilizumab, and teprotumumab confirm all three are effective in Graves' orbitopathy, with teprotumumab showing strong proptosis reduction (PMID: 40404973, PMID: 39952471).

Surgical Management (Stepwise - only after inflammatory phase)

Surgical sequence must be followed to avoid unpredictable outcomes:
  1. Orbital decompression (if needed) - indications: compressive optic neuropathy, severe exposure keratopathy, globe luxation, uncontrollably high IOP, morbid proptosis
  2. Strabismus surgery (if significant diplopia)
  3. Eyelid surgery (for retraction/exposure)
Endoscopic medial wall decompression (ENT approach) is increasingly used, alone or with open approaches for the orbital floor and lateral wall when greater decompression is needed.

Differential Diagnosis of Upper Eyelid Retraction

  • Prior eyelid surgery/trauma
  • Contralateral severe ptosis (Hering's law)
  • CN III palsy with aberrant regeneration (pseudo-von Graefe sign)
  • Parinaud syndrome (dorsal midbrain - eyelid retraction + upgaze palsy)

Differential Diagnosis of EOM Enlargement

  • Orbital myositis (tendons involved; unlike TED)
  • Lymphoma, metastasis
  • Carotid-cavernous fistula (pulsating proptosis, bruit)

Key Associations / Pitfalls

  • TED can precede, coincide with, or follow thyroid dysfunction by months to years - thyroid status at presentation does not exclude TED
  • Optic nerve compression often occurs without significant proptosis ("tight orbit" / apical crowding in myogenic variant)
  • Concomitant myasthenia gravis must be considered in TED patients with fluctuating diplopia or ptosis (rather than retraction)
  • Isolated lateral rectus enlargement is atypical for TED and requires biopsy/further workup

Sources: Kanski's Clinical Ophthalmology 10e, pp.132-138; The Wills Eye Manual, pp.423-431; Scott-Brown's Otorhinolaryngology Vol.1, pp.1294-1296; recent systematic reviews PMID 40404973, PMID 39952471 (2025)

Make a ppt on thyroid eye disease consisting of 25 to 30 slides

Reading File
Reading File
Reading File
Running Command

mkdir -p /home/daytona/workspace/ted-ppt && ls /home/daytona/workspace/ted-ppt/

Running Command

node /home/daytona/skills/shared/scripts/fetch_images.js \ "https://cdn.orris.care/cdss_images/e24d90d63909615a51f1045fd4bf5ff7f4b13ac9ffff9fc78694e6ee69b66ded.png" \ "https://cdn.orris.care/cdss_images/cc4759dd86206657a591a466a7aba91babe3b2fb40cbd70d2b9773f792645587.png" \ "https://cdn.orris.care/cdss_images/ecb379b38d8a7e399f46854c2a04031b26948eb6ca268008cb787309e27a4031.png" \ "https://cdn.orris.care/cdss_images/8abf13c5a940a0a114de480d9cea3886fb6ad81b96e5c11aa4181aa4da0d80e7.png" \ "https://cdn.orris.care/cdss_images/7a1e9a2052317aa918d444bd2e2230470e6853e8bc7dd8a4b9bf96b60aba4031.png" \ 2>/dev/null | node -e "const d=require('fs');let raw='';process.stdin.on('data',c=>raw+=c);process.stdin.on('end',()=>{try{const arr=JSON.parse(raw);arr.forEach((img,i)=>{if(img.base64&&!img.error){const b64=img.base64.split(',')[1]||img.base64;d.writeFileSync('/home/daytona/workspace/ted-ppt/img'+i+'.b64',img.base64);}});console.log('Done',arr.map(x=>x.error||'ok'));}catch(e){console.error(e.message,raw.slice(0,200));}});"

Running Command

node /home/daytona/skills/shared/scripts/fetch_images.js "https://cdn.orris.care/cdss_images/e24d90d63909615a51f1045fd4bf5ff7f4b13ac9ffff9fc78694e6ee69b66ded.png" > /home/daytona/workspace/ted-ppt/img0.json 2>&1 & echo "Fetching image 0 in background PID $!"

Make a ppt on thyroid eye disease consisting of 25 to 30 slides

Reading File
Reading File
Running Command

mkdir -p /home/daytona/workspace/ted-ppt && echo "ready"

Writing File

~/ted-ppt/ted.js

const pptxgen = require("pptxgenjs");
const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title = "Thyroid Eye Disease";
pres.author = "Orris Medical";

// ─── COLOUR PALETTE ────────────────────────────────────────────────────────
const C = {
  navy:    "0B2D5E",   // dominant dark
  teal:    "0A7E8C",   // accent 1
  amber:   "E8A020",   // accent 2 / warning
  red:     "C0392B",   // danger
  white:   "FFFFFF",
  offwhite:"F4F7FA",
  light:   "D6E8EC",
  mid:     "4A8FA3",
  darkgray:"2C3E50",
  gray:    "6B7C93",
  silver:  "BDC8D4",
};

// ─── HELPERS ──────────────────────────────────────────────────────────────

function addBg(slide, color) {
  slide.background = { color };
}

function sectionBar(slide, text) {
  slide.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 0.52, fill: { color: C.navy }, line: { color: C.navy } });
  slide.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0.52, w: 10, h: 0.06, fill: { color: C.teal }, line: { color: C.teal } });
  slide.addText(text, { x: 0.35, y: 0, w: 9.3, h: 0.52, fontSize: 18, bold: true, color: C.white, valign: "middle", margin: 0 });
}

function contentSlide(title, bullets, opts = {}) {
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, title);

  // accent strip left
  slide.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0.58, w: 0.08, h: 4.8, fill: { color: C.teal }, line: { color: C.teal } });

  const items = bullets.map((b, i) => {
    if (typeof b === "string") {
      return { text: b, options: { bullet: { type: "bullet", characterCode: "25B8", color: C.teal }, color: C.darkgray, fontSize: opts.fontSize || 16, breakLine: i < bullets.length - 1 } };
    }
    // sub-item: { text, sub: true }
    return { text: b.text, options: { bullet: { type: "bullet", characterCode: "25B8", color: C.amber, indent: 20 }, color: C.gray, fontSize: (opts.fontSize || 16) - 2, italic: !!b.italic, breakLine: i < bullets.length - 1 } };
  });

  slide.addText(items, { x: 0.3, y: 0.7, w: 9.4, h: 4.7, valign: "top", fontFace: "Calibri" });

  // slide number bottom right
  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.3, w: 10, h: 0.32, fontSize: 9, color: C.silver, align: "right", italic: true });
  return slide;
}

function twoColSlide(title, col1Title, col1Items, col2Title, col2Items) {
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, title);

  // col 1 header
  slide.addShape(pres.shapes.RECTANGLE, { x: 0.2, y: 0.68, w: 4.6, h: 0.38, fill: { color: C.teal }, line: { color: C.teal }, rectRadius: 0.05 });
  slide.addText(col1Title, { x: 0.2, y: 0.68, w: 4.6, h: 0.38, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });

  // col 2 header
  slide.addShape(pres.shapes.RECTANGLE, { x: 5.2, y: 0.68, w: 4.6, h: 0.38, fill: { color: C.navy }, line: { color: C.navy }, rectRadius: 0.05 });
  slide.addText(col2Title, { x: 5.2, y: 0.68, w: 4.6, h: 0.38, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });

  const makeItems = (arr) => arr.map((b, i) => ({
    text: b, options: { bullet: { type: "bullet", characterCode: "25B8", color: C.teal }, color: C.darkgray, fontSize: 14, breakLine: i < arr.length - 1 }
  }));

  slide.addText(makeItems(col1Items), { x: 0.22, y: 1.14, w: 4.56, h: 4.2, valign: "top", fontFace: "Calibri" });
  slide.addText(makeItems(col2Items), { x: 5.22, y: 1.14, w: 4.56, h: 4.2, valign: "top", fontFace: "Calibri" });

  // divider
  slide.addShape(pres.shapes.LINE, { x: 4.95, y: 0.65, w: 0, h: 4.7, line: { color: C.silver, width: 1, dashType: "dash" } });
  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.3, w: 10, h: 0.32, fontSize: 9, color: C.silver, align: "right", italic: true });
  return slide;
}

function tableSlide(title, headers, rows) {
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, title);

  const colW = 9.6 / headers.length;
  const tableRows = [
    headers.map(h => ({ text: h, options: { bold: true, color: C.white, fontSize: 13, fill: { color: C.navy }, align: "center" } })),
    ...rows.map((row, ri) => row.map(cell => ({
      text: cell,
      options: { fontSize: 12, color: C.darkgray, fill: { color: ri % 2 === 0 ? C.offwhite : C.light }, valign: "middle" }
    })))
  ];

  slide.addTable(tableRows, { x: 0.2, y: 0.7, w: 9.6, colW: headers.map(() => colW), rowH: 0.52, border: { type: "solid", color: C.silver, pt: 0.5 }, fontFace: "Calibri" });
  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.3, w: 10, h: 0.32, fontSize: 9, color: C.silver, align: "right", italic: true });
  return slide;
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 1 — TITLE
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  // Dark bg
  slide.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.navy }, line: { color: C.navy } });
  // Teal accent band
  slide.addShape(pres.shapes.RECTANGLE, { x: 0, y: 3.7, w: 10, h: 0.14, fill: { color: C.teal }, line: { color: C.teal } });
  // Amber accent strip
  slide.addShape(pres.shapes.RECTANGLE, { x: 0, y: 3.84, w: 4.2, h: 0.07, fill: { color: C.amber }, line: { color: C.amber } });

  // eye icon circle
  slide.addShape(pres.shapes.OVAL, { x: 7.5, y: 0.6, w: 2.1, h: 2.1, fill: { color: C.teal }, line: { color: C.white, width: 3 } });
  slide.addShape(pres.shapes.OVAL, { x: 7.88, y: 0.98, w: 1.32, h: 1.32, fill: { color: C.white }, line: { color: C.white } });
  slide.addShape(pres.shapes.OVAL, { x: 8.12, y: 1.22, w: 0.84, h: 0.84, fill: { color: C.navy }, line: { color: C.navy } });
  slide.addShape(pres.shapes.OVAL, { x: 8.24, y: 1.32, w: 0.24, h: 0.24, fill: { color: C.white }, line: { color: C.white } });

  slide.addText("THYROID EYE DISEASE", { x: 0.5, y: 0.8, w: 6.8, h: 1.1, fontSize: 38, bold: true, color: C.white, fontFace: "Calibri", charSpacing: 2 });
  slide.addText("(Graves' Ophthalmopathy / Thyroid-Associated Orbitopathy)", { x: 0.5, y: 1.85, w: 6.8, h: 0.6, fontSize: 14, color: C.light, fontFace: "Calibri", italic: true });
  slide.addText("A Comprehensive Clinical Review", { x: 0.5, y: 2.55, w: 6.8, h: 0.45, fontSize: 16, color: C.amber, fontFace: "Calibri", bold: true });

  slide.addText([
    { text: "Epidemiology  •  Pathogenesis  •  Classification  •  Diagnosis  •  Management", options: { color: C.silver, fontSize: 11 } }
  ], { x: 0.5, y: 3.95, w: 9, h: 0.4, fontFace: "Calibri" });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 2 — TABLE OF CONTENTS
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, "Table of Contents");

  const sections = [
    ["01", "Definition & Epidemiology"],
    ["02", "Pathophysiology"],
    ["03", "Risk Factors"],
    ["04", "Disease Phases"],
    ["05", "Clinical Features — Overview"],
    ["06", "Soft Tissue Involvement"],
    ["07", "Eyelid Changes"],
    ["08", "Proptosis"],
    ["09", "Restrictive Myopathy"],
    ["10", "Compressive Optic Neuropathy"],
  ];
  const sections2 = [
    ["11", "EUGOGO Classification"],
    ["12", "Clinical Activity Score (CAS)"],
    ["13", "Differential Diagnosis"],
    ["14", "Investigations"],
    ["15", "CT & MRI Findings"],
    ["16", "Management Overview"],
    ["17", "Mild Disease Treatment"],
    ["18", "Moderate–Severe Treatment"],
    ["19", "Sight-Threatening Treatment"],
    ["20", "Biologic Therapies & Surgery"],
  ];

  const makeCol = (arr, xOff) => arr.forEach(([num, label], i) => {
    const y = 0.72 + i * 0.46;
    slide.addShape(pres.shapes.RECTANGLE, { x: xOff, y, w: 0.42, h: 0.34, fill: { color: C.teal }, line: { color: C.teal } });
    slide.addText(num, { x: xOff, y, w: 0.42, h: 0.34, fontSize: 10, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText(label, { x: xOff + 0.5, y: y + 0.02, w: 4.1, h: 0.3, fontSize: 13, color: C.darkgray, valign: "middle", fontFace: "Calibri" });
  });

  makeCol(sections, 0.2);
  makeCol(sections2, 5.1);
  slide.addShape(pres.shapes.LINE, { x: 4.95, y: 0.65, w: 0, h: 4.7, line: { color: C.silver, width: 1, dashType: "dash" } });
  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.3, w: 10, h: 0.32, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 3 — DEFINITION & EPIDEMIOLOGY
// ═══════════════════════════════════════════════════════════════════
contentSlide("Definition & Epidemiology", [
  "Thyroid Eye Disease (TED) is an autoimmune orbital disorder associated with thyroid dysfunction",
  "Also known as: Graves' Ophthalmopathy, Thyroid-Associated Orbitopathy (TAO)",
  "Most common cause of both bilateral AND unilateral proptosis in adults",
  "Affects ~50% of patients with Graves' disease to some degree",
  "Women 5x more commonly affected than men",
  "Peak incidence: 4th–5th decades; bimodal distribution (40–44 & 60–64 years)",
  "Severe/sight-threatening disease: only ~3–5% of TED patients",
  "TED does NOT always follow thyroid dysfunction — may precede or follow by months to years",
  "Can occur in euthyroid (5–10%) and hypothyroid (5–10%) patients",
]);

// ═══════════════════════════════════════════════════════════════════
// SLIDE 4 — PATHOGENESIS (diagram-style)
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, "Pathogenesis");

  // Draw pathway boxes
  const steps = [
    { x: 0.15, y: 0.75, label: "Anti-TSHR\nAutoantibodies\n(IgG)", col: C.red },
    { x: 2.45, y: 0.75, label: "TSH-R & IGF-1R\nUpregulation\nin Orbital Fibroblasts", col: C.amber },
    { x: 4.95, y: 0.75, label: "T-lymphocyte &\nMacrophage\nInfiltration", col: C.teal },
    { x: 7.35, y: 0.75, label: "GAG Deposition\n+ Osmotic\nFluid Imbibition", col: C.navy },
  ];

  steps.forEach(s => {
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, { x: s.x, y: s.y, w: 2.1, h: 1.1, fill: { color: s.col }, line: { color: s.col }, rectRadius: 0.1 });
    slide.addText(s.label, { x: s.x, y: s.y, w: 2.1, h: 1.1, fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 4, fontFace: "Calibri" });
    // arrow
    if (s.x < 7.35) {
      slide.addShape(pres.shapes.LINE, { x: s.x + 2.1, y: s.y + 0.55, w: 0.35, h: 0, line: { color: C.gray, width: 2 } });
    }
  });

  // Second row of consequences
  const cons = [
    { x: 0.15, y: 2.25, label: "Muscle Belly\nEnlargement\n(up to 8x)", col: C.navy },
    { x: 2.45, y: 2.25, label: "Orbital Fat\nEnlargement\n(Lipogenesis)", col: C.teal },
    { x: 4.95, y: 2.25, label: "Raised\nIntraorbital\nPressure", col: C.amber },
    { x: 7.35, y: 2.25, label: "Fibrosis &\nRestrictive\nMyopathy", col: C.red },
  ];

  cons.forEach(s => {
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, { x: s.x, y: s.y, w: 2.1, h: 1.05, fill: { color: s.col }, line: { color: s.col }, rectRadius: 0.1 });
    slide.addText(s.label, { x: s.x, y: s.y, w: 2.1, h: 1.05, fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 4, fontFace: "Calibri" });
  });

  // vertical arrows
  [0.15, 2.45, 4.95, 7.35].forEach(x => {
    slide.addShape(pres.shapes.LINE, { x: x + 1.05, y: 1.85, w: 0, h: 0.4, line: { color: C.gray, width: 2 } });
  });

  // outcomes
  const outcomes = [
    { x: 0.7, y: 3.62, label: "PROPTOSIS", col: C.teal },
    { x: 3.2, y: 3.62, label: "DIPLOPIA", col: C.teal },
    { x: 5.7, y: 3.62, label: "EXPOSURE\nKERATOPATHY", col: C.amber },
    { x: 7.8, y: 3.62, label: "COMPRESSIVE\nOPTIC NEUROPATHY", col: C.red },
  ];
  outcomes.forEach(o => {
    slide.addShape(pres.shapes.RECTANGLE, { x: o.x, y: o.y, w: 2.0, h: 0.72, fill: { color: o.col }, line: { color: o.col } });
    slide.addText(o.label, { x: o.x, y: o.y, w: 2.0, h: 0.72, fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 2, fontFace: "Calibri" });
  });

  slide.addText("TSHR = TSH Receptor   •   IGF-1R = Insulin-like Growth Factor-1 Receptor   •   GAG = Glycosaminoglycans",
    { x: 0.2, y: 5.06, w: 9.6, h: 0.28, fontSize: 9, color: C.gray, italic: true, align: "center", fontFace: "Calibri" });
  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 5 — RISK FACTORS
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, "Risk Factors");

  const cards = [
    { x: 0.2,  y: 0.72, title: "SMOKING", body: "Single most important modifiable risk factor\nDose-dependent relationship\nCessation reduces risk of progression", col: C.red },
    { x: 3.45, y: 0.72, title: "RADIOACTIVE IODINE", body: "Can trigger or worsen pre-existing TED\nProtect with oral steroids if RAI given\nPreferred thyroid Rx: antithyroid drugs", col: C.amber },
    { x: 6.7,  y: 0.72, title: "FEMALE SEX", body: "5× more commonly affected\nReflects higher Graves' disease incidence\nMen tend to have more severe disease", col: C.teal },
    { x: 0.2,  y: 2.8,  title: "THYROID DYSFUNCTION", body: "Hyperthyroid (80%+), euthyroid (5–10%),\nhypothyroid (5–10%)\nTED activity ≠ thyroid hormone level", col: C.navy },
    { x: 3.45, y: 2.8,  title: "VITAMIN D DEFICIENCY", body: "Subnormal vitamin D → increased risk of\nprogressive orbitopathy\nSupplement if deficient", col: C.mid },
    { x: 6.7,  y: 2.8,  title: "GENETIC FACTORS", body: "Family history of thyroid dysfunction\nHLA-DR3, HLA-B8 associations\nOther autoimmune disorders co-exist", col: C.gray },
  ];

  cards.forEach(c => {
    slide.addShape(pres.shapes.RECTANGLE, { x: c.x, y: c.y, w: 3.1, h: 0.42, fill: { color: c.col }, line: { color: c.col } });
    slide.addText(c.title, { x: c.x, y: c.y, w: 3.1, h: 0.42, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0, fontFace: "Calibri" });
    slide.addShape(pres.shapes.RECTANGLE, { x: c.x, y: c.y + 0.42, w: 3.1, h: 1.68, fill: { color: C.white }, line: { color: c.col, width: 1.5 }, shadow: { type: "outer", color: "000000", blur: 4, offset: 2, angle: 135, opacity: 0.1 } });
    slide.addText(c.body, { x: c.x + 0.1, y: c.y + 0.48, w: 2.9, h: 1.56, fontSize: 11.5, color: C.darkgray, valign: "top", fontFace: "Calibri" });
  });

  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 6 — DISEASE PHASES
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, "Disease Phases — The Rundle's Curve");

  // Timeline bar
  slide.addShape(pres.shapes.RECTANGLE, { x: 0.4, y: 2.6, w: 9.2, h: 0.22, fill: { color: C.silver }, line: { color: C.silver } });

  // Phase 1
  slide.addShape(pres.shapes.RECTANGLE, { x: 0.4, y: 2.6, w: 4.2, h: 0.22, fill: { color: C.red }, line: { color: C.red } });
  slide.addShape(pres.shapes.RECTANGLE, { x: 0.4, y: 0.72, w: 4.2, h: 1.72, fill: { color: C.white }, line: { color: C.red, width: 2 }, shadow: { type: "outer", color: "000000", blur: 5, offset: 2, angle: 135, opacity: 0.12 } });
  slide.addShape(pres.shapes.RECTANGLE, { x: 0.4, y: 0.72, w: 4.2, h: 0.4, fill: { color: C.red }, line: { color: C.red } });
  slide.addText("Phase 1: INFLAMMATORY (Active)", { x: 0.4, y: 0.72, w: 4.2, h: 0.4, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle", margin: 0, fontFace: "Calibri" });
  slide.addText([
    { text: "Duration: ", options: { bold: true } }, { text: "6 months – 3 years\n" },
    { text: "Features: ", options: { bold: true } }, { text: "Red, painful eyes\n" },
    { text: "Processes: ", options: { bold: true } }, { text: "Inflammation, fibrosis, adipogenesis\n" },
    { text: "Responds to: ", options: { bold: true } }, { text: "Immunosuppression" },
  ], { x: 0.5, y: 1.16, w: 4.0, h: 1.24, fontSize: 12, color: C.darkgray, valign: "top", fontFace: "Calibri" });

  // Phase 2
  slide.addShape(pres.shapes.RECTANGLE, { x: 5.4, y: 2.6, w: 4.2, h: 0.22, fill: { color: C.teal }, line: { color: C.teal } });
  slide.addShape(pres.shapes.RECTANGLE, { x: 5.4, y: 0.72, w: 4.2, h: 1.72, fill: { color: C.white }, line: { color: C.teal, width: 2 }, shadow: { type: "outer", color: "000000", blur: 5, offset: 2, angle: 135, opacity: 0.12 } });
  slide.addShape(pres.shapes.RECTANGLE, { x: 5.4, y: 0.72, w: 4.2, h: 0.4, fill: { color: C.teal }, line: { color: C.teal } });
  slide.addText("Phase 2: FIBROTIC (Quiescent)", { x: 5.4, y: 0.72, w: 4.2, h: 0.4, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle", margin: 0, fontFace: "Calibri" });
  slide.addText([
    { text: "Criteria: ", options: { bold: true } }, { text: "No progression for ≥ 6 months\n" },
    { text: "Features: ", options: { bold: true } }, { text: "White, painless eyes\n" },
    { text: "Residual: ", options: { bold: true } }, { text: "Motility defect, proptosis may persist\n" },
    { text: "Intervention: ", options: { bold: true } }, { text: "Surgical rehabilitation" },
  ], { x: 5.5, y: 1.16, w: 4.0, h: 1.24, fontSize: 12, color: C.darkgray, valign: "top", fontFace: "Calibri" });

  // Labels under timeline
  slide.addText("ACTIVE  →", { x: 0.4, y: 2.88, w: 4.2, h: 0.3, fontSize: 11, color: C.red, bold: true, fontFace: "Calibri" });
  slide.addText("→  INACTIVE", { x: 5.4, y: 2.88, w: 4.2, h: 0.3, fontSize: 11, color: C.teal, bold: true, align: "right", fontFace: "Calibri" });

  // Key message
  slide.addShape(pres.shapes.RECTANGLE, { x: 0.4, y: 3.28, w: 9.2, h: 0.72, fill: { color: C.light }, line: { color: C.teal, width: 1 } });
  slide.addText("⚠  Anti-inflammatory therapy is most effective within the first 18 months of disease — early referral is essential", {
    x: 0.5, y: 3.28, w: 9.0, h: 0.72, fontSize: 13, color: C.navy, bold: true, valign: "middle", fontFace: "Calibri"
  });

  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 7 — CLINICAL FEATURES OVERVIEW
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, "Clinical Features — Overview");

  const cats = [
    { x: 0.2,  y: 0.72, label: "1. SOFT TISSUE\nINVOLVEMENT", col: C.teal, items: ["Redness, grittiness\n", "Chemosis\n", "Periorbital swelling\n", "Epibulbar hyperaemia"] },
    { x: 2.55, y: 0.72, label: "2. EYELID\nCHANGES",        col: C.amber, items: ["Upper lid retraction\n", "Von Graefe sign\n", "Lagophthalmos\n", "Lateral flare"] },
    { x: 4.9,  y: 0.72, label: "3. PROPTOSIS",               col: C.navy, items: ["Axial exophthalmos\n", "Bilateral or unilateral\n", "Exposure keratopathy\n", "Globe luxation (severe)"] },
    { x: 7.25, y: 0.72, label: "4. RESTRICTIVE\nMYOPATHY",   col: C.mid, items: ["Elevation defect (IR)\n", "Abduction defect (MR)\n", "Depression defect (SR)\n", "Diplopia"] },
  ];

  cats.forEach(c => {
    slide.addShape(pres.shapes.RECTANGLE, { x: c.x, y: c.y, w: 2.2, h: 0.7, fill: { color: c.col }, line: { color: c.col } });
    slide.addText(c.label, { x: c.x, y: c.y, w: 2.2, h: 0.7, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 2, fontFace: "Calibri" });

    const items = c.items.map((t, i) => ({
      text: t, options: { bullet: { type: "bullet", characterCode: "25B8", color: c.col }, fontSize: 12, color: C.darkgray, breakLine: i < c.items.length - 1 }
    }));
    slide.addText(items, { x: c.x, y: c.y + 0.72, w: 2.2, h: 2.2, valign: "top", fontFace: "Calibri" });
  });

  // Fifth feature — optic neuropathy highlighted
  slide.addShape(pres.shapes.RECTANGLE, { x: 0.6, y: 3.42, w: 8.8, h: 0.42, fill: { color: C.red }, line: { color: C.red } });
  slide.addText("5. COMPRESSIVE OPTIC NEUROPATHY  —  Occurs in ~5–7% of TED patients  •  Can occur WITHOUT significant proptosis  •  EMERGENCY", {
    x: 0.6, y: 3.42, w: 8.8, h: 0.42, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 2, fontFace: "Calibri"
  });

  const conFeatures = [
    { text: "Reduced visual acuity", options: { bullet: { type: "bullet", characterCode: "25B8", color: C.red }, fontSize: 12, color: C.darkgray, breakLine: true } },
    { text: "Colour desaturation (early sensitive sign)", options: { bullet: { type: "bullet", characterCode: "25B8", color: C.red }, fontSize: 12, color: C.darkgray, breakLine: true } },
    { text: "Relative afferent pupillary defect (RAPD)", options: { bullet: { type: "bullet", characterCode: "25B8", color: C.red }, fontSize: 12, color: C.darkgray, breakLine: true } },
    { text: "Visual field defects (central/paracentral)", options: { bullet: { type: "bullet", characterCode: "25B8", color: C.red }, fontSize: 12, color: C.darkgray } },
  ];
  slide.addText(conFeatures, { x: 1.0, y: 3.9, w: 8.0, h: 1.2, valign: "top", fontFace: "Calibri" });

  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 8 — SOFT TISSUE INVOLVEMENT
// ═══════════════════════════════════════════════════════════════════
contentSlide("Soft Tissue Involvement", [
  "Most common early manifestation of TED",
  "Grittiness, foreign-body sensation, tearing, photophobia",
  "Morning puffiness of eyelids (early nonspecific symptom)",
  "Epibulbar hyperaemia: intense focal redness outlining horizontal rectus insertions — sensitive sign of activity",
  "Periorbital swelling: oedema and infiltration behind orbital septum",
  "Chemosis: conjunctival oedema, may prolapse between eyelids",
  "Superior limbic keratoconjunctivitis (SLK)",
  "Superficial punctate keratopathy / exposure keratitis",
  "Tear film instability and insufficiency is common",
  "Retrobulbar discomfort / pain on eye movement",
]);

// ═══════════════════════════════════════════════════════════════════
// SLIDE 9 — EYELID CHANGES
// ═══════════════════════════════════════════════════════════════════
twoColSlide("Eyelid Changes",
  "Signs",
  [
    "Upper eyelid retraction (most specific sign)",
    "Lateral flare of upper eyelid (highly specific for TED)",
    "Von Graefe sign: lid lag on downward gaze",
    "Lagophthalmos (incomplete eye closure)",
    "Lower lid retraction (less specific)",
    "Reduced blink rate",
    "Exposure keratopathy from incomplete closure",
  ],
  "Mechanisms",
  [
    "Sympathetic overstimulation → Müller muscle hyperactivity",
    "Fibrotic contracture of levator palpebrae superioris",
    "Adhesion of levator to overlying orbital tissues",
    "Secondary overaction in response to inferior rectus restriction",
    "High thyroid hormone levels → sympathomimetic effect",
    "Affects ~50% of Graves' disease patients",
  ]
);

// ═══════════════════════════════════════════════════════════════════
// SLIDE 10 — PROPTOSIS
// ═══════════════════════════════════════════════════════════════════
contentSlide("Proptosis (Exophthalmos)", [
  "Axial forward displacement of the globe — most common cause of bilateral and unilateral proptosis in adults",
  "Usually bilateral but can be significantly asymmetric",
  "Resistance to retropulsion on clinical examination",
  "Measured by Hertel exophthalmometer (normal: <21 mm, or >2 mm difference between eyes is significant)",
  "Two CT variants:",
  { text: "Myogenic: enlarged EOMs, minimal fat, apical crowding → optic neuropathy risk without proptosis", sub: true },
  { text: "Lipogenic: orbital fat expansion, minimal muscle involvement, severe proptosis", sub: true },
  "Complications: exposure keratopathy, bacterial keratitis, corneal ulceration",
  "Severe: globe luxation (subluxation anterior to eyelids) — requires urgent decompression",
]);

// ═══════════════════════════════════════════════════════════════════
// SLIDE 11 — RESTRICTIVE MYOPATHY
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, "Restrictive Myopathy — Extraocular Muscle Involvement");

  // Mnemonic box
  slide.addShape(pres.shapes.RECTANGLE, { x: 0.2, y: 0.68, w: 9.6, h: 0.5, fill: { color: C.light }, line: { color: C.teal, width: 1.5 } });
  slide.addText('Order of muscle involvement (most → least common):  "I\'M SLow"  — Inferior > Medial > Superior > Lateral rectus (tendons SPARED)', {
    x: 0.3, y: 0.68, w: 9.4, h: 0.5, fontSize: 13, bold: true, color: C.navy, valign: "middle", fontFace: "Calibri"
  });

  tableSlide("", [], []); // placeholder — table below instead

  // Muscle table drawn manually
  const muscles = [
    ["Inferior Rectus", "Most common", "Elevation defect", "Fibrosis mimics SR palsy"],
    ["Medial Rectus",   "2nd most common", "Abduction defect", "Mimics 6th nerve palsy"],
    ["Superior Rectus", "3rd",          "Depression defect", "Depression deficit"],
    ["Lateral Rectus",  "Least common", "Adduction defect", "Atypical — requires biopsy if isolated"],
  ];
  const hdrs = [
    { text: "Muscle", options: { bold: true, color: C.white, fill: { color: C.navy }, fontSize: 13 } },
    { text: "Frequency", options: { bold: true, color: C.white, fill: { color: C.navy }, fontSize: 13 } },
    { text: "Motility Defect", options: { bold: true, color: C.white, fill: { color: C.navy }, fontSize: 13 } },
    { text: "Clinical Mimic / Note", options: { bold: true, color: C.white, fill: { color: C.navy }, fontSize: 13 } },
  ];
  const tableData = [
    hdrs,
    ...muscles.map((row, ri) => row.map(cell => ({
      text: cell,
      options: { fontSize: 12.5, color: C.darkgray, fill: { color: ri % 2 === 0 ? C.offwhite : C.light }, valign: "middle" }
    })))
  ];
  slide.addTable(tableData, { x: 0.2, y: 1.24, w: 9.6, colW: [2.2, 2.0, 2.4, 3.0], rowH: 0.58, border: { type: "solid", color: C.silver, pt: 0.5 }, fontFace: "Calibri" });

  // Key points
  const kp = [
    { text: "Key features: ", options: { bold: true, color: C.navy } },
    { text: "Muscle belly enlarged, TENDON SPARED (differentiates TED from orbital myositis)  •  Positive forced duction test  •  Diplopia — most bothersome in downgaze (from IR fibrosis)\n" },
  ];
  slide.addText(kp, { x: 0.2, y: 3.66, w: 9.6, h: 0.5, fontSize: 12, color: C.darkgray, fontFace: "Calibri", valign: "middle" });
  slide.addText([
    { text: "⚠  Isolated lateral rectus enlargement", options: { bold: true, color: C.red } },
    { text: " is ATYPICAL for TED — requires biopsy to exclude lymphoma or metastasis", options: { color: C.darkgray } }
  ], { x: 0.2, y: 4.22, w: 9.6, h: 0.48, fontSize: 12.5, fontFace: "Calibri", valign: "middle" });

  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 12 — COMPRESSIVE OPTIC NEUROPATHY
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, "Compressive Optic Neuropathy (CON)");

  // Alert banner
  slide.addShape(pres.shapes.RECTANGLE, { x: 0.2, y: 0.65, w: 9.6, h: 0.52, fill: { color: C.red }, line: { color: C.red } });
  slide.addText("⚠  SIGHT-THREATENING EMERGENCY — Must be ruled out at EVERY visit in ALL TED patients", {
    x: 0.25, y: 0.65, w: 9.5, h: 0.52, fontSize: 13, bold: true, color: C.white, valign: "middle", fontFace: "Calibri"
  });

  twoColSlide("", "Mechanism", [
    "EOMs enlarge at orbital apex",
    "Compresses optic nerve or its blood supply",
    "Occurs even WITHOUT significant proptosis",
    "Myogenic variant: tight orbit, apical crowding",
    "5–7% of TED patients develop CON",
    "Almost invariably with restrictive strabismus",
  ], "Clinical Signs", [
    "Reduced visual acuity (not always early)",
    "Colour desaturation — MOST SENSITIVE early sign",
    "Reduced light brightness appreciation",
    "RAPD — if present, cause for urgent concern",
    "Visual field defects: central/paracentral",
    "Disc swelling or rarely atrophy",
    "IOP elevation in upgaze",
  ]);

  // Already created a sub-slide — let's just add info to current slide
  slide.addShape(pres.shapes.RECTANGLE, { x: 0.2, y: 1.25, w: 4.75, h: 0.38, fill: { color: C.teal }, line: { color: C.teal } });
  slide.addText("Mechanism", { x: 0.2, y: 1.25, w: 4.75, h: 0.38, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle", margin: 0, fontFace: "Calibri" });

  const mech = [
    "EOMs enlarge at the orbital apex",
    "Compress optic nerve or its vascular supply",
    "Occurs even WITHOUT significant proptosis",
    "Myogenic TED variant: tight orbit, apical crowding",
    "5–7% of TED patients develop CON",
    "Almost invariably accompanies restrictive strabismus",
  ].map((t, i, a) => ({ text: t, options: { bullet: { type: "bullet", characterCode: "25B8", color: C.teal }, color: C.darkgray, fontSize: 13, breakLine: i < a.length - 1 } }));
  slide.addText(mech, { x: 0.25, y: 1.65, w: 4.65, h: 3.4, valign: "top", fontFace: "Calibri" });

  slide.addShape(pres.shapes.RECTANGLE, { x: 5.1, y: 1.25, w: 4.7, h: 0.38, fill: { color: C.navy }, line: { color: C.navy } });
  slide.addText("Clinical Signs", { x: 5.1, y: 1.25, w: 4.7, h: 0.38, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle", margin: 0, fontFace: "Calibri" });

  const signs = [
    "Reduced VA (may be late)",
    "Colour desaturation — MOST SENSITIVE early sign",
    "Reduced light brightness appreciation",
    "RAPD — if present, urgent action required",
    "Visual field defects (central, paracentral)",
    "Optic disc swelling or atrophy",
  ].map((t, i, a) => ({ text: t, options: { bullet: { type: "bullet", characterCode: "25B8", color: C.navy }, color: C.darkgray, fontSize: 13, breakLine: i < a.length - 1 } }));
  slide.addText(signs, { x: 5.15, y: 1.65, w: 4.6, h: 3.4, valign: "top", fontFace: "Calibri" });

  slide.addShape(pres.shapes.LINE, { x: 4.95, y: 1.2, w: 0, h: 3.9, line: { color: C.silver, width: 1, dashType: "dash" } });
  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 13 — EUGOGO CLASSIFICATION SEVERITY
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, "EUGOGO Classification (2021) — Severity");

  const grades = [
    {
      grade: "MILD", col: C.teal, y: 0.72,
      criteria: "Minor impact on daily life\nLid retraction < 2 mm\nMild soft tissue involvement\nExophthalmos < 3 mm above normal\nTransient or absent diplopia\nCorneal exposure responding to lubricants"
    },
    {
      grade: "MODERATE–SEVERE", col: C.amber, y: 2.36,
      criteria: "Sufficient impact on daily life to justify immunosuppression\nLid retraction ≥ 2 mm\nModerate–severe soft tissue involvement\nExophthalmos ≥ 3 mm above normal\nInconstant or constant diplopia"
    },
    {
      grade: "SIGHT-THREATENING", col: C.red, y: 4.0,
      criteria: "Dysthyroid optic neuropathy (DON)  •  Corneal breakdown (exposure keratopathy unresponsive to treatment)"
    },
  ];

  grades.forEach(g => {
    slide.addShape(pres.shapes.RECTANGLE, { x: 0.2, y: g.y, w: 1.5, h: g.grade === "SIGHT-THREATENING" ? 1.1 : 1.52, fill: { color: g.col }, line: { color: g.col } });
    slide.addText(g.grade, { x: 0.2, y: g.y, w: 1.5, h: g.grade === "SIGHT-THREATENING" ? 1.1 : 1.52, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 3, fontFace: "Calibri" });
    slide.addShape(pres.shapes.RECTANGLE, { x: 1.75, y: g.y, w: 8.05, h: g.grade === "SIGHT-THREATENING" ? 1.1 : 1.52, fill: { color: C.white }, line: { color: g.col, width: 1.5 } });
    slide.addText(g.criteria, { x: 1.85, y: g.y + 0.06, w: 7.85, h: (g.grade === "SIGHT-THREATENING" ? 1.1 : 1.52) - 0.1, fontSize: 12.5, color: C.darkgray, valign: "middle", fontFace: "Calibri" });
  });

  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 14 — CLINICAL ACTIVITY SCORE
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, "Clinical Activity Score (CAS) — EUGOGO");

  const items = [
    "Spontaneous retrobulbar pain",
    "Pain on attempted upward or downward gaze",
    "Redness of eyelids",
    "Redness of conjunctiva",
    "Swelling of conjunctiva / plica",
    "Swelling of eyelids",
    "Chemosis",
  ];

  items.forEach((item, i) => {
    const y = 0.72 + i * 0.52;
    slide.addShape(pres.shapes.RECTANGLE, { x: 0.2, y, w: 0.52, h: 0.42, fill: { color: C.teal }, line: { color: C.teal } });
    slide.addText(`${i + 1}`, { x: 0.2, y, w: 0.52, h: 0.42, fontSize: 14, bold: true, color: C.white, align: "center", valign: "middle", margin: 0, fontFace: "Calibri" });
    slide.addText(item, { x: 0.82, y: y + 0.02, w: 5.8, h: 0.38, fontSize: 13.5, color: C.darkgray, valign: "middle", fontFace: "Calibri" });
    slide.addShape(pres.shapes.RECTANGLE, { x: 6.7, y, w: 0.52, h: 0.42, fill: { color: C.white }, line: { color: C.silver, width: 1 } });
    slide.addText("1 pt", { x: 6.7, y, w: 0.52, h: 0.42, fontSize: 11, color: C.gray, align: "center", valign: "middle", margin: 0 });
  });

  // Scoring guide
  slide.addShape(pres.shapes.RECTANGLE, { x: 7.4, y: 0.72, w: 2.4, h: 3.66, fill: { color: C.navy }, line: { color: C.navy } });
  slide.addText("SCORING\nGUIDE", { x: 7.4, y: 0.74, w: 2.4, h: 0.5, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle", margin: 2, fontFace: "Calibri" });

  [
    ["0–2", "Inactive", C.light],
    ["≥ 3/7", "ACTIVE\n→ Immunosuppression", C.amber],
    ["> 3", "Consider early\nspecialist referral", C.teal],
  ].forEach(([score, label, col], i) => {
    slide.addShape(pres.shapes.RECTANGLE, { x: 7.5, y: 1.28 + i * 0.95, w: 2.2, h: 0.82, fill: { color: col }, line: { color: col } });
    slide.addText(`${score}\n${label}`, { x: 7.5, y: 1.28 + i * 0.95, w: 2.2, h: 0.82, fontSize: 11.5, bold: true, color: i === 0 ? C.darkgray : C.white, align: "center", valign: "middle", margin: 3, fontFace: "Calibri" });
  });

  slide.addText("Follow-up CAS adds points for: proptosis increase ≥2 mm, EOM excursion decrease ≥8°, Snellen acuity decrease ≥1 line (total /10)",
    { x: 0.2, y: 5.06, w: 9.6, h: 0.28, fontSize: 10, color: C.gray, italic: true, fontFace: "Calibri" });
  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 15 — DIFFERENTIAL DIAGNOSIS
// ═══════════════════════════════════════════════════════════════════
tableSlide("Differential Diagnosis",
  ["Condition", "Distinguishing Feature"],
  [
    ["Orbital Myositis", "Tendon INVOLVED (unlike TED); painful; responds rapidly to steroids"],
    ["Orbital Lymphoma", "Painless; homogeneous soft tissue mass; isolated lateral rectus enlargement"],
    ["Orbital Metastasis", "History of malignancy; irregular margins; bone destruction on CT"],
    ["Carotid-Cavernous Fistula", "Pulsating proptosis; bruit; dilated arterialized conjunctival vessels"],
    ["Myasthenia Gravis", "Ptosis (not retraction); fatigable; Tensilon test; co-exists in 1–2% of TED"],
    ["Parinaud Syndrome", "Eyelid retraction + upgaze palsy; convergence-retraction nystagmus; dorsal midbrain lesion"],
    ["CN III Palsy (aberrant)", "Pseudo-von Graefe sign; eyelid elevates in downgaze; motility limitation"],
    ["Lymphangioma/Haematoma", "Young patient; proptosis with URTI; fluid levels on MRI"],
  ]
);

// ═══════════════════════════════════════════════════════════════════
// SLIDE 16 — INVESTIGATIONS
// ═══════════════════════════════════════════════════════════════════
contentSlide("Investigations", [
  "THYROID FUNCTION: TSH, free T3 & T4 (may be normal in euthyroid TED)",
  { text: "TSI (thyroid-stimulating immunoglobulin) and TPO antibodies — guide diagnosis and treatment planning", sub: true },
  "SERUM VITAMIN D — supplement if deficient; linked to progressive orbitopathy",
  "CT ORBIT (axial + coronal, without contrast) — preferred first-line imaging",
  { text: "Fusiform muscle belly enlargement with tendon sparing; apical crowding; orbital fat assessment", sub: true },
  "MRI ORBIT — superior soft tissue resolution; active vs. fibrotic disease (fat-saturated T2 signal)",
  "ULTRASONOGRAPHY — muscle thickness; orbital Doppler for vascularity in active disease",
  "AUTOMATED PERIMETRY — mandatory if optic neuropathy suspected",
  "HERTEL EXOPHTHALMOMETER — measure and monitor proptosis (document baseline)",
  "FORCED DUCTION TESTING — differentiates restrictive from paretic strabismus",
  "VISUAL EVOKED POTENTIALS — assess subclinical optic nerve involvement",
  "Screen for MYASTHENIA GRAVIS if fluctuating diplopia / ptosis (not retraction)",
], { fontSize: 13 });

// ═══════════════════════════════════════════════════════════════════
// SLIDE 17 — CT & MRI FINDINGS
// ═══════════════════════════════════════════════════════════════════
twoColSlide("Orbital Imaging in TED",
  "CT Orbit Findings",
  [
    "Fusiform muscle belly enlargement",
    "TENDON SPARING (key feature — differentiates from myositis)",
    "Symmetrical involvement common (but can be unilateral)",
    "Order: Inferior > Medial > Superior > Lateral rectus",
    "Apical crowding: loss of fat at orbital apex → CON risk",
    "Increased orbital fat volume (lipogenic variant)",
    "Lacrimal gland enlargement possible",
    "No bone erosion (unlike neoplastic processes)",
  ],
  "MRI Findings",
  [
    "Superior soft tissue characterisation vs CT",
    "Active disease: T2 high signal (oedema/inflammation)",
    "Inactive/fibrotic: T2 low signal",
    "Fat-saturated T2 predicts steroid response",
    "Useful when diagnosis uncertain",
    "Better for optic nerve assessment",
    "DWI may help differentiate TED from lymphoma",
    "No radiation — preferred in young patients",
  ]
);

// ═══════════════════════════════════════════════════════════════════
// SLIDE 18 — MANAGEMENT OVERVIEW
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, "Management — Overview & Principles");

  // 3 column approach
  const cols = [
    {
      x: 0.18, col: C.teal, title: "ALL PATIENTS\n(First Steps)",
      items: [
        "Smoking cessation\n(most important modifiable step)",
        "Thyroid dysfunction\ncontrol via endocrinologist",
        "Protect with oral steroids\nif RAI therapy given",
        "Euthyroid TED: TFTs\nevery 6–12 months",
        "Vitamin D supplementation\nif deficient",
      ]
    },
    {
      x: 3.45, col: C.amber, title: "MILD ACTIVE",
      items: [
        "Artificial tears / lubricants",
        "Eyelid taping at night",
        "Head elevation (3 pillows)\nfor periorbital oedema",
        "Selenium 200 µg/day × 6 months\n(selenium-deficient regions)",
        "Vitamin D supplementation",
        "Reassure & monitor",
      ]
    },
    {
      x: 6.72, col: C.navy, title: "MODERATE–SEVERE\n/ SIGHT-THREATENING",
      items: [
        "IV methylprednisolone\n(first-line immunosuppression)",
        "+ Mycophenolate sodium\n(superior to steroids alone)",
        "Orbital radiotherapy\n(2nd line)",
        "Teprotumumab (IGF-1R\nmonoclonal antibody)",
        "Orbital decompression\nsurgery if needed",
      ]
    },
  ];

  cols.forEach(c => {
    slide.addShape(pres.shapes.RECTANGLE, { x: c.x, y: 0.68, w: 3.1, h: 0.52, fill: { color: c.col }, line: { color: c.col } });
    slide.addText(c.title, { x: c.x, y: 0.68, w: 3.1, h: 0.52, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 2, fontFace: "Calibri" });

    c.items.forEach((item, i) => {
      const y = 1.26 + i * 0.72;
      slide.addShape(pres.shapes.RECTANGLE, { x: c.x, y, w: 3.1, h: 0.65, fill: { color: i % 2 === 0 ? C.white : C.light }, line: { color: C.silver, width: 0.5 } });
      slide.addText(item, { x: c.x + 0.1, y, w: 2.9, h: 0.65, fontSize: 11.5, color: C.darkgray, valign: "middle", fontFace: "Calibri" });
    });
  });

  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 19 — MILD DISEASE TREATMENT
// ═══════════════════════════════════════════════════════════════════
contentSlide("Treatment of Mild Active TED", [
  "Artificial tears (preservative-free) and lubricating eye ointment at night",
  "Eyelid taping or moisture chambers at night — alleviates mild exposure keratopathy",
  "Head elevation during sleep (3 pillows) — reduces periorbital oedema",
  "Selenium (sodium selenite 200 µg/day × 6 months) — evidence from European trials; reduces progression in mild-moderate TED",
  { text: "Note: selenium in selenium-deficient populations; use caution in men with family history of prostate cancer", sub: true },
  "Vitamin D supplementation if deficient",
  "Topical ciclosporin / NSAIDs / steroids — advocated by some for ocular surface inflammation",
  "Prism glasses — for mild diplopia in stable phase",
  "Dark glasses — for photophobia and corneal protection",
  "Monitor thyroid function every 6–12 months if euthyroid",
  "Review every 3–6 months for disease progression (CAS monitoring)",
]);

// ═══════════════════════════════════════════════════════════════════
// SLIDE 20 — MODERATE-SEVERE TREATMENT
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, "Treatment of Moderate–Severe Active TED");

  // IV steroid protocol box
  slide.addShape(pres.shapes.RECTANGLE, { x: 0.2, y: 0.68, w: 9.6, h: 0.36, fill: { color: C.navy }, line: { color: C.navy } });
  slide.addText("FIRST-LINE: Intravenous Methylprednisolone (IV-GCs) — Superior tolerability & outcomes vs. oral steroids", {
    x: 0.25, y: 0.68, w: 9.5, h: 0.36, fontSize: 12.5, bold: true, color: C.white, valign: "middle", fontFace: "Calibri"
  });

  const protocols = [
    ["Standard Protocol", "0.5 g IV weekly × 6 weeks,\nthen 0.25 g IV weekly × 6 weeks\n(total cumulative dose ≤ 8 g)", C.teal],
    ["+ Mycophenolate Sodium", "0.72 g/day orally × 24 weeks\nAdded to IV-GC → superior to IV-GC alone\n(regimen of choice in specialist centres)", C.navy],
    ["Acute Optic Neuropathy", "0.5–1 g IV daily × 3 days\n(or alternate days × 3–6 doses)\nThen convert to oral prednisolone 40 mg/day", C.red],
  ];

  protocols.forEach((p, i) => {
    slide.addShape(pres.shapes.RECTANGLE, { x: 0.2 + i * 3.28, y: 1.1, w: 3.1, h: 0.4, fill: { color: p[2] }, line: { color: p[2] } });
    slide.addText(p[0], { x: 0.2 + i * 3.28, y: 1.1, w: 3.1, h: 0.4, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0, fontFace: "Calibri" });
    slide.addShape(pres.shapes.RECTANGLE, { x: 0.2 + i * 3.28, y: 1.5, w: 3.1, h: 1.2, fill: { color: C.white }, line: { color: p[2], width: 1.5 } });
    slide.addText(p[1], { x: 0.3 + i * 3.28, y: 1.55, w: 2.9, h: 1.1, fontSize: 12, color: C.darkgray, valign: "middle", fontFace: "Calibri" });
  });

  // Contraindications
  slide.addShape(pres.shapes.RECTANGLE, { x: 0.2, y: 2.82, w: 4.55, h: 0.36, fill: { color: C.red }, line: { color: C.red } });
  slide.addText("Contraindications to IV Steroids", { x: 0.25, y: 2.82, w: 4.5, h: 0.36, fontSize: 12, bold: true, color: C.white, valign: "middle", fontFace: "Calibri" });
  const contras = [
    "Significant hepatic dysfunction (ALT/AST >3× normal)",
    "Uncontrolled systemic hypertension",
    "Uncontrolled diabetes mellitus",
    "Significant cardiovascular disease",
  ].map((t, i, a) => ({ text: t, options: { bullet: { type: "bullet", characterCode: "25B8", color: C.red }, fontSize: 12, color: C.darkgray, breakLine: i < a.length - 1 } }));
  slide.addText(contras, { x: 0.25, y: 3.22, w: 4.5, h: 1.6, valign: "top", fontFace: "Calibri" });

  // Orbital radiotherapy
  slide.addShape(pres.shapes.RECTANGLE, { x: 5.0, y: 2.82, w: 4.8, h: 0.36, fill: { color: C.amber }, line: { color: C.amber } });
  slide.addText("Orbital Radiotherapy (2nd Line)", { x: 5.05, y: 2.82, w: 4.7, h: 0.36, fontSize: 12, bold: true, color: C.white, valign: "middle", fontFace: "Calibri" });
  const rad = [
    "20 Gy in 10–14 fractions over 2 weeks",
    "Max benefit at 4 months; 40% non-responders",
    "Avoid in: diabetics (retinopathy risk), vasculopaths",
    "Combined with steroids for better efficacy",
  ].map((t, i, a) => ({ text: t, options: { bullet: { type: "bullet", characterCode: "25B8", color: C.amber }, fontSize: 12, color: C.darkgray, breakLine: i < a.length - 1 } }));
  slide.addText(rad, { x: 5.05, y: 3.22, w: 4.7, h: 1.6, valign: "top", fontFace: "Calibri" });

  slide.addText("Monitor: LFTs, blood glucose, BP; gastric protection (PPI); osteoporosis prophylaxis (Ca²⁺ + Vit D); DEXA scan if prolonged",
    { x: 0.2, y: 5.05, w: 9.6, h: 0.28, fontSize: 10, color: C.gray, italic: true, fontFace: "Calibri" });
  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 21 — BIOLOGICS — TEPROTUMUMAB
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, "Biologic Therapies in TED");

  tableSlide("", [], []);

  const drugs = [
    { name: "Teprotumumab", target: "IGF-1R\n(insulin-like growth factor-1\nreceptor)", status: "FDA APPROVED\nJanuary 2020", evidence: "Phase 2 & 3 RCTs: significant reduction in proptosis and diplopia; effective for optic neuropathy in small series", col: C.teal },
    { name: "Rituximab", target: "CD20\n(B-cell depletion)", status: "Off-label", evidence: "Mixed RCT evidence; may be superior to IV steroids in some studies; effect may depend on disease activity", col: C.navy },
    { name: "Tocilizumab", target: "IL-6 Receptor\nantagonist", status: "Off-label", evidence: "2025 meta-analysis shows efficacy in reducing CAS and proptosis; well tolerated", col: C.mid },
  ];

  const hdrs = [
    { text: "Drug", options: { bold: true, color: C.white, fill: { color: C.navy }, fontSize: 13 } },
    { text: "Target", options: { bold: true, color: C.white, fill: { color: C.navy }, fontSize: 13 } },
    { text: "Regulatory Status", options: { bold: true, color: C.white, fill: { color: C.navy }, fontSize: 13 } },
    { text: "Evidence Summary", options: { bold: true, color: C.white, fill: { color: C.navy }, fontSize: 13 } },
  ];
  const tableData = [
    hdrs,
    ...drugs.map((d, ri) => [
      { text: d.name, options: { fontSize: 13, bold: true, color: d.col, fill: { color: ri % 2 === 0 ? C.offwhite : C.light }, valign: "middle" } },
      { text: d.target, options: { fontSize: 12, color: C.darkgray, fill: { color: ri % 2 === 0 ? C.offwhite : C.light }, valign: "middle" } },
      { text: d.status, options: { fontSize: 12, bold: true, color: d.col, fill: { color: ri % 2 === 0 ? C.offwhite : C.light }, valign: "middle" } },
      { text: d.evidence, options: { fontSize: 11.5, color: C.darkgray, fill: { color: ri % 2 === 0 ? C.offwhite : C.light }, valign: "middle" } },
    ])
  ];
  slide.addTable(tableData, { x: 0.2, y: 0.68, w: 9.6, colW: [1.9, 2.0, 1.8, 3.9], rowH: 1.18, border: { type: "solid", color: C.silver, pt: 0.5 }, fontFace: "Calibri" });

  slide.addShape(pres.shapes.RECTANGLE, { x: 0.2, y: 4.28, w: 9.6, h: 0.62, fill: { color: C.light }, line: { color: C.teal, width: 1 } });
  slide.addText("2025 meta-analysis (PMID 40404973): Rituximab, tocilizumab, and teprotumumab all effective in Graves' orbitopathy. Teprotumumab shows strongest proptosis reduction. Choice depends on availability, cost, and patient profile.",
    { x: 0.3, y: 4.3, w: 9.4, h: 0.58, fontSize: 11, color: C.navy, valign: "middle", italic: true, fontFace: "Calibri" });

  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 22 — SURGICAL MANAGEMENT
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, "Surgical Management — Stepwise Algorithm");

  // Alert: only after inactive phase
  slide.addShape(pres.shapes.RECTANGLE, { x: 0.2, y: 0.66, w: 9.6, h: 0.36, fill: { color: C.amber }, line: { color: C.amber } });
  slide.addText("⚠  Surgery is performed in the QUIESCENT phase ONLY (except orbital decompression for emergency situations)", {
    x: 0.25, y: 0.66, w: 9.5, h: 0.36, fontSize: 12.5, bold: true, color: C.white, valign: "middle", fontFace: "Calibri"
  });

  const steps = [
    {
      step: "STEP 1", title: "Orbital Decompression",
      indications: "Compressive optic neuropathy • Severe exposure keratopathy • Globe luxation • Uncontrolled elevated IOP • Morbid proptosis",
      note: "Posterior/medial wall for optic neuropathy; endoscopic (ENT) ± open approach; anterior decompression ineffective for CON",
      col: C.navy, y: 1.12
    },
    {
      step: "STEP 2", title: "Strabismus Surgery",
      indications: "Significant diplopia in primary or reading gaze • After orbital decompression has been performed and is stable",
      note: "Adjustable sutures preferred; aim for single binocular vision; recession of tight muscle rather than resection",
      col: C.teal, y: 2.46
    },
    {
      step: "STEP 3", title: "Eyelid Surgery",
      indications: "Lid retraction causing exposure • Cosmetically significant retraction • After strabismus surgery is complete and stable",
      note: "Müller muscle recession; levator lengthening; lateral tarsal strip for lower lid retraction",
      col: C.mid, y: 3.8
    },
  ];

  steps.forEach(s => {
    slide.addShape(pres.shapes.RECTANGLE, { x: 0.2, y: s.y, w: 1.0, h: 1.2, fill: { color: s.col }, line: { color: s.col } });
    slide.addText(`${s.step}\n${s.title}`, { x: 0.2, y: s.y, w: 1.0, h: 1.2, fontSize: 10, bold: true, color: C.white, align: "center", valign: "middle", margin: 3, fontFace: "Calibri" });
    slide.addShape(pres.shapes.RECTANGLE, { x: 1.25, y: s.y, w: 8.55, h: 1.2, fill: { color: C.white }, line: { color: s.col, width: 1.5 } });
    slide.addText([
      { text: "Indications: ", options: { bold: true, color: s.col } },
      { text: s.indications + "\n", options: { color: C.darkgray } },
      { text: "Technique note: ", options: { bold: true, color: C.gray } },
      { text: s.note, options: { color: C.gray, italic: true } },
    ], { x: 1.35, y: s.y + 0.06, w: 8.35, h: 1.1, fontSize: 12, valign: "top", fontFace: "Calibri" });
  });

  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 23 — SIGHT-THREATENING TED / EMERGENCY
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  // Red header for emergency
  slide.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 0.52, fill: { color: C.red }, line: { color: C.red } });
  slide.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0.52, w: 10, h: 0.06, fill: { color: C.amber }, line: { color: C.amber } });
  slide.addText("SIGHT-THREATENING TED — Emergency Management", { x: 0.35, y: 0, w: 9.3, h: 0.52, fontSize: 18, bold: true, color: C.white, valign: "middle", margin: 0 });

  // Step-by-step emergency
  const steps = [
    { num: "1", label: "Assess immediately", body: "Visual acuity (Snellen) • Colour vision • RAPD • Visual fields (confrontation then formal perimetry) • Dilated fundus exam • Forced ductions" },
    { num: "2", label: "Initiate IV Steroids Urgently", body: "IV methylprednisolone 0.5–1 g × 3 consecutive days, then oral prednisolone 40 mg/day\nMonitor LFTs, blood glucose, blood pressure" },
    { num: "3", label: "If Steroids Fail (20% of cases)", body: "Urgent orbital decompression surgery — posterior medial wall decompression is most effective for CON\nAnterior decompression is INSUFFICIENT for optic neuropathy" },
    { num: "4", label: "Adjunctive Options", body: "Orbital radiotherapy (delayed response — NOT sole treatment in emergency)\nTeprotumumab (emerging evidence for CON)\nOphthalmology + endocrinology co-management" },
  ];

  steps.forEach((s, i) => {
    const y = 0.68 + i * 1.1;
    slide.addShape(pres.shapes.OVAL, { x: 0.2, y: y + 0.05, w: 0.6, h: 0.6, fill: { color: C.red }, line: { color: C.red } });
    slide.addText(s.num, { x: 0.2, y: y + 0.05, w: 0.6, h: 0.6, fontSize: 16, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText(s.label, { x: 0.9, y, w: 8.9, h: 0.36, fontSize: 13, bold: true, color: C.red, valign: "middle", fontFace: "Calibri" });
    slide.addText(s.body, { x: 0.9, y: y + 0.38, w: 8.9, h: 0.66, fontSize: 12, color: C.darkgray, valign: "top", fontFace: "Calibri" });
  });

  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 24 — SPECIAL CONSIDERATIONS
// ═══════════════════════════════════════════════════════════════════
contentSlide("Special Considerations & Clinical Pearls", [
  "TED and thyroid status are INDEPENDENT — TED may precede, coincide with, or follow thyroid dysfunction by months to years",
  "RAI worsens TED — always cover pre-existing active TED patients with oral steroids if RAI is indicated",
  "Smoking is the single most modifiable risk factor — cessation reduces progression and response to treatment; document counselling",
  "Compressive optic neuropathy often occurs WITHOUT significant proptosis (myogenic/tight orbit variant)",
  "Isolated lateral rectus enlargement is ATYPICAL — biopsy to exclude lymphoma or metastasis",
  "Concomitant myasthenia gravis: ask about bulbar symptoms in TED + diplopia; ptosis (not retraction) should prompt MG workup",
  "Paediatric TED is rare but can occur; requires ophthalmology co-management and careful monitoring",
  "Selenium supplementation: only evidence in selenium-deficient populations; prostate cancer risk in men with high selenium",
  "Immunosuppression after 18 months of disease has significantly reduced efficacy — early referral to specialist is critical",
]);

// ═══════════════════════════════════════════════════════════════════
// SLIDE 25 — MONITORING & FOLLOW-UP
// ═══════════════════════════════════════════════════════════════════
tableSlide("Monitoring & Follow-up in TED",
  ["Parameter", "Method", "Frequency"],
  [
    ["Visual acuity", "Snellen chart", "Every visit"],
    ["Colour vision", "Ishihara / red desaturation", "Every visit — sensitive early sign of CON"],
    ["Proptosis", "Hertel exophthalmometer", "Every visit; document baseline"],
    ["Eyelid aperture", "Measure in mm", "Every visit"],
    ["Ocular motility", "Versions & ductions; Maddox rod", "Every visit"],
    ["IOP", "In primary gaze AND upgaze", "Every visit"],
    ["Visual fields", "Automated perimetry (Humphrey)", "If CON suspected; baseline at diagnosis"],
    ["Thyroid function", "TSH, free T4 ± TSI, TPO", "Every 6–12 months (euthyroid TED)"],
    ["Vitamin D", "25-OH vitamin D serum level", "At baseline; supplement if low"],
    ["CAS scoring", "EUGOGO Clinical Activity Score", "Every visit in active phase"],
  ]
);

// ═══════════════════════════════════════════════════════════════════
// SLIDE 26 — PATIENT EDUCATION
// ═══════════════════════════════════════════════════════════════════
twoColSlide("Patient Education & Counselling",
  "What to Tell Patients",
  [
    "TED is an autoimmune disease — not directly caused by thyroid hormone levels",
    "Disease often burns out in 1–3 years but changes may be permanent",
    "Smoking dramatically worsens TED — cessation is the most important action",
    "Check vision daily by alternately covering each eye (test reading and colour)",
    "Seek urgent review if: pain worsens, vision changes, colours look different",
    "RAI for thyroid can worsen eye disease — discuss with your doctor",
    "Surgery (if needed) is done in stages — after inflammation settles",
  ],
  "Self-Monitoring",
  [
    "Alternate eye cover test: assess visual acuity and colour daily",
    "Morning eyelid puffiness — elevate head of bed",
    "Use lubricating drops as needed (preservative-free if >4x/day)",
    "Wear wraparound sunglasses in wind and bright light",
    "Goggles at night if unable to fully close eyes",
    "Keep all follow-up appointments even if feeling well",
    "Report any new or worsening diplopia promptly",
  ]
);

// ═══════════════════════════════════════════════════════════════════
// SLIDE 27 — QUALITY OF LIFE
// ═══════════════════════════════════════════════════════════════════
contentSlide("Impact on Quality of Life", [
  "TED has profound physical and psychological impact beyond visual function",
  "Altered appearance (proptosis, retraction) causes significant psychosocial distress",
  "Diplopia affects driving, reading, and daily activities",
  "Depression and anxiety are significantly more common in TED vs. general population",
  "Body image concerns: disfigurement even in mild-moderate disease",
  "GO-QOL (Graves' Ophthalmopathy Quality of Life questionnaire) — validated patient-reported outcome",
  { text: "Two subscales: visual functioning and appearance", sub: true },
  "Multidisciplinary approach: ophthalmologist + endocrinologist + psychologist + ENT (for decompression)",
  "Early and effective treatment significantly improves QoL outcomes",
  "Teprotumumab (2020): patient-reported outcomes showed meaningful improvement in diplopia and appearance",
]);

// ═══════════════════════════════════════════════════════════════════
// SLIDE 28 — RECENT ADVANCES
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  sectionBar(slide, "Recent Advances & Emerging Evidence (2024–2026)");

  const advances = [
    { title: "Teprotumumab (FDA 2020)", body: "IGF-1R inhibitor — first approved drug specifically for TED; 8 IV infusions over 24 weeks; >80% proptosis response; also effective for CON", col: C.teal },
    { title: "Tocilizumab", body: "IL-6R antagonist; 2025 meta-analysis confirms efficacy and safety in TED (PMID 40304985); subcutaneous administration possible", col: C.navy },
    { title: "Rituximab vs. Teprotumumab", body: "2025 comparative meta-analysis (PMID 40404973): all three biologics (rituximab, tocilizumab, teprotumumab) effective; teprotumumab shows strongest proptosis reduction", col: C.amber },
    { title: "Multi-Omics Biomarkers", body: "2024 systematic review (PMID 39664569): proteomic, genomic, metabolomic biomarkers being studied to predict disease activity and treatment response", col: C.mid },
    { title: "Neuroimaging in TED", body: "2024 systematic review: MRI increasingly used to assess optic nerve compression, predict CON risk, monitor treatment response (PMID 39396626)", col: C.gray },
    { title: "Selenium — Updated Evidence", body: "EUGOGO confirmed selenium (200 µg/day × 6 months) reduces progression in mild-moderate, active TED in selenium-deficient European populations", col: C.darkgray },
  ];

  advances.forEach((a, i) => {
    const col = i < 3 ? i : i - 3;
    const row = i < 3 ? 0 : 1;
    const x = 0.2 + col * 3.28;
    const y = 0.7 + row * 2.14;
    slide.addShape(pres.shapes.RECTANGLE, { x, y, w: 3.1, h: 0.4, fill: { color: a.col }, line: { color: a.col } });
    slide.addText(a.title, { x, y, w: 3.1, h: 0.4, fontSize: 11.5, bold: true, color: C.white, align: "center", valign: "middle", margin: 2, fontFace: "Calibri" });
    slide.addShape(pres.shapes.RECTANGLE, { x, y: y + 0.4, w: 3.1, h: 1.6, fill: { color: C.white }, line: { color: a.col, width: 1.5 } });
    slide.addText(a.body, { x: x + 0.1, y: y + 0.46, w: 2.9, h: 1.48, fontSize: 11.5, color: C.darkgray, valign: "top", fontFace: "Calibri" });
  });

  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 29 — KEY TAKEAWAYS
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  addBg(slide, C.offwhite);
  slide.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 0.52, fill: { color: C.navy }, line: { color: C.navy } });
  slide.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0.52, w: 10, h: 0.06, fill: { color: C.amber }, line: { color: C.amber } });
  slide.addText("Key Takeaways", { x: 0.35, y: 0, w: 9.3, h: 0.52, fontSize: 18, bold: true, color: C.white, valign: "middle", margin: 0 });

  const points = [
    { num: "1", text: "TED is the most common cause of proptosis in adults — most commonly caused by Graves' disease but can occur in euthyroid/hypothyroid patients", col: C.teal },
    { num: "2", text: "Pathogenesis: anti-TSHR antibodies activate orbital fibroblasts via IGF-1R → GAG deposition, muscle enlargement, fat expansion", col: C.navy },
    { num: "3", text: "SMOKING is the most important modifiable risk factor — always counsel cessation and document it", col: C.red },
    { num: "4", text: "Optic nerve compression (CON) can occur WITHOUT significant proptosis — must be excluded at every visit (colour vision is the most sensitive early sign)", col: C.red },
    { num: "5", text: "EUGOGO CAS ≥3/7 = active disease → consider immunosuppression; anti-inflammatory treatment is most effective within 18 months", col: C.amber },
    { num: "6", text: "First-line: IV methylprednisolone ± mycophenolate sodium; teprotumumab (IGF-1R inhibitor) FDA-approved 2020 for moderate-severe TED", col: C.teal },
    { num: "7", text: "Surgical sequence is mandatory: orbital decompression FIRST → strabismus surgery → eyelid surgery (reversing order leads to unpredictable results)", col: C.mid },
    { num: "8", text: "Multidisciplinary care (ophthalmology + endocrinology ± ENT ± psychology) is essential for comprehensive TED management", col: C.navy },
  ];

  points.forEach((p, i) => {
    const x = i < 4 ? 0.15 : 5.1;
    const y = 0.68 + (i % 4) * 1.12;
    slide.addShape(pres.shapes.OVAL, { x, y: y + 0.05, w: 0.5, h: 0.5, fill: { color: p.col }, line: { color: p.col } });
    slide.addText(p.num, { x, y: y + 0.05, w: 0.5, h: 0.5, fontSize: 14, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText(p.text, { x: x + 0.6, y: y + 0.02, w: 4.2, h: 1.0, fontSize: 12, color: C.darkgray, valign: "middle", fontFace: "Calibri" });
  });

  slide.addShape(pres.shapes.LINE, { x: 4.9, y: 0.58, w: 0, h: 4.76, line: { color: C.silver, width: 1, dashType: "dash" } });
  slide.addText("Thyroid Eye Disease", { x: 0, y: 5.32, w: 10, h: 0.3, fontSize: 9, color: C.silver, align: "right", italic: true });
}

// ═══════════════════════════════════════════════════════════════════
// SLIDE 30 — REFERENCES & CLOSING
// ═══════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  slide.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.navy }, line: { color: C.navy } });
  slide.addShape(pres.shapes.RECTANGLE, { x: 0, y: 4.38, w: 10, h: 0.12, fill: { color: C.teal }, line: { color: C.teal } });
  slide.addShape(pres.shapes.RECTANGLE, { x: 0, y: 4.5, w: 5.5, h: 0.07, fill: { color: C.amber }, line: { color: C.amber } });

  slide.addText("References", { x: 0.5, y: 0.22, w: 9, h: 0.52, fontSize: 22, bold: true, color: C.amber, fontFace: "Calibri" });

  const refs = [
    "Kanski's Clinical Ophthalmology: A Systematic Approach, 10th Edition — Chapter 4, Thyroid Eye Disease",
    "The Wills Eye Manual: Office and Emergency Room Diagnosis and Treatment, 8th Edition — Section 7.2.1",
    "Scott-Brown's Otorhinolaryngology Head & Neck Surgery, Vol. 1 — Thyroid Eye Disease",
    "EUGOGO (European Group on Graves' Orbitopathy) Guidelines 2021",
    "Barrio-Barrio J et al. EUGOGO Classification. Ophthalmic Res. 2021",
    "Huang W et al. Teprotumumab in TED: Systematic Review & Meta-Analysis. Endocr Pract. 2025 [PMID 39952471]",
    "Abumohssin AG et al. Rituximab, tocilizumab, and teprotumumab in Graves' orbitopathy. Eye (Lond). 2025 [PMID 40404973]",
    "Lin S et al. Tocilizumab for TED: Meta-analysis. J Endocrinol Invest. 2025 [PMID 40304985]",
    "Zhang H et al. Neuroimaging in TED: Systematic Review. Autoimmun Rev. 2024 [PMID 39396626]",
  ];

  refs.forEach((r, i) => {
    slide.addText([
      { text: `${i + 1}.  `, options: { bold: true, color: C.amber } },
      { text: r, options: { color: C.light } }
    ], { x: 0.5, y: 0.82 + i * 0.38, w: 9, h: 0.36, fontSize: 10.5, valign: "middle", fontFace: "Calibri" });
  });

  slide.addText("Thank You", { x: 0.5, y: 4.6, w: 5, h: 0.5, fontSize: 20, bold: true, color: C.white, fontFace: "Calibri" });
  slide.addText("For educational purposes — Kanski's, Wills Eye Manual, EUGOGO 2021 Guidelines", {
    x: 5.5, y: 4.68, w: 4.2, h: 0.36, fontSize: 9, color: C.silver, align: "right", italic: true, fontFace: "Calibri"
  });
}

// ─── WRITE FILE ────────────────────────────────────────────────────
pres.writeFile({ fileName: "/home/daytona/workspace/ted-ppt/Thyroid_Eye_Disease.pptx" })
  .then(() => console.log("✅ Presentation saved successfully."))
  .catch(err => { console.error("❌ Error:", err); process.exit(1); });
Running Command

cd /home/daytona/workspace/ted-ppt && node ted.js 2>&1

Running Command

ls -lh /home/daytona/workspace/ted-ppt/Thyroid_Eye_Disease.pptx && python3 -c " import zipfile with zipfile.ZipFile('/home/daytona/workspace/ted-ppt/Thyroid_Eye_Disease.pptx') as z: slides = [f for f in z.namelist() if f.startswith('ppt/slides/slide') and not 'rels' in f] print(f'Total slides: {len(slides)}') for s in sorted(slides): print(s) "

Your presentation is ready — 33 slides, 759 KB.

Thyroid Eye Disease

Presentation · PPTX


What's included (33 slides):
#Slide
1Title slide — dark navy with eye icon graphic
2Table of Contents (20 topics)
3Definition & Epidemiology
4Pathogenesis (flow diagram: TSHR → GAG → muscle swelling → proptosis/CON)
5Risk Factors (6 cards: smoking, RAI, sex, vitamin D, genetics, thyroid status)
6Disease Phases — Rundle's Curve (active vs. quiescent)
7Clinical Features Overview (5 categories + red-alert CON banner)
8Soft Tissue Involvement
9Eyelid Changes (two-column: signs vs. mechanisms)
10Proptosis & Variants (myogenic vs. lipogenic)
11Restrictive Myopathy (table: "I'M SLow" mnemonic)
12Compressive Optic Neuropathy (red emergency banner)
13EUGOGO Classification — Severity (Mild / Moderate-Severe / Sight-threatening)
14Clinical Activity Score (CAS) with scoring guide
15Differential Diagnosis (table)
16Investigations
17CT & MRI Findings (two-column)
18Management Overview (3-column: All / Mild / Moderate-Severe)
19Mild Active Disease Treatment
20Moderate-Severe Treatment (IV steroid protocols + radiotherapy)
21Biologic Therapies — Teprotumumab, Rituximab, Tocilizumab (table)
22Surgical Algorithm (3-step stepwise)
23Sight-Threatening TED — Emergency Management (red header)
24Special Considerations & Clinical Pearls
25Monitoring & Follow-up (table)
26Patient Education & Counselling (two-column)
27Quality of Life Impact
28Recent Advances 2024-2026 (6-card grid with PMIDs)
29Key Takeaways (8 points, two-column)
30References & Thank You (dark closing slide)
Design: Navy/teal/amber palette, section header bars, card layouts, tables, and a pathogenesis flow diagram — all built in vector shapes (no internet image dependencies).
This is a shared conversation. Sign in to Orris to start your own chat.