Create a PowerPoint presentation for Section 1: Essential Physiology (Slides 2-5) Slide 2: Normal Glucose Homeostasis • Blood glucose maintained ~4-6 mmol/L (70-110 mg/dL) fasting • Sources: Dietary carbohydrates, hepatic gluconeogenesis/glycogenolysis • Key hormones: Insulin (lowers), Glucagon (raises) • Other: Cortisol, catecholamines, growth hormone (counter-regulatory) Slide 3: Role of Insulin • Produced by pancreatic beta cells • Actions: o Promotes glucose uptake (GLUT4 in muscle/adipose) o Glycogen synthesis (liver/muscle) o Inhibits lipolysis and gluconeogenesis • Anabolic hormone Slide 4: Role of Glucagon • Produced by pancreatic alpha cells • Actions: o Stimulates glycogenolysis and gluconeogenesis in liver o Promotes ketogenesis in prolonged fasting • Released in response to low blood glucose Slide 5: Pancreatic Islets and Regulation • Diagram of islets of Langerhans (beta, alpha cells) • Feedback loop: High glucose → insulin release; Low glucose → glucagon release • Postprandial vs. fasting states Section 2: Definitions and Classification (Slides 6-8) Slide 6: Definition of Diabetes Mellitus • Group of metabolic disorders characterized by chronic hyperglycemia due to defects in insulin secretion, insulin action, or both • Leads to disturbances in carbohydrate, fat, and protein metabolism Slide 7: Main Types of Diabetes • Type 1 DM (5-10%): Autoimmune beta-cell destruction → absolute insulin deficiency • Type 2 DM (90-95%): Insulin resistance + relative insulin deficiency • Gestational DM • Other: MODY, secondary (steroids, pancreatitis, etc.), prediabetes Slide 8: Diagnostic Criteria • Fasting plasma glucose ≥7.0 mmol/L (126 mg/dL) • 2h OGTT ≥11.1 mmol/L (200 mg/dL) • HbA1c ≥6.5% (48 mmol/mol) • Random glucose ≥11.1 mmol/L + symptoms • (Note: Confirm with repeat test unless symptomatic) Section 3: Pathophysiology (Slides 9-13) Slide 9: Pathophysiology of Type 1 DM • Autoimmune destruction of beta cells (T-cell mediated) • Genetic predisposition (HLA) + environmental triggers (viruses?) • Absolute insulin deficiency → hyperglycemia, lipolysis, ketogenesis Slide 10: Pathophysiology of Type 2 DM • Insulin resistance (muscle, liver, adipose) • Compensatory hyperinsulinemia initially • Progressive beta-cell dysfunction/failure • Contributing factors: Obesity, visceral fat, inflammation, genetics Slide 11: Hyperglycemia Consequences • Osmotic diuresis (polyuria, polydipsia, dehydration) • Glycosuria • Long-term: Advanced glycation end-products (AGEs), oxidative stress, vascular damage Slide 12-13: Flowcharts • One for T1DM, one for T2DM progression Section 4: Clinical Features and Natural History (Slides 14-18) Slide 14: Classic Symptoms of Hyperglycemia • Polyuria, polydipsia, polyphagia • Weight loss (especially T1) • Fatigue, blurred vision, recurrent infections • Slow-healing wounds Slide 15: Natural History of Type 1 DM • Rapid onset (weeks) • Often presents with DKA in children/young adults • Lifelong insulin dependence Slide 16: Natural History of Type 2 DM • Insidious onset (years) • Often diagnosed incidentally • Prediabetes phase → overt diabetes → complications • Strongly associated with obesity/metabolic syndrome Slide 17-18: Chronic Complications • Microvascular: Retinopathy, nephropathy, neuropathy • Macrovascular: CAD, stroke, peripheral artery disease • Others: Diabetic foot, infections, skin changes • Timeline graphic showing progression with poor control Section 5: Investigations (Slides 19-21) Slide 19: Diagnostic & Monitoring Tests • Blood glucose (fasting/random) • HbA1c (glycated hemoglobin) – reflects 2-3 months • OGTT • C-peptide/insulin levels (to differentiate T1 vs T2) • Autoantibodies (GAD, islet cell) for T1 Slide 20: Screening for Complications • Eye exam (fundoscopy/retinopathy screening) • Urine ACR (albumin-creatinine ratio) • eGFR/renal function • Lipid profile, ECG/foot exam • Neuropathy assessment Slide 21: Other Labs • Electrolytes, ketones (in illness), arterial blood gas Section 6: Management (Slides 22-28) Slide 22: General Principles • Patient education, lifestyle modification (diet, exercise, weight loss) • Glycemic targets (individualized, e.g., HbA1c <7%) • Multidisciplinary care: Dietitian, educator, podiatrist, etc. • Cardiovascular risk reduction (BP, lipids, smoking) Slide 23: Type 1 DM Management • Insulin therapy (basal-bolus, pump) • Carbohydrate counting, self-monitoring/CGM • Sick day rules Slide 24: Type 2 DM Management • Lifestyle first • Metformin (first-line) • Other orals: SGLT2i, GLP-1RA, sulfonylureas, DPP4i • Insulin if needed • Note benefits of SGLT2i/GLP-1 for CV/renal protection Slide 25: Monitoring and Follow-up • Regular HbA1c, self-monitoring • Annual complication screening Section 7: Diabetic Emergencies (Slides 26-34) Slide 26: Overview of Emergencies • Hyperglycemic: DKA, HHS • Hypoglycemia • Others: Hyperosmolar hyperglycemic state, lactic acidosis Slide 27: Diabetic Ketoacidosis (DKA) • Triad: Hyperglycemia (>11-13.9 mmol/L), ketonemia/acidosis (pH<7.3, bicarb<15), anion gap • Mostly T1DM (can occur in T2) • Precipitants: Infection, insulin omission, illness Slide 28: DKA Clinical Features • Polyuria/polydipsia, nausea/vomiting, abdominal pain • Kussmaul breathing, fruity breath (acetone) • Dehydration, altered mental status/coma Slide 29: HHS (Hyperosmolar Hyperglycemic State) • Severe hyperglycemia (>33 mmol/L), hyperosmolality (>320 mOsm), profound dehydration • Minimal/no ketoacidosis • Mostly elderly T2DM, insidious onset (days-weeks) • Higher mortality than DKA Slide 30: Hypoglycemia • Blood glucose <4 mmol/L (or <3.9 with symptoms) • Causes: Excess insulin/meds, missed meals, exercise • Symptoms: Adrenergic (sweating, tremor) + neuroglycopenic (confusion, seizure) Slide 31-32: Management of DKA/HHS • ABC, fluids (normal saline initially), insulin (after K+ check), electrolytes (esp. potassium), treat precipitant • Monitoring: Hourly glucose, electrolytes, gap closure • Key differences table (DKA vs HHS) Slide 33: Hypoglycemia Management • Conscious: Oral carbs (15g) • Unconscious: IV dextrose or IM glucagon • Prevent recurrence Slide 34: Prevention of Emergencies • Education, sick day rules, access to supplies, regular follow-up Conclusion & References (Slides 35-36) • Summary key points • Importance of early diagnosis, tight control, and education • References (ADA, NICE, or key sources) • Q&A slide Additional Tips for Creation: • Use simple diagrams (glucose regulation loop, DKA pathway). • Include tables for comparisons (DKA vs HHS, T1 vs T2). • Add high-yield images: Fundus photo of retinopathy, foot ulcer (with sensitivity). • Total timing: 30-45 minutes presentation. • Sources: Base on guidelines (e.g., ADA, WHO) for accuracy.

Reading File
Reading File
Reading File
Running Command

Give me the script

Here is the complete PptxGenJS script for the full 36-slide Diabetes Mellitus presentation:
// Diabetes Mellitus Presentation
// Run: node diabetes.js
// Requires: npm install pptxgenjs (or use pre-installed version)

const pptxgen = require("pptxgenjs");
const pres = new pptxgen();

pres.layout = "LAYOUT_16x9";
pres.title = "Diabetes Mellitus: Physiology, Pathophysiology & Management";
pres.author = "Medical Education";

// ─── THEME COLORS ───────────────────────────────────────────────────────────
const C = {
  navy:    "0A2342",   // dominant background
  teal:    "00848E",   // accent headers
  cyan:    "00C9D7",   // highlight / bullets
  white:   "FFFFFF",
  light:   "E8F6F7",   // light card bg
  gray:    "B0BEC5",
  red:     "E53935",
  amber:   "FFB300",
  green:   "2E7D32",
  darkTeal:"006670",
  muted:   "CFD8DC",
  charcoal:"1C3A4A",
};

// ─── MASTER HELPERS ──────────────────────────────────────────────────────────

/** Full-bleed navy background */
function navyBg(slide) {
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0, y: 0, w: 10, h: 5.625,
    fill: { color: C.navy }, line: { color: C.navy },
  });
}

/** Teal accent bar at top (under a header area) */
function topBar(slide, color = C.teal) {
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0, y: 0, w: 10, h: 0.08,
    fill: { color: color }, line: { color: color },
  });
}

/** Bottom footer strip */
function footer(slide, label = "") {
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0, y: 5.35, w: 10, h: 0.27,
    fill: { color: C.teal }, line: { color: C.teal },
  });
  if (label) {
    slide.addText(label, {
      x: 0.2, y: 5.35, w: 9.6, h: 0.27,
      fontSize: 9, color: C.white, valign: "middle", align: "left",
      bold: false, margin: 0,
    });
  }
}

/** Standard content slide shell: navy bg + teal accent + title */
function contentShell(slide, title, footerLabel = "Diabetes Mellitus | Medical Education") {
  navyBg(slide);
  // left accent bar
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0, y: 0, w: 0.07, h: 5.625,
    fill: { color: C.cyan }, line: { color: C.cyan },
  });
  // Title band
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0.07, y: 0, w: 9.93, h: 0.82,
    fill: { color: C.charcoal }, line: { color: C.charcoal },
  });
  slide.addText(title, {
    x: 0.25, y: 0, w: 9.5, h: 0.82,
    fontSize: 22, bold: true, color: C.cyan,
    valign: "middle", align: "left", margin: 0,
  });
  footer(slide, footerLabel);
}

/** Bullet list helper — returns pptxgen text array */
function bullets(items, fontSize = 14, color = C.white, indent = false) {
  return items.map((item, i) => ({
    text: item,
    options: {
      bullet: { code: indent ? "2013" : "25CF", color: C.cyan },
      fontSize,
      color,
      breakLine: i < items.length - 1,
      indentLevel: indent ? 1 : 0,
    },
  }));
}

/** Section divider slide */
function sectionDivider(title, subtitle, sectionNum) {
  const slide = pres.addSlide();
  navyBg(slide);
  // Large teal rectangle left panel
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0, y: 0, w: 3.5, h: 5.625,
    fill: { color: C.teal }, line: { color: C.teal },
  });
  slide.addText(`SECTION\n${sectionNum}`, {
    x: 0, y: 1.5, w: 3.5, h: 2,
    fontSize: 38, bold: true, color: C.white,
    align: "center", valign: "middle", margin: 0,
  });
  slide.addText(title, {
    x: 3.8, y: 1.5, w: 5.8, h: 1.2,
    fontSize: 28, bold: true, color: C.cyan,
    align: "left", valign: "bottom", margin: 0,
  });
  slide.addText(subtitle, {
    x: 3.8, y: 2.75, w: 5.8, h: 1.5,
    fontSize: 14, color: C.muted,
    align: "left", valign: "top", margin: 0,
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 1 — TITLE SLIDE
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  navyBg(slide);

  // Cyan diagonal accent shape (top-right)
  slide.addShape(pres.shapes.RIGHT_TRIANGLE, {
    x: 7, y: 0, w: 3, h: 2.5,
    fill: { color: C.teal }, line: { color: C.teal },
    flipH: true,
  });

  // Bottom teal bar
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0, y: 4.9, w: 10, h: 0.725,
    fill: { color: C.teal }, line: { color: C.teal },
  });

  slide.addText("DIABETES MELLITUS", {
    x: 0.5, y: 0.9, w: 9, h: 1.0,
    fontSize: 40, bold: true, color: C.cyan,
    align: "center", charSpacing: 4, margin: 0,
  });
  slide.addText("Physiology, Pathophysiology, Classification\nClinical Features & Management", {
    x: 0.5, y: 2.0, w: 9, h: 1.1,
    fontSize: 18, color: C.white, align: "center",
    italic: false, margin: 0,
  });
  slide.addText("Based on ADA, WHO & NICE Guidelines", {
    x: 0.5, y: 3.2, w: 9, h: 0.5,
    fontSize: 12, color: C.gray, align: "center", italic: true, margin: 0,
  });
  slide.addText("Medical Education  |  2026", {
    x: 0, y: 4.9, w: 10, h: 0.725,
    fontSize: 13, color: C.white, align: "center", valign: "middle", bold: true, margin: 0,
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SECTION 1 DIVIDER — Essential Physiology
// ════════════════════════════════════════════════════════════════════════════
sectionDivider("Essential Physiology", "Normal glucose homeostasis, insulin, glucagon\nand pancreatic regulation", "1");

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 2 — Normal Glucose Homeostasis
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Normal Glucose Homeostasis");

  // Two columns
  // Left column — bullets
  slide.addText([
    ...bullets(["Blood glucose maintained ~4–6 mmol/L (70–110 mg/dL) fasting"], 14),
  ], { x: 0.25, y: 0.95, w: 4.7, h: 0.55, margin: 0 });

  // Sources card
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.2, y: 1.6, w: 4.5, h: 1.1,
    fill: { color: C.charcoal }, line: { color: C.teal }, rectRadius: 0.08,
  });
  slide.addText("GLUCOSE SOURCES", {
    x: 0.35, y: 1.65, w: 4.1, h: 0.3,
    fontSize: 10, bold: true, color: C.cyan, margin: 0,
  });
  slide.addText([
    ...bullets(["Dietary carbohydrates", "Hepatic gluconeogenesis", "Hepatic glycogenolysis"], 13),
  ], { x: 0.35, y: 1.93, w: 4.1, h: 0.7, margin: 0 });

  // Key hormones card
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.2, y: 2.8, w: 4.5, h: 1.25,
    fill: { color: C.charcoal }, line: { color: C.amber }, rectRadius: 0.08,
  });
  slide.addText("KEY HORMONES", {
    x: 0.35, y: 2.85, w: 4.1, h: 0.3,
    fontSize: 10, bold: true, color: C.amber, margin: 0,
  });
  slide.addText([
    { text: "Insulin", options: { bold: true, color: C.cyan, fontSize: 13, breakLine: false } },
    { text: "  — lowers blood glucose", options: { color: C.white, fontSize: 13, breakLine: true } },
    { text: "Glucagon", options: { bold: true, color: C.amber, fontSize: 13, breakLine: false } },
    { text: "  — raises blood glucose", options: { color: C.white, fontSize: 13, breakLine: true } },
    { text: "Counter-regulatory: ", options: { bold: true, color: C.gray, fontSize: 12, breakLine: false } },
    { text: "Cortisol, catecholamines, GH", options: { color: C.muted, fontSize: 12 } },
  ], { x: 0.35, y: 3.13, w: 4.1, h: 0.85, margin: 0 });

  // Right — Glucose loop diagram (drawn shapes)
  // Circle: hyperglycemia
  slide.addShape(pres.shapes.OVAL, {
    x: 5.5, y: 1.0, w: 1.9, h: 0.7,
    fill: { color: C.red }, line: { color: C.red },
  });
  slide.addText("High Glucose", { x: 5.5, y: 1.0, w: 1.9, h: 0.7, fontSize: 10, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });

  // Arrow down → insulin released
  slide.addShape(pres.shapes.RECTANGLE, { x: 6.3, y: 1.72, w: 0.08, h: 0.5, fill: { color: C.cyan }, line: { color: C.cyan } });
  slide.addText("▼ Insulin released", { x: 5.5, y: 2.15, w: 1.9, h: 0.35, fontSize: 9, color: C.cyan, align: "center", margin: 0 });

  // Circle: normoglycemia
  slide.addShape(pres.shapes.OVAL, {
    x: 5.5, y: 2.55, w: 1.9, h: 0.7,
    fill: { color: C.green }, line: { color: C.green },
  });
  slide.addText("Normoglycemia\n4–6 mmol/L", { x: 5.5, y: 2.55, w: 1.9, h: 0.7, fontSize: 9, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });

  // Arrow down → glucagon released
  slide.addShape(pres.shapes.RECTANGLE, { x: 6.3, y: 3.27, w: 0.08, h: 0.5, fill: { color: C.amber }, line: { color: C.amber } });
  slide.addText("▼ Glucagon released", { x: 5.5, y: 3.7, w: 1.9, h: 0.35, fontSize: 9, color: C.amber, align: "center", margin: 0 });

  // Circle: hypoglycemia
  slide.addShape(pres.shapes.OVAL, {
    x: 5.5, y: 4.1, w: 1.9, h: 0.7,
    fill: { color: C.darkTeal }, line: { color: C.darkTeal },
  });
  slide.addText("Low Glucose", { x: 5.5, y: 4.1, w: 1.9, h: 0.7, fontSize: 10, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });

  // Connecting label
  slide.addText("Feedback Loop", { x: 7.6, y: 2.6, w: 2, h: 0.4, fontSize: 11, bold: true, color: C.teal, align: "center", margin: 0 });
  slide.addShape(pres.shapes.RECTANGLE, { x: 7.55, y: 3.0, w: 0.08, h: 0.08, fill: { color: C.teal }, line: { color: C.teal } });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 3 — Role of Insulin
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Role of Insulin");

  // Source pill
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.2, y: 0.92, w: 3.2, h: 0.42,
    fill: { color: C.teal }, line: { color: C.teal }, rectRadius: 0.15,
  });
  slide.addText("Produced by Pancreatic β-cells", {
    x: 0.2, y: 0.92, w: 3.2, h: 0.42,
    fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 0,
  });

  // Actions header
  slide.addText("ACTIONS OF INSULIN", {
    x: 0.25, y: 1.5, w: 9, h: 0.35,
    fontSize: 13, bold: true, color: C.cyan, margin: 0,
  });

  // Three action cards
  const actions = [
    { title: "Glucose Uptake", body: "Promotes glucose uptake via\nGLUT4 transporters in muscle\nand adipose tissue", color: C.teal },
    { title: "Glycogen Synthesis", body: "Stimulates glycogen storage\nin liver and muscle;\nsuppresses gluconeogenesis", color: C.darkTeal },
    { title: "Anti-Lipolytic", body: "Inhibits lipolysis in adipose;\nprevents free fatty acid\nrelease and ketogenesis", color: C.charcoal },
  ];

  actions.forEach((a, i) => {
    const x = 0.2 + i * 3.2;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 1.95, w: 3.0, h: 2.3,
      fill: { color: a.color }, line: { color: C.cyan }, rectRadius: 0.1,
    });
    slide.addText(a.title, {
      x, y: 2.0, w: 3.0, h: 0.45,
      fontSize: 13, bold: true, color: C.cyan, align: "center", valign: "middle", margin: 0,
    });
    slide.addShape(pres.shapes.RECTANGLE, {
      x: x + 0.5, y: 2.46, w: 2.0, h: 0.04,
      fill: { color: C.cyan }, line: { color: C.cyan },
    });
    slide.addText(a.body, {
      x, y: 2.55, w: 3.0, h: 1.55,
      fontSize: 12, color: C.white, align: "center", valign: "top", margin: 0,
    });
  });

  // Anabolic banner
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0.2, y: 4.45, w: 9.5, h: 0.55,
    fill: { color: C.green }, line: { color: C.green },
  });
  slide.addText("★  ANABOLIC HORMONE — promotes energy storage; major driver of nutrient metabolism", {
    x: 0.2, y: 4.45, w: 9.5, h: 0.55,
    fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0,
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 4 — Role of Glucagon
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Role of Glucagon");

  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.2, y: 0.92, w: 3.2, h: 0.42,
    fill: { color: C.amber }, line: { color: C.amber }, rectRadius: 0.15,
  });
  slide.addText("Produced by Pancreatic α-cells", {
    x: 0.2, y: 0.92, w: 3.2, h: 0.42,
    fontSize: 11, bold: true, color: C.navy, align: "center", valign: "middle", margin: 0,
  });

  slide.addText("ACTIONS OF GLUCAGON", {
    x: 0.25, y: 1.5, w: 9, h: 0.35,
    fontSize: 13, bold: true, color: C.amber, margin: 0,
  });

  const gActions = [
    { title: "Glycogenolysis", body: "Breaks down hepatic glycogen\nto release glucose into\nthe bloodstream", color: C.charcoal },
    { title: "Gluconeogenesis", body: "Stimulates new glucose\nsynthesis from amino acids\nand lactate in liver", color: C.darkTeal },
    { title: "Ketogenesis", body: "Promotes ketone body\nproduction during\nprolonged fasting", color: C.charcoal },
  ];

  gActions.forEach((a, i) => {
    const x = 0.2 + i * 3.2;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 1.95, w: 3.0, h: 2.2,
      fill: { color: a.color }, line: { color: C.amber }, rectRadius: 0.1,
    });
    slide.addText(a.title, {
      x, y: 2.0, w: 3.0, h: 0.45,
      fontSize: 13, bold: true, color: C.amber, align: "center", valign: "middle", margin: 0,
    });
    slide.addShape(pres.shapes.RECTANGLE, {
      x: x + 0.5, y: 2.46, w: 2.0, h: 0.04,
      fill: { color: C.amber }, line: { color: C.amber },
    });
    slide.addText(a.body, {
      x, y: 2.55, w: 3.0, h: 1.5,
      fontSize: 12, color: C.white, align: "center", valign: "top", margin: 0,
    });
  });

  // Trigger banner
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0.2, y: 4.4, w: 9.5, h: 0.55,
    fill: { color: C.amber }, line: { color: C.amber },
  });
  slide.addText("Released in response to LOW blood glucose  |  Opposes insulin action  |  Catabolic hormone", {
    x: 0.2, y: 4.4, w: 9.5, h: 0.55,
    fontSize: 12, bold: true, color: C.navy, align: "center", valign: "middle", margin: 0,
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 5 — Pancreatic Islets & Regulation
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Pancreatic Islets & Regulation");

  // Left: islet diagram (drawn)
  slide.addShape(pres.shapes.OVAL, {
    x: 0.3, y: 0.95, w: 4.2, h: 3.0,
    fill: { color: C.charcoal }, line: { color: C.cyan, pt: 2 },
  });
  slide.addText("Islet of\nLangerhans", { x: 0.3, y: 1.05, w: 4.2, h: 0.6, fontSize: 11, bold: true, color: C.cyan, align: "center", margin: 0 });

  // β-cell circles
  [{ x: 1.0, y: 1.75 }, { x: 1.9, y: 1.7 }, { x: 2.8, y: 1.75 }, { x: 1.45, y: 2.4 }, { x: 2.35, y: 2.4 }].forEach(p => {
    slide.addShape(pres.shapes.OVAL, { x: p.x, y: p.y, w: 0.6, h: 0.6, fill: { color: C.teal }, line: { color: C.white } });
    slide.addText("β", { x: p.x, y: p.y, w: 0.6, h: 0.6, fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
  });
  // α-cell circles (peripheral)
  [{ x: 0.55, y: 2.55 }, { x: 3.35, y: 2.55 }, { x: 1.0, y: 3.15 }, { x: 2.75, y: 3.15 }].forEach(p => {
    slide.addShape(pres.shapes.OVAL, { x: p.x, y: p.y, w: 0.6, h: 0.6, fill: { color: C.amber }, line: { color: C.white } });
    slide.addText("α", { x: p.x, y: p.y, w: 0.6, h: 0.6, fontSize: 11, bold: true, color: C.navy, align: "center", valign: "middle", margin: 0 });
  });

  // Legend
  slide.addShape(pres.shapes.OVAL, { x: 0.4, y: 4.1, w: 0.3, h: 0.3, fill: { color: C.teal }, line: { color: C.white } });
  slide.addText("β-cells: Insulin", { x: 0.75, y: 4.1, w: 1.8, h: 0.3, fontSize: 11, color: C.teal, margin: 0 });
  slide.addShape(pres.shapes.OVAL, { x: 2.7, y: 4.1, w: 0.3, h: 0.3, fill: { color: C.amber }, line: { color: C.white } });
  slide.addText("α-cells: Glucagon", { x: 3.05, y: 4.1, w: 1.8, h: 0.3, fontSize: 11, color: C.amber, margin: 0 });

  // Right: feedback table
  const rows = [
    ["State", "Glucose", "Dominant Hormone", "Effect"],
    ["Postprandial", "High ↑", "Insulin (β-cells)", "Uptake, storage"],
    ["Fasting", "Low ↓", "Glucagon (α-cells)", "Release, synthesis"],
    ["Exercise/Stress", "Variable", "Catecholamines, GH", "Counter-regulatory"],
  ];
  slide.addTable(rows, {
    x: 4.7, y: 0.92, w: 5.0, h: 2.8,
    fontSize: 10,
    color: C.white,
    fill: { color: C.navy },
    border: { type: "solid", color: C.teal, pt: 1 },
    rowH: 0.55,
    fontFace: "Calibri",
    align: "center",
    valign: "middle",
    colW: [1.2, 0.9, 1.6, 1.3],
  });

  // Feedback note
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 4.7, y: 3.85, w: 5.0, h: 1.15,
    fill: { color: C.charcoal }, line: { color: C.cyan }, rectRadius: 0.08,
  });
  slide.addText([
    { text: "Feedback Principle: ", options: { bold: true, color: C.cyan, fontSize: 12, breakLine: false } },
    { text: "Glucose sensors in pancreatic islets detect blood glucose changes and adjust hormone secretion in a tight negative feedback loop to maintain euglycemia.", options: { color: C.white, fontSize: 11 } },
  ], { x: 4.85, y: 3.9, w: 4.7, h: 1.05, margin: 0, valign: "middle" });
}

// ════════════════════════════════════════════════════════════════════════════
// SECTION 2 DIVIDER — Definitions & Classification
// ════════════════════════════════════════════════════════════════════════════
sectionDivider("Definitions & Classification", "Definition of diabetes, types, and diagnostic criteria", "2");

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 6 — Definition of Diabetes Mellitus
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Definition of Diabetes Mellitus");

  // Large definition card
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.3, y: 0.95, w: 9.3, h: 1.7,
    fill: { color: C.charcoal }, line: { color: C.cyan, pt: 2 }, rectRadius: 0.1,
  });
  slide.addText([
    { text: "Diabetes Mellitus", options: { bold: true, color: C.cyan, fontSize: 17, breakLine: true } },
    { text: "A group of metabolic disorders characterised by ", options: { color: C.white, fontSize: 14, breakLine: false } },
    { text: "chronic hyperglycaemia", options: { bold: true, color: C.amber, fontSize: 14, breakLine: false } },
    { text: " due to defects in insulin secretion, insulin action, or both.", options: { color: C.white, fontSize: 14 } },
  ], { x: 0.5, y: 0.98, w: 9.0, h: 1.6, valign: "middle", margin: 0 });

  // Consequences row
  slide.addText("METABOLIC CONSEQUENCES", {
    x: 0.3, y: 2.8, w: 9, h: 0.35,
    fontSize: 12, bold: true, color: C.teal, margin: 0,
  });

  const consequences = [
    { icon: "🍬", title: "Carbohydrate", body: "Impaired glucose uptake\nand utilisation" },
    { icon: "🧈", title: "Fat", body: "Increased lipolysis,\nketogenesis, dyslipidaemia" },
    { icon: "🥩", title: "Protein", body: "Catabolism, impaired\nwound healing, muscle loss" },
  ];

  consequences.forEach((c, i) => {
    const x = 0.3 + i * 3.15;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 3.2, w: 3.0, h: 1.75,
      fill: { color: C.charcoal }, line: { color: C.teal }, rectRadius: 0.1,
    });
    slide.addText(c.icon + "  " + c.title + " Metabolism", {
      x, y: 3.25, w: 3.0, h: 0.45,
      fontSize: 12, bold: true, color: C.cyan, align: "center", margin: 0,
    });
    slide.addText(c.body, {
      x, y: 3.72, w: 3.0, h: 1.1,
      fontSize: 12, color: C.white, align: "center", valign: "top", margin: 0,
    });
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 7 — Main Types of Diabetes
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Main Types of Diabetes");

  const types = [
    { label: "Type 1 DM", pct: "5–10%", desc: "Autoimmune β-cell\ndestruction → absolute\ninsulin deficiency", color: C.red },
    { label: "Type 2 DM", pct: "90–95%", desc: "Insulin resistance +\nrelative insulin deficiency;\nstrongly linked to obesity", color: C.teal },
    { label: "Gestational\nDM", pct: "~7–10%*", desc: "Glucose intolerance first\ndetected during pregnancy;\nresolves postpartum", color: C.amber },
    { label: "Other Types", pct: "Rare", desc: "MODY, steroid-induced,\npancreatitis, secondary\ncauses, prediabetes", color: C.darkTeal },
  ];

  types.forEach((t, i) => {
    const x = 0.2 + i * 2.4;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 0.9, w: 2.25, h: 4.1,
      fill: { color: C.charcoal }, line: { color: t.color, pt: 2 }, rectRadius: 0.1,
    });
    // Color header
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 0.9, w: 2.25, h: 0.8,
      fill: { color: t.color }, line: { color: t.color }, rectRadius: 0.1,
    });
    slide.addText(t.label, {
      x, y: 0.9, w: 2.25, h: 0.8,
      fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0,
    });
    // Percentage badge
    slide.addShape(pres.shapes.OVAL, {
      x: x + 0.6, y: 1.77, w: 1.05, h: 0.55,
      fill: { color: C.navy }, line: { color: t.color },
    });
    slide.addText(t.pct, {
      x: x + 0.6, y: 1.77, w: 1.05, h: 0.55,
      fontSize: 10, bold: true, color: t.color, align: "center", valign: "middle", margin: 0,
    });
    slide.addText(t.desc, {
      x, y: 2.42, w: 2.25, h: 2.3,
      fontSize: 11, color: C.white, align: "center", valign: "top", margin: 4,
    });
  });

  slide.addText("* Gestational DM prevalence varies by population and diagnostic criteria", {
    x: 0.2, y: 5.05, w: 9.5, h: 0.25,
    fontSize: 9, color: C.gray, italic: true, margin: 0,
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 8 — Diagnostic Criteria
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Diagnostic Criteria for Diabetes");

  const criteria = [
    { test: "Fasting Plasma Glucose", threshold: "≥7.0 mmol/L", alt: "(≥126 mg/dL)", note: "No caloric intake ≥8h" },
    { test: "2h OGTT Glucose", threshold: "≥11.1 mmol/L", alt: "(≥200 mg/dL)", note: "75g glucose load" },
    { test: "HbA1c", threshold: "≥6.5%", alt: "(≥48 mmol/mol)", note: "Reflects 2–3 month avg" },
    { test: "Random Glucose + Symptoms", threshold: "≥11.1 mmol/L", alt: "(≥200 mg/dL)", note: "Classic symptoms required" },
  ];

  criteria.forEach((c, i) => {
    const y = 0.95 + i * 0.98;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x: 0.2, y, w: 9.4, h: 0.85,
      fill: { color: C.charcoal }, line: { color: C.teal }, rectRadius: 0.07,
    });
    // Number badge
    slide.addShape(pres.shapes.OVAL, {
      x: 0.28, y: y + 0.13, w: 0.58, h: 0.58,
      fill: { color: C.teal }, line: { color: C.teal },
    });
    slide.addText(`${i + 1}`, {
      x: 0.28, y: y + 0.13, w: 0.58, h: 0.58,
      fontSize: 14, bold: true, color: C.white, align: "center", valign: "middle", margin: 0,
    });
    slide.addText(c.test, {
      x: 1.0, y: y + 0.03, w: 3.8, h: 0.43,
      fontSize: 13, bold: true, color: C.white, valign: "bottom", margin: 0,
    });
    slide.addText(c.note, {
      x: 1.0, y: y + 0.47, w: 3.8, h: 0.33,
      fontSize: 10, color: C.gray, valign: "top", italic: true, margin: 0,
    });
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x: 5.2, y: y + 0.1, w: 2.5, h: 0.62,
      fill: { color: C.red }, line: { color: C.red }, rectRadius: 0.08,
    });
    slide.addText(c.threshold, {
      x: 5.2, y: y + 0.1, w: 2.5, h: 0.62,
      fontSize: 14, bold: true, color: C.white, align: "center", valign: "middle", margin: 0,
    });
    slide.addText(c.alt, {
      x: 7.8, y: y + 0.2, w: 1.7, h: 0.4,
      fontSize: 11, color: C.muted, align: "left", valign: "middle", margin: 0,
    });
  });

  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0.2, y: 4.9, w: 9.4, h: 0.35,
    fill: { color: C.amber }, line: { color: C.amber },
  });
  slide.addText("⚠  Confirm with a repeat test on a separate day unless the patient is symptomatic with unequivocal hyperglycaemia", {
    x: 0.2, y: 4.9, w: 9.4, h: 0.35,
    fontSize: 10, bold: true, color: C.navy, align: "center", valign: "middle", margin: 0,
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SECTION 3 DIVIDER — Pathophysiology
// ════════════════════════════════════════════════════════════════════════════
sectionDivider("Pathophysiology", "Type 1, Type 2, consequences of hyperglycaemia\nand disease progression flowcharts", "3");

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 9 — Pathophysiology of Type 1 DM
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Pathophysiology of Type 1 DM");

  // T1 pathway — horizontal flowchart
  const steps = [
    { label: "Genetic\nPredisposition", sub: "HLA-DR3/DR4", color: C.charcoal },
    { label: "Environmental\nTrigger", sub: "Viral infection?", color: C.charcoal },
    { label: "Autoimmune\nActivation", sub: "T-cell mediated", color: C.red },
    { label: "β-Cell\nDestruction", sub: ">80% lost", color: C.red },
    { label: "Absolute Insulin\nDeficiency", sub: "Zero endogenous", color: C.darkTeal },
  ];

  const bw = 1.55, bh = 1.3, by = 1.15;
  steps.forEach((s, i) => {
    const x = 0.2 + i * 1.92;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: by, w: bw, h: bh,
      fill: { color: s.color }, line: { color: C.cyan }, rectRadius: 0.08,
    });
    slide.addText(s.label, { x, y: by + 0.05, w: bw, h: 0.7, fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText(s.sub, { x, y: by + 0.8, w: bw, h: 0.4, fontSize: 10, color: C.cyan, align: "center", margin: 0, italic: true });
    if (i < steps.length - 1) {
      slide.addText("▶", { x: x + bw - 0.05, y: by + 0.45, w: 0.45, h: 0.45, fontSize: 16, color: C.cyan, align: "center", valign: "middle", margin: 0 });
    }
  });

  // Consequences
  slide.addText("CONSEQUENCES", { x: 0.2, y: 2.65, w: 9, h: 0.35, fontSize: 12, bold: true, color: C.teal, margin: 0 });

  const cons = [
    { t: "Hyperglycaemia", d: "Osmotic symptoms\n(polyuria, polydipsia)", c: C.red },
    { t: "Lipolysis", d: "Free fatty acid\nrelease, weight loss", c: C.amber },
    { t: "Ketogenesis", d: "DKA risk;\nketonuria, acidosis", c: C.red },
    { t: "Catabolism", d: "Muscle wasting,\nfatigue, weakness", c: C.darkTeal },
  ];

  cons.forEach((c, i) => {
    const x = 0.2 + i * 2.38;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 3.07, w: 2.2, h: 1.95,
      fill: { color: C.charcoal }, line: { color: c.c }, rectRadius: 0.08,
    });
    slide.addText(c.t, { x, y: 3.12, w: 2.2, h: 0.45, fontSize: 12, bold: true, color: c.c, align: "center", valign: "middle", margin: 0 });
    slide.addText(c.d, { x, y: 3.6, w: 2.2, h: 1.3, fontSize: 11, color: C.white, align: "center", valign: "top", margin: 0 });
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 10 — Pathophysiology of Type 2 DM
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Pathophysiology of Type 2 DM");

  // Left: text
  slide.addText([
    ...bullets(["Peripheral insulin resistance (muscle, liver, adipose)"], 13),
  ], { x: 0.2, y: 1.0, w: 5.5, h: 0.45, margin: 0 });
  slide.addText([
    ...bullets(["Compensatory hyperinsulinaemia — β-cells work harder"], 13),
  ], { x: 0.2, y: 1.48, w: 5.5, h: 0.45, margin: 0 });
  slide.addText([
    ...bullets(["Progressive β-cell dysfunction and eventual failure"], 13),
  ], { x: 0.2, y: 1.96, w: 5.5, h: 0.45, margin: 0 });

  // Contributing factors
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.2, y: 2.55, w: 5.2, h: 2.5,
    fill: { color: C.charcoal }, line: { color: C.teal }, rectRadius: 0.08,
  });
  slide.addText("CONTRIBUTING FACTORS", { x: 0.3, y: 2.6, w: 5.0, h: 0.35, fontSize: 11, bold: true, color: C.teal, margin: 0 });
  slide.addText([
    ...bullets(["Obesity and visceral adiposity", "Chronic low-grade inflammation (TNF-α, IL-6)", "Ectopic lipid deposition in liver/muscle", "Genetic susceptibility (polygenic)", "Sedentary lifestyle, high caloric diet", "Ageing"], 12),
  ], { x: 0.3, y: 3.0, w: 4.9, h: 1.9, margin: 0 });

  // Right: Staircase progression diagram
  slide.addText("Disease Progression", { x: 5.7, y: 0.9, w: 4.0, h: 0.35, fontSize: 12, bold: true, color: C.cyan, margin: 0 });
  const stages = [
    { label: "Normal\nGlucose", color: C.green },
    { label: "Insulin\nResistance", color: C.amber },
    { label: "Pre-\nDiabetes", color: C.amber },
    { label: "Type 2\nDiabetes", color: C.red },
    { label: "Complications", color: C.red },
  ];
  stages.forEach((s, i) => {
    const x = 5.7 + i * 0.82;
    const y = 4.8 - i * 0.65;
    slide.addShape(pres.shapes.RECTANGLE, {
      x, y, w: 0.75, h: 0.65 * (i + 1),
      fill: { color: s.color }, line: { color: s.color },
    });
    slide.addText(s.label, {
      x, y: y - 0.45, w: 0.75, h: 0.42,
      fontSize: 8, bold: true, color: s.color, align: "center", margin: 0,
    });
  });
  slide.addText("Time →", { x: 5.7, y: 5.05, w: 4.0, h: 0.25, fontSize: 10, color: C.gray, align: "right", margin: 0 });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 11 — Consequences of Hyperglycaemia
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Consequences of Hyperglycaemia");

  // Acute consequences
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.2, y: 0.92, w: 4.4, h: 3.85,
    fill: { color: C.charcoal }, line: { color: C.amber, pt: 2 }, rectRadius: 0.08,
  });
  slide.addText("ACUTE", { x: 0.2, y: 0.92, w: 4.4, h: 0.45, fontSize: 14, bold: true, color: C.amber, align: "center", valign: "middle", margin: 0 });
  slide.addText([
    ...bullets(["Osmotic diuresis → polyuria", "Polydipsia (compensatory thirst)", "Dehydration and electrolyte loss", "Glycosuria (glucose in urine)", "Fatigue, blurred vision", "DKA / HHS in extremes"], 12),
  ], { x: 0.35, y: 1.42, w: 4.1, h: 3.2, margin: 0 });

  // Chronic consequences
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 5.1, y: 0.92, w: 4.65, h: 3.85,
    fill: { color: C.charcoal }, line: { color: C.red, pt: 2 }, rectRadius: 0.08,
  });
  slide.addText("CHRONIC", { x: 5.1, y: 0.92, w: 4.65, h: 0.45, fontSize: 14, bold: true, color: C.red, align: "center", valign: "middle", margin: 0 });
  slide.addText([
    ...bullets([
      "Advanced Glycation End-Products (AGEs)",
      "Oxidative stress & ROS production",
      "Protein kinase C activation",
      "Polyol pathway activation",
      "Endothelial dysfunction",
      "Vascular damage → micro & macrovascular disease",
    ], 12),
  ], { x: 5.25, y: 1.42, w: 4.35, h: 3.2, margin: 0 });

  slide.addShape(pres.shapes.RECTANGLE, {
    x: 4.73, y: 0.92, w: 0.08, h: 3.85,
    fill: { color: C.cyan }, line: { color: C.cyan },
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 12 — T1DM Flowchart
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "T1DM — Pathophysiology Flowchart");

  const nodes = [
    { x: 3.8, y: 0.95, w: 2.4, h: 0.55, label: "Genetic Susceptibility\n(HLA-DR3/DR4)", color: C.charcoal, border: C.cyan },
    { x: 3.8, y: 1.75, w: 2.4, h: 0.55, label: "Environmental Trigger\n(Viral / Unknown)", color: C.charcoal, border: C.teal },
    { x: 3.8, y: 2.55, w: 2.4, h: 0.55, label: "T-Cell Activation\n(Autoimmune response)", color: C.charcoal, border: C.amber },
    { x: 3.8, y: 3.35, w: 2.4, h: 0.55, label: "β-Cell Destruction\n(Insulitis)", color: C.red, border: C.red },
    { x: 3.8, y: 4.15, w: 2.4, h: 0.55, label: "Absolute Insulin\nDeficiency", color: C.red, border: C.red },
  ];

  nodes.forEach((n, i) => {
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x: n.x, y: n.y, w: n.w, h: n.h,
      fill: { color: n.color }, line: { color: n.border, pt: 1.5 }, rectRadius: 0.07,
    });
    slide.addText(n.label, {
      x: n.x, y: n.y, w: n.w, h: n.h,
      fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 2,
    });
    if (i < nodes.length - 1) {
      slide.addText("▼", { x: n.x + n.w / 2 - 0.15, y: n.y + n.h - 0.02, w: 0.3, h: 0.25, fontSize: 14, color: C.cyan, align: "center", margin: 0 });
    }
  });

  // Side consequences from "Absolute Insulin Deficiency"
  const cons2 = [
    { x: 0.3, y: 3.8, w: 1.9, h: 0.55, label: "Hyperglycaemia", color: C.amber },
    { x: 0.3, y: 4.55, w: 1.9, h: 0.55, label: "DKA", color: C.red },
    { x: 7.6, y: 3.8, w: 1.9, h: 0.55, label: "Lipolysis", color: C.amber },
    { x: 7.6, y: 4.55, w: 1.9, h: 0.55, label: "Ketogenesis", color: C.red },
  ];
  cons2.forEach(c => {
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x: c.x, y: c.y, w: c.w, h: c.h,
      fill: { color: c.color }, line: { color: c.color }, rectRadius: 0.07,
    });
    slide.addText(c.label, {
      x: c.x, y: c.y, w: c.w, h: c.h,
      fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0,
    });
  });
  // arrows to side
  slide.addText("◀", { x: 2.2, y: 4.35, w: 0.3, h: 0.3, fontSize: 14, color: C.amber, align: "center", margin: 0 });
  slide.addText("▶", { x: 7.3, y: 4.35, w: 0.3, h: 0.3, fontSize: 14, color: C.amber, align: "center", margin: 0 });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 13 — T2DM Flowchart
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "T2DM — Progression Flowchart");

  const t2nodes = [
    { x: 3.8, y: 0.92, w: 2.4, h: 0.55, label: "Obesity / Sedentary\nLifestyle + Genetics", color: C.charcoal, border: C.cyan },
    { x: 3.8, y: 1.7, w: 2.4, h: 0.55, label: "Insulin Resistance\n(Muscle, Liver, Adipose)", color: C.charcoal, border: C.teal },
    { x: 3.8, y: 2.48, w: 2.4, h: 0.55, label: "Compensatory\nHyperinsulinaemia", color: C.charcoal, border: C.amber },
    { x: 3.8, y: 3.26, w: 2.4, h: 0.55, label: "β-Cell Exhaustion\n& Dysfunction", color: C.amber, border: C.amber },
    { x: 3.8, y: 4.04, w: 2.4, h: 0.55, label: "Overt Type 2 DM\n(Relative Insulin Deficiency)", color: C.red, border: C.red },
  ];

  t2nodes.forEach((n, i) => {
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x: n.x, y: n.y, w: n.w, h: n.h,
      fill: { color: n.color }, line: { color: n.border, pt: 1.5 }, rectRadius: 0.07,
    });
    slide.addText(n.label, {
      x: n.x, y: n.y, w: n.w, h: n.h,
      fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 2,
    });
    if (i < t2nodes.length - 1) {
      slide.addText("▼", { x: n.x + n.w / 2 - 0.15, y: n.y + n.h - 0.02, w: 0.3, h: 0.25, fontSize: 14, color: C.cyan, align: "center", margin: 0 });
    }
  });

  const t2side = [
    { x: 0.2, y: 1.7, w: 2.1, h: 0.55, label: "Visceral Fat\nInflammation", color: C.darkTeal },
    { x: 0.2, y: 2.48, w: 2.1, h: 0.55, label: "Ectopic Lipid\nDeposition", color: C.darkTeal },
    { x: 7.7, y: 3.26, w: 2.1, h: 0.55, label: "Chronic\nHyperglycaemia", color: C.amber },
    { x: 7.7, y: 4.04, w: 2.1, h: 0.55, label: "Long-term\nComplications", color: C.red },
  ];
  t2side.forEach(c => {
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x: c.x, y: c.y, w: c.w, h: c.h,
      fill: { color: c.color }, line: { color: c.color }, rectRadius: 0.07,
    });
    slide.addText(c.label, {
      x: c.x, y: c.y, w: c.w, h: c.h,
      fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 0,
    });
  });
  slide.addText("▶", { x: 2.3, y: 1.87, w: 0.3, h: 0.3, fontSize: 14, color: C.teal, align: "center", margin: 0 });
  slide.addText("▶", { x: 2.3, y: 2.65, w: 0.3, h: 0.3, fontSize: 14, color: C.teal, align: "center", margin: 0 });
  slide.addText("◀", { x: 7.4, y: 3.43, w: 0.3, h: 0.3, fontSize: 14, color: C.amber, align: "center", margin: 0 });
  slide.addText("◀", { x: 7.4, y: 4.21, w: 0.3, h: 0.3, fontSize: 14, color: C.red, align: "center", margin: 0 });
}

// ════════════════════════════════════════════════════════════════════════════
// SECTION 4 DIVIDER — Clinical Features & Natural History
// ════════════════════════════════════════════════════════════════════════════
sectionDivider("Clinical Features\n& Natural History", "Symptoms, disease course, and chronic complications", "4");

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 14 — Classic Symptoms
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Classic Symptoms of Hyperglycaemia");

  const symptoms = [
    { icon: "💧", title: "Polyuria", desc: "Osmotic diuresis from\nglycosuria; frequent\nlarge-volume urination" },
    { icon: "🥤", title: "Polydipsia", desc: "Compensatory thirst\nfrom dehydration and\nosmotic shifts" },
    { icon: "🍽", title: "Polyphagia", desc: "Increased hunger despite\neating; cells starved of\nglucose (T1 especially)" },
    { icon: "⚖️", title: "Weight Loss", desc: "Prominent in T1DM;\ncatabolism of fat\nand muscle stores" },
    { icon: "😴", title: "Fatigue", desc: "Cellular energy deficit;\ndehydration and\nelectrolyte imbalance" },
    { icon: "👁", title: "Blurred Vision", desc: "Osmotic changes to\nlens shape from\nhyperglycaemia" },
  ];

  symptoms.forEach((s, i) => {
    const col = i % 3;
    const row = Math.floor(i / 3);
    const x = 0.2 + col * 3.2;
    const y = 0.92 + row * 2.05;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y, w: 3.05, h: 1.9,
      fill: { color: C.charcoal }, line: { color: C.teal }, rectRadius: 0.1,
    });
    slide.addText(s.icon + "  " + s.title, {
      x, y: y + 0.05, w: 3.05, h: 0.5,
      fontSize: 13, bold: true, color: C.cyan, align: "center", valign: "middle", margin: 0,
    });
    slide.addText(s.desc, {
      x, y: y + 0.56, w: 3.05, h: 1.25,
      fontSize: 11, color: C.white, align: "center", valign: "top", margin: 0,
    });
  });

  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0.2, y: 5.04, w: 9.5, h: 0.25,
    fill: { color: C.charcoal }, line: { color: C.charcoal },
  });
  slide.addText("Also: slow-healing wounds, recurrent infections (skin/UTI/candida), peripheral tingling", {
    x: 0.2, y: 5.04, w: 9.5, h: 0.25,
    fontSize: 9.5, color: C.muted, align: "center", valign: "middle", italic: true, margin: 0,
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 15 — Natural History of T1DM
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Natural History of Type 1 DM");

  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.2, y: 0.95, w: 9.4, h: 1.45,
    fill: { color: C.charcoal }, line: { color: C.red, pt: 2 }, rectRadius: 0.08,
  });
  slide.addText([
    { text: "Onset: ", options: { bold: true, color: C.red, fontSize: 13, breakLine: false } },
    { text: "Rapid — days to weeks.  ", options: { color: C.white, fontSize: 13, breakLine: false } },
    { text: "Most common: ", options: { bold: true, color: C.cyan, fontSize: 13, breakLine: false } },
    { text: "Children, adolescents, young adults", options: { color: C.white, fontSize: 13, breakLine: true } },
    { text: "Classic presentation: DKA — polyuria, vomiting, Kussmaul breathing, altered consciousness", options: { color: C.muted, fontSize: 12 } },
  ], { x: 0.4, y: 0.98, w: 9.0, h: 1.35, valign: "middle", margin: 0 });

  const phases = [
    { label: "Pre-clinical\nPhase", sub: "Autoimmunity, GAD antibodies\nNo symptoms; β-cells declining", color: C.darkTeal },
    { label: "Clinical\nOnset", sub: "Rapid symptom onset;\nosmotic symptoms prominent", color: C.amber },
    { label: "Honeymoon\nPeriod", sub: "Partial β-cell recovery;\ntemporary reduced insulin needs", color: C.teal },
    { label: "Established\nT1DM", sub: "Complete β-cell loss;\nlifelong insulin dependence", color: C.red },
  ];

  phases.forEach((p, i) => {
    const x = 0.2 + i * 2.38;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 2.6, w: 2.22, h: 2.4,
      fill: { color: p.color }, line: { color: C.white }, rectRadius: 0.08,
    });
    slide.addText(p.label, { x, y: 2.65, w: 2.22, h: 0.65, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addShape(pres.shapes.RECTANGLE, { x: x + 0.35, y: 3.32, w: 1.52, h: 0.04, fill: { color: C.white }, line: { color: C.white } });
    slide.addText(p.sub, { x, y: 3.4, w: 2.22, h: 1.4, fontSize: 10, color: C.white, align: "center", valign: "top", margin: 0 });
    if (i < phases.length - 1) {
      slide.addText("▶", { x: x + 2.22 - 0.05, y: 3.55, w: 0.3, h: 0.3, fontSize: 16, color: C.cyan, align: "center", margin: 0 });
    }
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 16 — Natural History of T2DM
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Natural History of Type 2 DM");

  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.2, y: 0.95, w: 9.4, h: 1.1,
    fill: { color: C.charcoal }, line: { color: C.teal, pt: 2 }, rectRadius: 0.08,
  });
  slide.addText("Insidious onset over months to years. Often diagnosed incidentally on routine blood tests. Strongly associated with obesity, metabolic syndrome, and physical inactivity.", {
    x: 0.4, y: 0.95, w: 9.0, h: 1.1,
    fontSize: 12, color: C.white, valign: "middle", margin: 0,
  });

  const phases2 = [
    { label: "Normal\nGlucose", sub: "Insulin sensitivity\nnormal", color: C.green },
    { label: "Insulin\nResistance", sub: "Hyperinsulinaemia\ncompensates", color: C.teal },
    { label: "Pre-\nDiabetes", sub: "IFG/IGT; HbA1c\n5.7–6.4%", color: C.amber },
    { label: "Type 2\nDiabetes", sub: "Diagnostic thresholds\nexceeded", color: C.red },
    { label: "Micro/Macro\nComplications", sub: "Retinopathy,\nnephropathy, CVD", color: C.red },
  ];

  phases2.forEach((p, i) => {
    const x = 0.15 + i * 1.93;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 2.2, w: 1.8, h: 2.8,
      fill: { color: p.color }, line: { color: C.white }, rectRadius: 0.08,
    });
    slide.addText(p.label, { x, y: 2.25, w: 1.8, h: 0.6, fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addShape(pres.shapes.RECTANGLE, { x: x + 0.25, y: 2.87, w: 1.3, h: 0.04, fill: { color: C.white }, line: { color: C.white } });
    slide.addText(p.sub, { x, y: 2.96, w: 1.8, h: 1.9, fontSize: 10, color: C.white, align: "center", valign: "top", margin: 0 });
    if (i < phases2.length - 1) {
      slide.addText("▶", { x: x + 1.8, y: 3.42, w: 0.2, h: 0.3, fontSize: 14, color: C.cyan, align: "center", margin: 0 });
    }
  });

  slide.addText("Time — years to decades →", { x: 0.15, y: 5.1, w: 9.5, h: 0.2, fontSize: 9, color: C.gray, italic: true, margin: 0 });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 17 — Chronic Complications (Microvascular)
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Chronic Complications — Microvascular");

  const compls = [
    {
      organ: "👁  Retinopathy",
      points: ["Commonest cause of blindness in working-age adults", "Background → proliferative retinopathy", "Screen annually with fundoscopy / retinal photography"],
      color: C.red,
    },
    {
      organ: "🫘  Nephropathy",
      points: ["Thickening of glomerular basement membrane", "Microalbuminuria → proteinuria → CKD", "Diabetic nephropathy = leading cause of ESKD"],
      color: C.amber,
    },
    {
      organ: "⚡  Neuropathy",
      points: ["Peripheral: glove-and-stocking sensory loss", "Autonomic: gastroparesis, postural hypotension", "Mononeuropathy (e.g., foot drop, CN III palsy)"],
      color: C.teal,
    },
  ];

  compls.forEach((c, i) => {
    const x = 0.2 + i * 3.25;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 0.92, w: 3.1, h: 4.1,
      fill: { color: C.charcoal }, line: { color: c.color, pt: 2 }, rectRadius: 0.1,
    });
    slide.addShape(pres.shapes.RECTANGLE, {
      x, y: 0.92, w: 3.1, h: 0.55,
      fill: { color: c.color }, line: { color: c.color },
    });
    slide.addText(c.organ, { x, y: 0.92, w: 3.1, h: 0.55, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText([
      ...bullets(c.points, 12),
    ], { x: x + 0.1, y: 1.55, w: 2.9, h: 3.3, margin: 0 });
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 18 — Chronic Complications (Macrovascular + Others)
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Chronic Complications — Macrovascular & Others");

  // Macrovascular
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.2, y: 0.92, w: 5.5, h: 3.55,
    fill: { color: C.charcoal }, line: { color: C.red, pt: 2 }, rectRadius: 0.08,
  });
  slide.addText("MACROVASCULAR", { x: 0.2, y: 0.92, w: 5.5, h: 0.45, fontSize: 13, bold: true, color: C.red, align: "center", margin: 0 });
  slide.addText([
    ...bullets([
      "Coronary artery disease (CAD) — 2–4× increased risk",
      "Ischaemic stroke and TIA",
      "Peripheral arterial disease (PAD)",
      "Heart failure (partly HFpEF)",
      "Driven by dyslipidaemia, hypertension, smoking, inflammation",
    ], 12),
  ], { x: 0.35, y: 1.42, w: 5.2, h: 3.0, margin: 0 });

  // Others
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 5.9, y: 0.92, w: 3.85, h: 3.55,
    fill: { color: C.charcoal }, line: { color: C.amber, pt: 2 }, rectRadius: 0.08,
  });
  slide.addText("OTHERS", { x: 5.9, y: 0.92, w: 3.85, h: 0.45, fontSize: 13, bold: true, color: C.amber, align: "center", margin: 0 });
  slide.addText([
    ...bullets([
      "Diabetic foot (ulcers, Charcot)",
      "Recurrent infections",
      "Skin: NLD, acanthosis nigricans",
      "Sexual dysfunction (ED)",
      "Depression / anxiety",
    ], 12),
  ], { x: 6.05, y: 1.42, w: 3.55, h: 3.0, margin: 0 });

  // Timeline note
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0.2, y: 4.6, w: 9.5, h: 0.48,
    fill: { color: C.teal }, line: { color: C.teal },
  });
  slide.addText("Risk is strongly related to duration of disease and degree of glycaemic control  |  HbA1c reduction of 1% → ~37% less microvascular events (UKPDS)", {
    x: 0.2, y: 4.6, w: 9.5, h: 0.48,
    fontSize: 10, bold: true, color: C.white, align: "center", valign: "middle", margin: 0,
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SECTION 5 DIVIDER — Investigations
// ════════════════════════════════════════════════════════════════════════════
sectionDivider("Investigations", "Diagnostic tests, monitoring, and complication screening", "5");

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 19 — Diagnostic & Monitoring Tests
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Diagnostic & Monitoring Tests");

  const tests = [
    { name: "Fasting Plasma Glucose", detail: "≥7.0 mmol/L diagnostic\nSimple, widely available", use: "Diagnosis", color: C.red },
    { name: "HbA1c", detail: "≥6.5% diagnostic\nReflects 2–3 month avg glucose\nUnaffected by acute changes", use: "Diagnosis + Monitoring", color: C.teal },
    { name: "OGTT (75g)", detail: "2h ≥11.1 mmol/L diagnostic\nGold standard in GDM", use: "Diagnosis", color: C.amber },
    { name: "C-Peptide / Insulin", detail: "Low → T1DM\nNormal/High → T2DM/early\nHelps differentiate types", use: "Differentiation", color: C.darkTeal },
    { name: "Autoantibodies", detail: "GAD65, islet cell, IA-2\nZnT8 antibodies\n+ve → confirms T1DM", use: "T1DM Confirmation", color: C.red },
    { name: "Random Glucose", detail: "≥11.1 + symptoms → diagnostic\nQuick point-of-care test", use: "Diagnosis", color: C.charcoal },
  ];

  tests.forEach((t, i) => {
    const col = i % 3;
    const row = Math.floor(i / 3);
    const x = 0.2 + col * 3.2;
    const y = 0.95 + row * 2.05;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y, w: 3.05, h: 1.9,
      fill: { color: C.charcoal }, line: { color: t.color }, rectRadius: 0.08,
    });
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y, w: 3.05, h: 0.45,
      fill: { color: t.color }, line: { color: t.color }, rectRadius: 0.08,
    });
    slide.addText(t.name, { x, y, w: 3.05, h: 0.45, fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText(t.detail, { x, y: y + 0.5, w: 3.05, h: 1.1, fontSize: 10.5, color: C.white, align: "center", valign: "top", margin: 2 });
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, { x: x + 0.3, y: y + 1.63, w: 2.45, h: 0.22, fill: { color: t.color }, line: { color: t.color }, rectRadius: 0.05 });
    slide.addText(t.use, { x: x + 0.3, y: y + 1.63, w: 2.45, h: 0.22, fontSize: 9, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 20 — Complication Screening
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Screening for Complications");

  const screenings = [
    { name: "Eyes", test: "Fundoscopy / Retinal photography", freq: "Annual", target: "Retinopathy screening", color: C.red },
    { name: "Kidneys", test: "Urine ACR + eGFR / Creatinine", freq: "Annual", target: "Early nephropathy detection", color: C.amber },
    { name: "Feet", test: "10g monofilament + pulses + inspection", freq: "Annual", target: "Neuropathy & PAD", color: C.teal },
    { name: "Cardiovascular", test: "Lipid profile, BP, ECG, BMI, smoking", freq: "Annual", target: "CV risk stratification", color: C.red },
    { name: "HbA1c", test: "Glycated haemoglobin", freq: "Every 3–6 months", target: "Glycaemic control monitoring", color: C.cyan },
    { name: "Neuropathy", test: "Vibration sense, ankle reflexes, 10g filament", freq: "Annual", target: "Peripheral neuropathy", color: C.darkTeal },
  ];

  const rows2 = [
    [{ text: "System", options: { bold: true, color: C.cyan } }, { text: "Test", options: { bold: true, color: C.cyan } }, { text: "Frequency", options: { bold: true, color: C.cyan } }, { text: "Targets", options: { bold: true, color: C.cyan } }],
    ...screenings.map(s => [s.name, s.test, s.freq, s.target]),
  ];

  slide.addTable(rows2, {
    x: 0.2, y: 0.92, w: 9.5, h: 4.15,
    fontSize: 11,
    color: C.white,
    fill: { color: C.charcoal },
    border: { type: "solid", color: C.teal, pt: 1 },
    rowH: 0.55,
    fontFace: "Calibri",
    align: "left",
    valign: "middle",
    colW: [1.4, 3.1, 1.9, 3.1],
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 21 — Other Labs
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Other Investigations");

  const labGroups = [
    {
      title: "Acute / Sick Day",
      labs: ["Blood ketones (β-hydroxybutyrate >3 mmol/L = severe)", "Arterial blood gas — pH, bicarbonate, pCO₂", "Electrolytes — Na, K (critical in DKA)", "Serum osmolality (HHS >320 mOsm/kg)", "Lactate — lactic acidosis check"],
      color: C.red,
    },
    {
      title: "Routine Monitoring",
      labs: ["Full blood count — anaemia in CKD", "LFTs — NAFLD common in T2DM", "Thyroid function — associated autoimmunity (T1)", "Micronutrients — Vit B12 (metformin use)", "Coeliac screen — associated with T1DM"],
      color: C.teal,
    },
  ];

  labGroups.forEach((g, i) => {
    const x = 0.2 + i * 4.9;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 0.92, w: 4.6, h: 4.1,
      fill: { color: C.charcoal }, line: { color: g.color, pt: 2 }, rectRadius: 0.08,
    });
    slide.addShape(pres.shapes.RECTANGLE, {
      x, y: 0.92, w: 4.6, h: 0.5,
      fill: { color: g.color }, line: { color: g.color },
    });
    slide.addText(g.title, { x, y: 0.92, w: 4.6, h: 0.5, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText([
      ...bullets(g.labs, 12),
    ], { x: x + 0.1, y: 1.48, w: 4.4, h: 3.45, margin: 0 });
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SECTION 6 DIVIDER — Management
// ════════════════════════════════════════════════════════════════════════════
sectionDivider("Management", "General principles, T1 and T2 treatment,\nmonitoring and follow-up", "6");

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 22 — General Principles of Management
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "General Principles of Management");

  const pillars = [
    { title: "Patient\nEducation", points: ["Disease understanding", "Self-monitoring skills", "Sick day rules"], color: C.teal },
    { title: "Lifestyle\nModification", points: ["Mediterranean-style diet", "≥150 min/week exercise", "Weight loss ≥5–10%"], color: C.green },
    { title: "Glycaemic\nTargets", points: ["HbA1c <7% (53 mmol/mol)", "Individualised goals", "Avoid hypoglycaemia"], color: C.amber },
    { title: "CV Risk\nReduction", points: ["BP <130/80 mmHg", "Statin therapy", "No smoking"], color: C.red },
    { title: "MDT\nCare", points: ["Diabetologist, dietitian", "Diabetes educator", "Podiatrist, ophthalmologist"], color: C.darkTeal },
  ];

  pillars.forEach((p, i) => {
    const x = 0.15 + i * 1.93;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 0.92, w: 1.8, h: 4.1,
      fill: { color: C.charcoal }, line: { color: p.color, pt: 2 }, rectRadius: 0.08,
    });
    slide.addShape(pres.shapes.RECTANGLE, {
      x, y: 0.92, w: 1.8, h: 0.7,
      fill: { color: p.color }, line: { color: p.color },
    });
    slide.addText(p.title, { x, y: 0.92, w: 1.8, h: 0.7, fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText([
      ...bullets(p.points, 10.5),
    ], { x: x + 0.05, y: 1.68, w: 1.7, h: 3.2, margin: 0 });
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 23 — T1DM Management
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Type 1 DM — Management");

  // Insulin types table
  slide.addText("INSULIN REGIMENS", { x: 0.2, y: 0.92, w: 9, h: 0.35, fontSize: 13, bold: true, color: C.cyan, margin: 0 });

  const insulinRows = [
    [{ text: "Regimen", options: { bold: true, color: C.cyan } }, { text: "Components", options: { bold: true, color: C.cyan } }, { text: "Notes", options: { bold: true, color: C.cyan } }],
    ["Basal-Bolus (MDI)", "Long-acting + rapid-acting at meals", "Gold standard; most physiological"],
    ["CSII (Insulin Pump)", "Continuous subcutaneous infusion", "Better control; preferred in some"],
    ["Basal-only (bridging)", "Long-acting once/twice daily", "Not ideal; used temporarily"],
  ];

  slide.addTable(insulinRows, {
    x: 0.2, y: 1.32, w: 9.5, h: 1.65,
    fontSize: 11, color: C.white, fill: { color: C.charcoal },
    border: { type: "solid", color: C.teal, pt: 1 },
    rowH: 0.44, fontFace: "Calibri", align: "left", valign: "middle",
    colW: [2.8, 3.8, 2.9],
  });

  // Additional management
  slide.addText("ADDITIONAL STRATEGIES", { x: 0.2, y: 3.1, w: 9, h: 0.35, fontSize: 13, bold: true, color: C.cyan, margin: 0 });

  const addl = [
    { t: "Carbohydrate Counting", d: "Match rapid insulin dose to carb intake; 1 unit per 10–15g CHO (varies)", c: C.teal },
    { t: "CGM", d: "Continuous glucose monitoring — reduces HbA1c & hypoglycaemia events", c: C.darkTeal },
    { t: "Sick Day Rules", d: "Never stop insulin; monitor ketones; increase frequency, seek help if ketones >3", c: C.red },
  ];

  addl.forEach((a, i) => {
    const x = 0.2 + i * 3.2;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 3.5, w: 3.05, h: 1.6,
      fill: { color: a.c }, line: { color: a.c }, rectRadius: 0.08,
    });
    slide.addText(a.t, { x, y: 3.53, w: 3.05, h: 0.45, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText(a.d, { x, y: 4.0, w: 3.05, h: 1.0, fontSize: 10.5, color: C.white, align: "center", valign: "top", margin: 2 });
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 24 — T2DM Management
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Type 2 DM — Pharmacological Management");

  const drugs = [
    { name: "Metformin", class: "Biguanide", moa: "↓ hepatic glucose output; improves insulin sensitivity", notes: "First-line; weight neutral; cheap; hold in eGFR<30", color: C.teal },
    { name: "SGLT2 Inhibitors", class: "e.g. Empagliflozin, Dapagliflozin", moa: "Block renal glucose reabsorption → glucosuria", notes: "CV & renal protection ✓; weight loss; risk: DKA, UTI", color: C.green },
    { name: "GLP-1 Receptor Agonists", class: "e.g. Semaglutide, Liraglutide", moa: "Mimic incretin; ↑ insulin, ↓ glucagon, ↓ appetite", notes: "CV protection ✓; weight loss; injectable (or oral)", color: C.green },
    { name: "Sulfonylureas", class: "e.g. Gliclazide, Glibenclamide", moa: "Stimulate β-cell insulin release (KATP channel)", notes: "Hypoglycaemia risk; weight gain; low cost", color: C.amber },
    { name: "DPP-4 Inhibitors", class: "e.g. Sitagliptin, Saxagliptin", moa: "Prolong incretin action (GLP-1/GIP)", notes: "Well tolerated; weight neutral; modest efficacy", color: C.darkTeal },
    { name: "Insulin", class: "Basal ± bolus", moa: "Exogenous insulin replacement", notes: "When oral agents fail; requires BG monitoring", color: C.red },
  ];

  drugs.forEach((d, i) => {
    const col = i % 3;
    const row = Math.floor(i / 3);
    const x = 0.15 + col * 3.22;
    const y = 0.92 + row * 2.1;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y, w: 3.08, h: 1.95,
      fill: { color: C.charcoal }, line: { color: d.color }, rectRadius: 0.08,
    });
    slide.addShape(pres.shapes.RECTANGLE, { x, y, w: 3.08, h: 0.42, fill: { color: d.color }, line: { color: d.color } });
    slide.addText(d.name, { x, y, w: 3.08, h: 0.42, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText(d.class, { x, y: y + 0.44, w: 3.08, h: 0.28, fontSize: 9, color: C.muted, align: "center", italic: true, margin: 0 });
    slide.addText(d.moa, { x, y: y + 0.73, w: 3.08, h: 0.55, fontSize: 9.5, color: C.white, align: "center", margin: 2 });
    slide.addText(d.notes, { x, y: y + 1.3, w: 3.08, h: 0.6, fontSize: 9, color: C.cyan, align: "center", margin: 2 });
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 25 — Monitoring & Follow-up
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Monitoring & Follow-up");

  const items = [
    { freq: "Every Visit", tasks: ["Blood pressure measurement", "Weight / BMI", "Foot inspection", "Medication review", "Hypoglycaemia enquiry"], color: C.cyan },
    { freq: "Every 3–6 Months", tasks: ["HbA1c", "Self-monitoring log review", "Hypoglycaemia episodes", "Insulin/medication adjustment"], color: C.teal },
    { freq: "Annual Review", tasks: ["Retinal screening", "Urine ACR + eGFR", "Full foot exam (monofilament)", "Lipids + ECG", "Neuropathy assessment", "Dietitian + educator review"], color: C.amber },
  ];

  items.forEach((it, i) => {
    const x = 0.15 + i * 3.25;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 0.92, w: 3.1, h: 4.1,
      fill: { color: C.charcoal }, line: { color: it.color, pt: 2 }, rectRadius: 0.08,
    });
    slide.addShape(pres.shapes.RECTANGLE, { x, y: 0.92, w: 3.1, h: 0.5, fill: { color: it.color }, line: { color: it.color } });
    slide.addText(it.freq, { x, y: 0.92, w: 3.1, h: 0.5, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText([...bullets(it.tasks, 12)], { x: x + 0.1, y: 1.48, w: 2.9, h: 3.45, margin: 0 });
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SECTION 7 DIVIDER — Diabetic Emergencies
// ════════════════════════════════════════════════════════════════════════════
sectionDivider("Diabetic Emergencies", "DKA, HHS, hypoglycaemia — recognition,\nmanagement and prevention", "7");

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 26 — Overview of Emergencies
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Diabetic Emergencies — Overview");

  const emgs = [
    { title: "DKA", sub: "Diabetic Ketoacidosis", type: "Hyperglycaemic", desc: "Mostly T1DM\nHyperglycaemia + Ketoacidosis\nAcid-base imbalance", color: C.red },
    { title: "HHS", sub: "Hyperosmolar Hyperglycaemic State", type: "Hyperglycaemic", desc: "Mostly elderly T2DM\nExtreme hyperglycaemia\nNo significant ketosis", color: C.amber },
    { title: "Hypoglycaemia", sub: "BG <4 mmol/L", type: "Hypoglycaemic", desc: "Any DM on insulin/sulfonyl\nAdrenergic + neuroglycopenic Sx\nTreat immediately", color: C.teal },
    { title: "Lactic Acidosis", sub: "Rare, high mortality", type: "Metabolic", desc: "Tissue hypoperfusion\nAssociated with metformin\nManage in ICU", color: C.darkTeal },
  ];

  emgs.forEach((e, i) => {
    const x = 0.15 + i * 2.42;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 0.92, w: 2.28, h: 4.1,
      fill: { color: C.charcoal }, line: { color: e.color, pt: 2 }, rectRadius: 0.1,
    });
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, { x, y: 0.92, w: 2.28, h: 0.55, fill: { color: e.color }, line: { color: e.color }, rectRadius: 0.1 });
    slide.addText(e.title, { x, y: 0.92, w: 2.28, h: 0.55, fontSize: 14, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText(e.sub, { x, y: 1.52, w: 2.28, h: 0.45, fontSize: 9.5, color: e.color, align: "center", italic: true, margin: 0 });
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, { x: x + 0.35, y: 2.02, w: 1.58, h: 0.28, fill: { color: e.color }, line: { color: e.color }, rectRadius: 0.06 });
    slide.addText(e.type, { x: x + 0.35, y: 2.02, w: 1.58, h: 0.28, fontSize: 9, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText(e.desc, { x, y: 2.38, w: 2.28, h: 2.5, fontSize: 11, color: C.white, align: "center", valign: "top", margin: 2 });
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 27 — DKA Criteria
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Diabetic Ketoacidosis (DKA)");

  // DKA triad
  slide.addText("THE DIAGNOSTIC TRIAD", { x: 0.2, y: 0.92, w: 9, h: 0.35, fontSize: 12, bold: true, color: C.red, margin: 0 });

  const triad = [
    { label: "Hyperglycaemia", val: ">11–13.9 mmol/L\n(>200 mg/dL)", color: C.red },
    { label: "Ketonaemia /\nKetonuria", val: ">3 mmol/L ketones\nor urine ketones 2+", color: C.red },
    { label: "Metabolic\nAcidosis", val: "pH <7.3\nBicarb <15 mEq/L\nAnion gap >12", color: C.red },
  ];

  triad.forEach((t, i) => {
    const x = 0.2 + i * 3.22;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 1.35, w: 3.08, h: 1.75,
      fill: { color: t.color }, line: { color: t.color }, rectRadius: 0.1,
    });
    slide.addText(t.label, { x, y: 1.38, w: 3.08, h: 0.6, fontSize: 14, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addShape(pres.shapes.RECTANGLE, { x: x + 0.5, y: 1.97, w: 2.08, h: 0.04, fill: { color: C.white }, line: { color: C.white } });
    slide.addText(t.val, { x, y: 2.04, w: 3.08, h: 0.98, fontSize: 12, color: C.white, align: "center", valign: "top", margin: 0 });
  });

  // Precipitants & info
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.2, y: 3.25, w: 4.55, h: 1.8,
    fill: { color: C.charcoal }, line: { color: C.amber }, rectRadius: 0.08,
  });
  slide.addText("PRECIPITANTS", { x: 0.2, y: 3.27, w: 4.55, h: 0.35, fontSize: 11, bold: true, color: C.amber, margin: 2 });
  slide.addText([
    ...bullets(["Infection (most common — 30–40%)", "Insulin omission / non-compliance", "New T1DM presentation", "MI, stroke, surgery, drugs (steroids, SGLT2i)", "Unknown in ~25%"], 11),
  ], { x: 0.35, y: 3.63, w: 4.25, h: 1.35, margin: 0 });

  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 5.0, y: 3.25, w: 4.75, h: 1.8,
    fill: { color: C.charcoal }, line: { color: C.cyan }, rectRadius: 0.08,
  });
  slide.addText("KEY FACTS", { x: 5.0, y: 3.27, w: 4.75, h: 0.35, fontSize: 11, bold: true, color: C.cyan, margin: 2 });
  slide.addText([
    ...bullets(["Primarily Type 1 DM but can occur in T2", "Can present with near-normal glucose (euglycaemic DKA — SGLT2i)", "Mortality <1% with prompt treatment", "Most common cause of DM death in <20yr"], 11),
  ], { x: 5.15, y: 3.63, w: 4.45, h: 1.35, margin: 0 });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 28 — DKA Clinical Features
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "DKA — Clinical Features");

  const features = [
    { system: "Osmotic", items: ["Polyuria, polydipsia", "Dehydration", "Dry mucous membranes, tachycardia"] },
    { system: "GI", items: ["Nausea and vomiting", "Diffuse abdominal pain", "Anorexia"] },
    { system: "Respiratory", items: ["Kussmaul breathing\n(deep, rapid, laboured)", "Fruity/acetone breath"] },
    { system: "Neurological", items: ["Fatigue, lethargy", "Confusion, drowsiness", "Coma (severe cases)"] },
  ];

  features.forEach((f, i) => {
    const x = 0.2 + i * 2.4;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 0.92, w: 2.25, h: 4.1,
      fill: { color: C.charcoal }, line: { color: C.red }, rectRadius: 0.08,
    });
    slide.addShape(pres.shapes.RECTANGLE, { x, y: 0.92, w: 2.25, h: 0.5, fill: { color: C.red }, line: { color: C.red } });
    slide.addText(f.system, { x, y: 0.92, w: 2.25, h: 0.5, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText([...bullets(f.items, 11.5)], { x: x + 0.05, y: 1.47, w: 2.15, h: 3.45, margin: 0 });
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 29 — HHS
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Hyperosmolar Hyperglycaemic State (HHS)");

  // Diagnostic criteria
  slide.addText("DIAGNOSTIC CRITERIA", { x: 0.2, y: 0.92, w: 9, h: 0.35, fontSize: 12, bold: true, color: C.amber, margin: 0 });

  const hhsCrit = [
    { label: "Glucose", val: ">33 mmol/L\n(>600 mg/dL)" },
    { label: "Osmolality", val: ">320 mOsm/kg\n(effective)" },
    { label: "pH", val: ">7.3\n(minimal acidosis)" },
    { label: "Ketones", val: "Absent or\ntrace only" },
  ];

  hhsCrit.forEach((c, i) => {
    const x = 0.2 + i * 2.4;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 1.35, w: 2.25, h: 1.55,
      fill: { color: C.amber }, line: { color: C.amber }, rectRadius: 0.08,
    });
    slide.addText(c.label, { x, y: 1.38, w: 2.25, h: 0.42, fontSize: 13, bold: true, color: C.navy, align: "center", margin: 0 });
    slide.addText(c.val, { x, y: 1.82, w: 2.25, h: 1.0, fontSize: 12, bold: true, color: C.navy, align: "center", valign: "top", margin: 0 });
  });

  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.2, y: 3.05, w: 4.55, h: 2.0,
    fill: { color: C.charcoal }, line: { color: C.amber }, rectRadius: 0.08,
  });
  slide.addText("FEATURES", { x: 0.2, y: 3.07, w: 4.55, h: 0.35, fontSize: 11, bold: true, color: C.amber, margin: 2 });
  slide.addText([
    ...bullets(["Mostly elderly Type 2 DM", "Insidious onset over days–weeks", "Profound dehydration (8–10L deficit)", "Neurological signs common: confusion, seizures", "No significant ketoacidosis"], 11),
  ], { x: 0.35, y: 3.44, w: 4.25, h: 1.55, margin: 0 });

  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 5.0, y: 3.05, w: 4.75, h: 2.0,
    fill: { color: C.charcoal }, line: { color: C.red }, rectRadius: 0.08,
  });
  slide.addText("vs DKA", { x: 5.0, y: 3.07, w: 4.75, h: 0.35, fontSize: 11, bold: true, color: C.red, margin: 2 });
  slide.addText([
    ...bullets(["HHS: older patient, T2DM", "HHS: gradual onset vs DKA acute", "HHS: higher glucose, higher osmolality", "HHS: no/minimal ketosis vs DKA significant", "HHS: higher mortality (15–20%) vs DKA (<1%)"], 11),
  ], { x: 5.15, y: 3.44, w: 4.45, h: 1.55, margin: 0 });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 30 — Hypoglycaemia
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Hypoglycaemia");

  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.2, y: 0.92, w: 9.4, h: 0.6,
    fill: { color: C.teal }, line: { color: C.teal }, rectRadius: 0.07,
  });
  slide.addText("Definition: Blood glucose <4.0 mmol/L  |  Symptoms may occur below 3.9 mmol/L", {
    x: 0.2, y: 0.92, w: 9.4, h: 0.6,
    fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0,
  });

  // Symptoms
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.2, y: 1.62, w: 4.55, h: 3.2,
    fill: { color: C.charcoal }, line: { color: C.cyan }, rectRadius: 0.08,
  });
  slide.addText("SYMPTOMS", { x: 0.2, y: 1.64, w: 4.55, h: 0.4, fontSize: 12, bold: true, color: C.cyan, margin: 2 });
  slide.addText("Adrenergic (autonomic):", { x: 0.35, y: 2.1, w: 4.25, h: 0.3, fontSize: 11, bold: true, color: C.amber, margin: 0 });
  slide.addText([...bullets(["Sweating, tremor, palpitations", "Anxiety, hunger"], 11)], { x: 0.35, y: 2.42, w: 4.25, h: 0.75, margin: 0 });
  slide.addText("Neuroglycopenic:", { x: 0.35, y: 3.2, w: 4.25, h: 0.3, fontSize: 11, bold: true, color: C.red, margin: 0 });
  slide.addText([...bullets(["Confusion, slurred speech", "Seizure, coma", "Focal neurological signs"], 11)], { x: 0.35, y: 3.52, w: 4.25, h: 1.2, margin: 0 });

  // Causes
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 5.0, y: 1.62, w: 4.75, h: 3.2,
    fill: { color: C.charcoal }, line: { color: C.amber }, rectRadius: 0.08,
  });
  slide.addText("CAUSES", { x: 5.0, y: 1.64, w: 4.75, h: 0.4, fontSize: 12, bold: true, color: C.amber, margin: 2 });
  slide.addText([
    ...bullets([
      "Excess insulin dose",
      "Sulfonylurea (prolonged hypoglycaemia)",
      "Missed or delayed meals",
      "Unaccustomed exercise",
      "Alcohol (inhibits gluconeogenesis)",
      "Renal / hepatic impairment",
      "Hypoglycaemia unawareness (autonomic neuropathy)",
    ], 11),
  ], { x: 5.15, y: 2.1, w: 4.45, h: 2.65, margin: 0 });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 31 — DKA Management
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "DKA Management");

  const steps31 = [
    { n: "1", title: "Airway / Assess", body: "ABC, GCS; IV access; continuous monitoring; urine output catheterisation if comatose", color: C.teal },
    { n: "2", title: "IV Fluids", body: "0.9% NaCl — 1L over 1h, then 500mL/h×2h, then adjust. Cautious in cardiac/renal disease", color: C.teal },
    { n: "3", title: "Insulin", body: "Fixed-rate IV insulin 0.1 unit/kg/h\nDo NOT start until K⁺ ≥3.5 mEq/L\nSwitch to SC when gap closed + eating", color: C.amber },
    { n: "4", title: "Potassium", body: "Replace K⁺ if <5.5 mEq/L\nMonitor hourly initially\nHypoK is most dangerous complication", color: C.red },
    { n: "5", title: "Monitor", body: "Hourly glucose & ketones\n2-hourly electrolytes, VBG\nTarget: ketones falling >0.5/h", color: C.darkTeal },
    { n: "6", title: "Treat Cause", body: "Cultures → antibiotics if infected\nReview medications\nAddress precipitant", color: C.charcoal },
  ];

  steps31.forEach((s, i) => {
    const col = i % 3;
    const row = Math.floor(i / 3);
    const x = 0.15 + col * 3.25;
    const y = 0.92 + row * 2.1;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y, w: 3.1, h: 1.95,
      fill: { color: C.charcoal }, line: { color: s.color }, rectRadius: 0.08,
    });
    slide.addShape(pres.shapes.OVAL, { x: x + 0.1, y: y + 0.1, w: 0.45, h: 0.45, fill: { color: s.color }, line: { color: s.color } });
    slide.addText(s.n, { x: x + 0.1, y: y + 0.1, w: 0.45, h: 0.45, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText(s.title, { x: x + 0.62, y: y + 0.1, w: 2.38, h: 0.45, fontSize: 12, bold: true, color: s.color, valign: "middle", margin: 0 });
    slide.addText(s.body, { x: x + 0.1, y: y + 0.6, w: 2.9, h: 1.25, fontSize: 10.5, color: C.white, valign: "top", margin: 2 });
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 32 — DKA vs HHS Comparison Table
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "DKA vs HHS — Comparison");

  const compRows = [
    [{ text: "Feature", options: { bold: true, color: C.cyan } }, { text: "DKA", options: { bold: true, color: C.red } }, { text: "HHS", options: { bold: true, color: C.amber } }],
    ["Diabetes Type", "Primarily T1DM", "Primarily T2DM"],
    ["Onset", "Acute (hours–days)", "Insidious (days–weeks)"],
    ["Age", "Young (any age)", "Elderly"],
    ["Glucose", ">11–13.9 mmol/L", ">33 mmol/L"],
    ["Osmolality", "Normal/mildly raised", ">320 mOsm/kg"],
    ["pH", "<7.3", ">7.3"],
    ["Bicarbonate", "<15 mEq/L", "Normal"],
    ["Ketones", "Raised (>3 mmol/L)", "Absent/trace"],
    ["Anion Gap", "High", "Normal"],
    ["Mortality", "<1% with treatment", "15–20%"],
    ["Fluid Deficit", "3–5 L", "8–10 L"],
  ];

  slide.addTable(compRows, {
    x: 0.2, y: 0.92, w: 9.5, h: 4.3,
    fontSize: 11, color: C.white, fill: { color: C.charcoal },
    border: { type: "solid", color: C.teal, pt: 1 },
    rowH: 0.33, fontFace: "Calibri", align: "left", valign: "middle",
    colW: [3.0, 3.25, 3.25],
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 33 — Hypoglycaemia Management
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Hypoglycaemia Management");

  // Decision pathway
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 3.5, y: 0.92, w: 3.0, h: 0.6,
    fill: { color: C.teal }, line: { color: C.teal }, rectRadius: 0.08,
  });
  slide.addText("Blood Glucose <4 mmol/L", { x: 3.5, y: 0.92, w: 3.0, h: 0.6, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });

  slide.addText("▼", { x: 4.85, y: 1.53, w: 0.3, h: 0.3, fontSize: 18, color: C.cyan, align: "center", margin: 0 });

  // Two branches
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.3, y: 1.92, w: 4.2, h: 0.6,
    fill: { color: C.green }, line: { color: C.green }, rectRadius: 0.08,
  });
  slide.addText("CONSCIOUS / Can Swallow", { x: 0.3, y: 1.92, w: 4.2, h: 0.6, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });

  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 5.4, y: 1.92, w: 4.1, h: 0.6,
    fill: { color: C.red }, line: { color: C.red }, rectRadius: 0.08,
  });
  slide.addText("UNCONSCIOUS / Cannot Swallow", { x: 5.4, y: 1.92, w: 4.1, h: 0.6, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });

  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 0.3, y: 2.65, w: 4.2, h: 1.65,
    fill: { color: C.charcoal }, line: { color: C.green }, rectRadius: 0.08,
  });
  slide.addText([
    ...bullets(["15g fast-acting carbs: 4 glucose tablets, 150mL fruit juice, or 3 tsp sugar", "Recheck glucose after 15 min", "If still <4: repeat treatment", "When recovered: give longer-acting carb snack"], 11),
  ], { x: 0.4, y: 2.7, w: 4.0, h: 1.55, margin: 0 });

  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 5.4, y: 2.65, w: 4.1, h: 1.65,
    fill: { color: C.charcoal }, line: { color: C.red }, rectRadius: 0.08,
  });
  slide.addText([
    ...bullets(["IV 10% Dextrose 150–200mL (or 50mL 50% dextrose)", "IM/SC Glucagon 1mg — if no IV access", "Recovery position; do NOT give oral glucose", "Repeat glucose check every 15 min"], 11),
  ], { x: 5.5, y: 2.7, w: 3.9, h: 1.55, margin: 0 });

  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0.2, y: 4.45, w: 9.5, h: 0.55,
    fill: { color: C.amber }, line: { color: C.amber },
  });
  slide.addText("Prevention: review doses, education on hypoglycaemia recognition, medical alert ID, always carry glucose", {
    x: 0.2, y: 4.45, w: 9.5, h: 0.55,
    fontSize: 10.5, bold: true, color: C.navy, align: "center", valign: "middle", margin: 0,
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 34 — Prevention of Emergencies
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  contentShell(slide, "Prevention of Diabetic Emergencies");

  const strategies = [
    { title: "Patient\nEducation", points: ["Recognise warning signs", "Know when to seek help", "Understand sick day rules"], color: C.teal },
    { title: "Sick Day\nRules", points: ["Never stop insulin in T1DM", "Monitor glucose/ketones 4-hrly", "Increase fluids, seek advice if vomiting"], color: C.amber },
    { title: "Access to\nSupplies", points: ["Insulin, test strips, glucose", "Glucagon kit at home", "CGM where available"], color: C.green },
    { title: "Regular\nFollow-up", points: ["HbA1c every 3–6 months", "Review hypo patterns", "Adjust regimen proactively"], color: C.darkTeal },
    { title: "Medication\nAdherence", points: ["Address barriers to compliance", "Simplify regimens when possible", "Pharmacy support"], color: C.cyan },
  ];

  strategies.forEach((s, i) => {
    const x = 0.15 + i * 1.93;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y: 0.92, w: 1.8, h: 4.1,
      fill: { color: C.charcoal }, line: { color: s.color, pt: 2 }, rectRadius: 0.08,
    });
    slide.addShape(pres.shapes.RECTANGLE, { x, y: 0.92, w: 1.8, h: 0.7, fill: { color: s.color }, line: { color: s.color } });
    slide.addText(s.title, { x, y: 0.92, w: 1.8, h: 0.7, fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText([...bullets(s.points, 10.5)], { x: x + 0.05, y: 1.68, w: 1.7, h: 3.2, margin: 0 });
  });
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 35 — Summary & Conclusion
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  navyBg(slide);
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0, y: 0, w: 0.07, h: 5.625,
    fill: { color: C.cyan }, line: { color: C.cyan },
  });
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0.07, y: 0, w: 9.93, h: 0.75,
    fill: { color: C.charcoal }, line: { color: C.charcoal },
  });
  slide.addText("Key Takeaways", {
    x: 0.25, y: 0, w: 9.5, h: 0.75,
    fontSize: 22, bold: true, color: C.cyan, valign: "middle", margin: 0,
  });

  const takeaways = [
    { n: "1", t: "Glucose Homeostasis", d: "Tightly regulated by insulin (β-cells) and glucagon (α-cells) within 4–6 mmol/L" },
    { n: "2", t: "Types of DM", d: "T1 = autoimmune absolute deficiency; T2 = resistance + relative deficiency; both lead to chronic hyperglycaemia" },
    { n: "3", t: "Diagnosis", d: "Based on glucose thresholds or HbA1c ≥6.5%; confirm with repeat test unless symptomatic" },
    { n: "4", t: "Complications", d: "Micro (retinopathy, nephropathy, neuropathy) and macro (CAD, stroke, PAD) — prevented by good control" },
    { n: "5", t: "Management", d: "Lifestyle + Metformin for T2; insulin for T1; SGLT2i/GLP-1RA have proven CV & renal benefit" },
    { n: "6", t: "Emergencies", d: "DKA: fluids + insulin + K⁺. HHS: slow rehydration. Hypoglycaemia: 15g glucose or IV dextrose" },
  ];

  takeaways.forEach((t, i) => {
    const col = i % 2;
    const row = Math.floor(i / 2);
    const x = 0.25 + col * 4.88;
    const y = 0.88 + row * 1.47;
    slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
      x, y, w: 4.65, h: 1.32,
      fill: { color: C.charcoal }, line: { color: C.teal }, rectRadius: 0.07,
    });
    slide.addShape(pres.shapes.OVAL, { x: x + 0.1, y: y + 0.1, w: 0.48, h: 0.48, fill: { color: C.cyan }, line: { color: C.cyan } });
    slide.addText(t.n, { x: x + 0.1, y: y + 0.1, w: 0.48, h: 0.48, fontSize: 13, bold: true, color: C.navy, align: "center", valign: "middle", margin: 0 });
    slide.addText(t.t, { x: x + 0.65, y: y + 0.1, w: 3.9, h: 0.42, fontSize: 12, bold: true, color: C.cyan, valign: "middle", margin: 0 });
    slide.addText(t.d, { x: x + 0.1, y: y + 0.57, w: 4.45, h: 0.68, fontSize: 10.5, color: C.white, valign: "top", margin: 2 });
  });

  footer(slide, "Early diagnosis + tight control + patient education = prevention of complications");
}

// ════════════════════════════════════════════════════════════════════════════
// SLIDE 36 — References & Q&A
// ════════════════════════════════════════════════════════════════════════════
{
  const slide = pres.addSlide();
  navyBg(slide);
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0, y: 0, w: 0.07, h: 5.625,
    fill: { color: C.cyan }, line: { color: C.cyan },
  });
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0.07, y: 0, w: 9.93, h: 0.75,
    fill: { color: C.charcoal }, line: { color: C.charcoal },
  });
  slide.addText("References & Q&A", {
    x: 0.25, y: 0, w: 9.5, h: 0.75,
    fontSize: 22, bold: true, color: C.cyan, valign: "middle", margin: 0,
  });

  const refs = [
    "American Diabetes Association. Standards of Medical Care in Diabetes — 2024. Diabetes Care 2024;47(Suppl 1).",
    "World Health Organization. Classification of Diabetes Mellitus. WHO, 2019.",
    "NICE Guideline NG28. Type 2 diabetes in adults: management. NICE, updated 2022.",
    "NICE Guideline NG17. Type 1 diabetes in adults: diagnosis and management. NICE, updated 2022.",
    "Joint British Diabetes Societies (JBDS). Management of Diabetic Ketoacidosis in Adults. 2023.",
    "UKPDS Group. Intensive blood-glucose control with sulphonylureas or insulin. Lancet 1998;352:837–853.",
    "Zinman B, et al. Empagliflozin, Cardiovascular Outcomes, and Mortality in Type 2 Diabetes (EMPA-REG). NEJM 2015.",
  ];

  refs.forEach((r, i) => {
    slide.addShape(pres.shapes.RECTANGLE, {
      x: 0.15, y: 0.85 + i * 0.55, w: 0.22, h: 0.35,
      fill: { color: C.teal }, line: { color: C.teal },
    });
    slide.addText(`${i + 1}`, { x: 0.15, y: 0.85 + i * 0.55, w: 0.22, h: 0.35, fontSize: 9, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    slide.addText(r, { x: 0.42, y: 0.85 + i * 0.55, w: 9.3, h: 0.48, fontSize: 9.5, color: C.muted, valign: "middle", margin: 0 });
  });

  // Q&A area
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 2.5, y: 4.75, w: 5.0, h: 0.65,
    fill: { color: C.teal }, line: { color: C.teal }, rectRadius: 0.1,
  });
  slide.addText("Questions & Discussion", {
    x: 2.5, y: 4.75, w: 5.0, h: 0.65,
    fontSize: 16, bold: true, color: C.white, align: "center", valign: "middle", margin: 0,
  });
}

// ════════════════════════════════════════════════════════════════════════════
// WRITE FILE
// ════════════════════════════════════════════════════════════════════════════
pres.writeFile({ fileName: "/home/daytona/workspace/diabetes-pptx/Diabetes_Mellitus.pptx" })
  .then(() => console.log("✅  Saved: /home/daytona/workspace/diabetes-pptx/Diabetes_Mellitus.pptx"))
  .catch(err => { console.error("❌  Error:", err); process.exit(1); });

To run it:
node /home/daytona/workspace/diabetes-pptx/diabetes.js
The script will produce Diabetes_Mellitus.pptx with:
  • 36 slides covering all 7 sections
  • Navy/teal/cyan color theme with color-coded section cards
  • Tables (DKA vs HHS comparison, diagnostic criteria, complication screening)
  • Flowcharts (T1DM & T2DM progression using drawn shapes + arrows)
  • Step-by-step DKA management numbered cards
  • Hypoglycaemia decision pathway (conscious vs unconscious branches)
  • 7 numbered references (ADA 2024, WHO, NICE, JBDS, UKPDS, EMPA-REG)
Save the script as diabetes.js in /home/daytona/workspace/diabetes-pptx/, then run it. Want me to execute it now and give you the download link?

Execute the script to generate the PPTX file

Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.
This is a shared conversation. Sign in to Orris to start your own chat.