give diagram of eye

Reading File
Finding Sources
Finding Sources
Loading Image
Loading Image
Finding Sources
Reading File
Reading File
Loading Image
Loading Image
Here are detailed diagrams of the eye from authoritative medical textbooks:

Diagram of the Eye

1. Cross-Section of the Human Eye (Internal Anatomy)

From Ganong's Review of Medical Physiology
Cross-section diagram of the human eye showing internal anatomy including retina, lens, cornea, optic nerve, and chambers
Key structures labeled:
  • Outer coat (fibrous tunic): Sclera (white, protective) and Cornea (transparent, anterior)
  • Middle coat (vascular tunic / uvea): Choroid, Ciliary body, Iris
  • Inner coat (neural tunic): Retina, Fovea centralis
  • Optical media: Cornea, Lens, Vitreous chamber (posterior cavity)
  • Chambers: Anterior chamber, Posterior chamber (together = anterior cavity)
  • Supporting structures: Zonular fibers of suspensory ligament, Conjunctiva
  • Vasculature: Central artery and vein of the retina
  • Exit: Optic nerve (CN II)
  • Extraocular muscles: Superior rectus muscle, Inferior rectus muscle (shown at poles)

2. Horizontal Section of the Eye within the Orbit

From Netter's Atlas of Human Anatomy
Horizontal section of the eye in orbit showing orbital structures, rectus muscles, conjunctiva, and optic nerve
This section shows the eye in its orbital context, including:
  • Medial and lateral rectus muscles with their sheaths
  • Bulbar sheath (Tenon's capsule) and episcleral space
  • Palpebral and bulbar conjunctiva
  • Periorbita, orbital fat
  • Medial and lateral check ligaments and palpebral ligaments
  • Optic nerve (CN II) and its sheath posteriorly
  • Sphenoidal sinus and ethmoidal cells (adjacent structures)
  • Common annular tendon (origin of rectus muscles)

3. Embryological Development of the Eye

From Histology: A Text and Atlas
Developmental anatomy of the eye showing retina, optic nerve, neural retina, and surrounding coats including dura mater and choroid
Shows the layered structure in developmental context: neural retina, retinal pigment epithelium, choroid, sclera, cornea, iris, ciliary body, optic nerve, and vitreous body.

Quick Summary of Main Layers (Outside to Inside)

LayerStructureFunction
OuterSclera / CorneaProtection / light entry
Middle (Uvea)Choroid / Ciliary body / IrisNutrition / accommodation / pupil control
InnerRetina (neural + pigment)Phototransduction
ChambersAnterior + Posterior (aqueous humor)Nutrition of avascular structures
Posterior cavityVitreous chamberMaintains eye shape
  • Ganong's Review of Medical Physiology, 26th Ed., Fig. 10-1
  • Netter's Atlas of Human Anatomy, 7th Ed., p. 146
  • Histology: A Text and Atlas (Ross & Pawlina), 8th Ed.

write an essay on structure of skin in easy way

Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Finding Sources
Loading Image
Reading File
I now have everything needed to write a clear, easy essay. Here it is:

The Structure of Skin - An Easy Guide

Introduction: What is Skin?

Skin is the largest organ of the human body. It covers the entire outer surface and acts like a protective suit - keeping harmful things out (bacteria, UV rays, chemicals) and keeping important things in (water, body fluids). It also helps you feel touch, heat, cold, and pain, and plays a role in regulating your body temperature.
The skin is made up of three main layers, stacked one on top of the other:
  1. Epidermis - the outermost layer
  2. Dermis - the middle layer
  3. Hypodermis (also called subcutaneous tissue) - the deepest layer
Below is a beautifully labeled diagram showing all three layers along with blood vessels, hair follicles, and sensory receptors:
Cross-section diagram of skin showing epidermis, dermis with papillary and reticular layers, subcutaneous layer, hair follicles, blood vessels, sensory receptors, dermal papillae, and adipocytes

Layer 1: The Epidermis (The Outermost Shield)

Think of the epidermis as a brick wall. The "bricks" are cells called keratinocytes, which make up about 85% of all cells in this layer. These cells are constantly being made at the bottom and pushed upward until they die and flake off the surface. The whole process of replacing the epidermis takes about 47 days.
The epidermis has 4 sub-layers (strata), going from deepest to most superficial:

a) Stratum Basale (the Bottom Layer)

This is the "factory floor" where new skin cells are born. It is a single row of small, active cells that divide and push new cells upward. It is attached to the layer below (dermis) by tiny protein anchors called hemidesmosomes.

b) Stratum Spinosum (the Spiny Layer)

Several layers of keratinocytes sit here. They are held together tightly by desmosomes - think of them as tiny Velcro patches between cells. This layer gives the skin structural strength.

c) Stratum Granulosum (the Granular Layer)

Cells here are flatter and are filling up with:
  • Keratohyalin granules - which help pack keratin (a tough protein) inside the cell
  • Lamellar bodies - tiny lipid (fat) packages that get released to form the skin's waterproof barrier

d) Stratum Corneum (the Top Layer)

This is the outermost surface - dead, flattened cells completely packed with keratin. They have no nuclei anymore. These cells constantly shed (desquamate) and are replaced from below. This layer is your main barrier against the outside world.
In thick skin (like on the palms of hands and soles of feet), there is an extra layer called the stratum lucidum between the granulosum and corneum.

Special Cells in the Epidermis

The epidermis also contains three important non-keratinocyte cell types:
Cell% of EpidermisJob
Melanocytes~5%Make melanin pigment to protect DNA from UV radiation
Langerhans cells2-5%Immune defense - identify and present antigens
Merkel cells6-10%Detect light touch and texture (mechanoreceptors)
Melanocytes sit in the stratum basale and pass their pigment to surrounding keratinocytes. The pigment collects above the cell's nucleus like a tiny umbrella, shielding the DNA from sun damage. This is why skin tans in sunlight.

Layer 2: The Dermis (The Strong Middle Layer)

The dermis is the thick, tough layer beneath the epidermis. It is made of connective tissue - mostly collagen fibers (the most abundant protein in the dermis), elastic fibers, and cells called fibroblasts. The dermis gives skin its strength, elasticity, and flexibility. In fact, the leather used in shoes and bags is essentially processed dermis!
The dermis has 2 sub-layers:

a) Papillary Layer (upper dermis)

This is the thin, superficial part. It is made of loose connective tissue and pushes up into the epidermis as tiny finger-like projections called dermal papillae. These papillae:
  • Increase the surface area of attachment between epidermis and dermis
  • Contain capillaries that nourish the epidermis (which has no blood vessels)
  • Contain sensory nerve endings for fine touch
On the fingertips, these ridges form patterns - your fingerprints.

b) Reticular Layer (lower dermis)

This is the deeper, thicker part. It is made of dense irregular connective tissue with thick collagen type I fibers and elastic fibers. It contains:
  • Larger blood vessels and lymphatic vessels
  • Sweat glands, sebaceous glands, hair follicles
  • Fat cells in some regions

Sensory Receptors in the Dermis

The dermis is richly supplied with nerve receptors:
ReceptorLocationDetects
Free nerve endingsEpidermisPain, heat, cold, fine touch
Merkel corpusclesDermal-epidermal junctionSustained pressure, texture
Meissner corpusclesDermal papillaeLight touch
Pacinian corpusclesDeep dermis / hypodermisDeep pressure, vibration
Ruffini corpusclesDeep dermisSkin stretch and torque

Layer 3: The Hypodermis (The Fatty Cushion Below)

The hypodermis (also called subcutaneous tissue) is not technically part of the skin itself, but it lies directly under the dermis and connects the skin to the underlying muscles and bones.
It is made mostly of:
  • Adipocytes - fat cells that store energy and insulate the body
  • Areolar connective tissue - loose connective tissue
  • Larger blood vessels and nerves that branch upward into the dermis
The hypodermis acts as a shock absorber, an insulating blanket, and an energy reserve. Its thickness varies a lot between individuals and between body regions.

The Skin Appendages (Structures Within the Skin)

Skin is not just layers - it also contains several structures called appendages that grow from the epidermis down into the dermis:

1. Hair Follicles

Nearly the entire body is covered in hair. Each hair grows from a follicle - a tube-like pocket in the skin. At the bottom of the follicle is the hair bulb, where cells divide and push the hair shaft upward. Attached to each follicle is a tiny muscle - the arrector pili - which contracts when you're cold or scared, causing "goosebumps."

2. Sebaceous (Oil) Glands

These glands produce an oily substance called sebum, which coats the hair shaft and skin surface. Sebum keeps skin moisturized, prevents water loss, and has mild antibacterial properties. They use a method called holocrine secretion - the entire cell bursts to release its contents.

3. Sweat Glands

There are two types:
  • Eccrine glands - found all over the body, produce watery sweat to cool you down
  • Apocrine glands - found in the armpits and groin, produce thicker, protein-rich sweat into hair follicles (responsible for body odor when broken down by bacteria)

4. Nails

Nails are plates of hard, keratinized cells sitting on nail beds. They grow from a nail root at the base (under the skin fold) where keratinocytes keep dividing and differentiating to form hard keratin.

Functions of the Skin - A Quick Summary

FunctionHow Skin Does It
ProtectionSclera layer + keratin + melanin blocks physical, chemical, and UV damage
SensationMultiple nerve receptors detect touch, pain, heat, pressure
Temperature regulationSweat cools; fat insulates; blood vessels dilate/constrict
Vitamin D synthesisUV light converts precursor to Vitamin D3 in skin cells
Immune defenseLangerhans cells, dermal dendritic cells, and macrophages patrol for pathogens
WaterproofingLipid barrier in stratum granulosum prevents excessive water loss/gain

Conclusion

Skin is a remarkable, multi-layered organ. From the outermost dead keratin cells that shield you from the environment, to the living epidermis below, to the tough collagen-rich dermis packed with blood vessels, nerves, and glands, down to the fatty cushion of the hypodermis - every part has a specific job. Understanding its structure makes it easy to appreciate how skin protects, senses, and sustains life every single moment.

Sources: Histology: A Text and Atlas (Ross & Pawlina, 8th Ed.) | Junqueira's Basic Histology, 17th Ed. | Fitzpatrick's Dermatology, 9th Ed.

Create a study guide PDF on skin structure and functions

Reading File
Running Command

ls /home/daytona/workspace/ 2>/dev/null && echo "---" && python3 -c "import repo…

Running Command

mkdir -p /home/daytona/workspace/skin-study-guide && echo "dir created"

Writing File

~/skin-study-guide/generate_pdf.py

import requests
import os
from io import BytesIO
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, Image, KeepTogether, PageBreak
)
from reportlab.platypus.flowables import HRFlowable
from reportlab.pdfgen import canvas

OUTPUT = "/home/daytona/workspace/skin-study-guide/Skin_Structure_Study_Guide.pdf"

# ── Color palette ────────────────────────────────────────────────
SKIN_TAN   = colors.HexColor("#F4A460")
SKIN_PINK  = colors.HexColor("#E8A090")
DERM_BLUE  = colors.HexColor("#2E4057")
ACCENT     = colors.HexColor("#048A81")
LIGHT_BG   = colors.HexColor("#FFF8F0")
HEADER_BG  = colors.HexColor("#2E4057")
TABLE_HDR  = colors.HexColor("#048A81")
TABLE_ALT  = colors.HexColor("#F0FAF9")
YELLOW_HL  = colors.HexColor("#FFF3CD")
RED_SOFT   = colors.HexColor("#FDECEA")

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

def S(name, **kw):
    return ParagraphStyle(name, **kw)

title_style = S("Title",
    fontSize=28, textColor=colors.white, alignment=TA_CENTER,
    fontName="Helvetica-Bold", spaceAfter=4, leading=34)

subtitle_style = S("Subtitle",
    fontSize=13, textColor=colors.HexColor("#A8D8EA"),
    alignment=TA_CENTER, fontName="Helvetica", spaceAfter=2)

section_h1 = S("H1",
    fontSize=16, textColor=colors.white, fontName="Helvetica-Bold",
    spaceAfter=6, spaceBefore=14, leading=20,
    backColor=DERM_BLUE, leftIndent=-8, rightIndent=-8,
    borderPad=6)

section_h2 = S("H2",
    fontSize=13, textColor=DERM_BLUE, fontName="Helvetica-Bold",
    spaceAfter=4, spaceBefore=10, leading=16,
    borderPad=3)

section_h3 = S("H3",
    fontSize=11, textColor=ACCENT, fontName="Helvetica-Bold",
    spaceAfter=3, spaceBefore=7, leading=14)

body = S("Body",
    fontSize=10, textColor=colors.HexColor("#1a1a1a"),
    fontName="Helvetica", spaceAfter=5, leading=15,
    alignment=TA_JUSTIFY)

bullet_style = S("Bullet",
    fontSize=10, textColor=colors.HexColor("#1a1a1a"),
    fontName="Helvetica", spaceAfter=3, leading=14,
    leftIndent=14, bulletIndent=4)

caption_style = S("Caption",
    fontSize=8, textColor=colors.grey, fontName="Helvetica-Oblique",
    alignment=TA_CENTER, spaceAfter=4)

key_term = S("KeyTerm",
    fontSize=10, textColor=DERM_BLUE, fontName="Helvetica-Bold",
    spaceAfter=2, leading=14)

box_style = S("Box",
    fontSize=10, textColor=colors.HexColor("#1a1a1a"),
    fontName="Helvetica", spaceAfter=4, leading=14,
    backColor=YELLOW_HL, borderPad=6, leftIndent=6)

# ── Helper: colored heading band ────────────────────────────────
def heading_band(text, bg=DERM_BLUE, fg=colors.white, size=15):
    data = [[Paragraph(f"<font color='white'><b>{text}</b></font>",
                       ParagraphStyle("hb", fontSize=size, textColor=fg,
                                      fontName="Helvetica-Bold", leading=size+4))]]
    t = Table(data, colWidths=[175*mm])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("TOPPADDING",    (0,0), (-1,-1), 7),
        ("BOTTOMPADDING", (0,0), (-1,-1), 7),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
    ]))
    return t

def sub_heading(text, bg=ACCENT):
    data = [[Paragraph(f"<font color='white'><b>{text}</b></font>",
                       ParagraphStyle("sh", fontSize=12, textColor=colors.white,
                                      fontName="Helvetica-Bold", leading=15))]]
    t = Table(data, colWidths=[175*mm])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
    ]))
    return t

def info_box(title, text, bg=YELLOW_HL, title_color=DERM_BLUE):
    inner = [
        [Paragraph(f"<b>{title}</b>",
                   ParagraphStyle("ibt", fontSize=10, textColor=title_color,
                                  fontName="Helvetica-Bold", leading=14))],
        [Paragraph(text,
                   ParagraphStyle("ibb", fontSize=9.5, textColor=colors.HexColor("#1a1a1a"),
                                  fontName="Helvetica", leading=13))]
    ]
    t = Table(inner, colWidths=[170*mm])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("BOX",         (0,0), (-1,-1), 1, colors.HexColor("#CCC")),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
        ("RIGHTPADDING",  (0,0), (-1,-1), 8),
    ]))
    return t

def bullet(text):
    return Paragraph(f"• &nbsp; {text}", bullet_style)

def sp(h=4):
    return Spacer(1, h*mm)

def hr():
    return HRFlowable(width="100%", thickness=0.5, color=colors.HexColor("#CCCCCC"), spaceAfter=4)

# ── Download diagram image ───────────────────────────────────────
DIAGRAM_URL = "https://cdn.orris.care/cdss_images/dfa992647ec952b8f0ced9cc2efc45b077c3b741aefe6dc840d5415215a8d9e8.png"
img_path = "/home/daytona/workspace/skin-study-guide/skin_diagram.png"
if not os.path.exists(img_path):
    r = requests.get(DIAGRAM_URL, timeout=30)
    with open(img_path, "wb") as f:
        f.write(r.content)
    print("Image downloaded")

# ── Build story ──────────────────────────────────────────────────
story = []

# ════════════════════════════════════════════
# COVER PAGE
# ════════════════════════════════════════════
def cover_page(canvas_obj, doc):
    w, h = A4
    # Background gradient-like fill
    canvas_obj.setFillColor(DERM_BLUE)
    canvas_obj.rect(0, 0, w, h, fill=1, stroke=0)
    # Decorative stripe
    canvas_obj.setFillColor(ACCENT)
    canvas_obj.rect(0, h*0.38, w, 8, fill=1, stroke=0)
    canvas_obj.setFillColor(SKIN_TAN)
    canvas_obj.rect(0, h*0.38-10, w, 4, fill=1, stroke=0)

# Cover content via story (rendered over cover_page background via onFirstPage)
story.append(Spacer(1, 50*mm))

cover_title_data = [[
    Paragraph("<font color='white'><b>SKIN STRUCTURE</b></font>",
              ParagraphStyle("ct1", fontSize=36, fontName="Helvetica-Bold",
                             alignment=TA_CENTER, leading=42, textColor=colors.white)),
]]
ct = Table(cover_title_data, colWidths=[175*mm])
ct.setStyle(TableStyle([("BACKGROUND",(0,0),(-1,-1),colors.transparent)]))
story.append(ct)
story.append(sp(2))

cover_sub_data = [[
    Paragraph("<font color='#A8D8EA'>&amp; FUNCTIONS</font>",
              ParagraphStyle("ct2", fontSize=26, fontName="Helvetica-Bold",
                             alignment=TA_CENTER, leading=32, textColor=colors.HexColor("#A8D8EA"))),
]]
cs = Table(cover_sub_data, colWidths=[175*mm])
cs.setStyle(TableStyle([("BACKGROUND",(0,0),(-1,-1),colors.transparent)]))
story.append(cs)

story.append(sp(6))

# Big decorative label
badge_data = [[
    Paragraph("<font color='white'><b>STUDY GUIDE</b></font>",
              ParagraphStyle("badge", fontSize=14, fontName="Helvetica-Bold",
                             alignment=TA_CENTER, textColor=colors.white))
]]
badge = Table(badge_data, colWidths=[60*mm])
badge.setStyle(TableStyle([
    ("BACKGROUND",(0,0),(-1,-1), ACCENT),
    ("BOX",(0,0),(-1,-1),2,colors.white),
    ("TOPPADDING",(0,0),(-1,-1),6),
    ("BOTTOMPADDING",(0,0),(-1,-1),6),
    ("ALIGN",(0,0),(-1,-1),"CENTER"),
]))
story.append(Table([[badge]], colWidths=[175*mm],
             style=[("ALIGN",(0,0),(-1,-1),"CENTER")]))

story.append(sp(8))

# Skin diagram on cover
if os.path.exists(img_path):
    img = Image(img_path, width=130*mm, height=75*mm)
    story.append(Table([[img]], colWidths=[175*mm],
                 style=[("ALIGN",(0,0),(-1,-1),"CENTER")]))

story.append(sp(6))

story.append(Paragraph(
    "<font color='#CCCCCC'>Anatomy · Histology · Physiology · Clinical Relevance</font>",
    ParagraphStyle("footer_cover", fontSize=11, fontName="Helvetica",
                   alignment=TA_CENTER, textColor=colors.HexColor("#CCCCCC"))))

story.append(Paragraph(
    "<font color='#888888'>Sources: Histology: A Text &amp; Atlas (Ross &amp; Pawlina, 8th Ed.) | Junqueira's Basic Histology, 17e | Fitzpatrick's Dermatology, 9e</font>",
    ParagraphStyle("sources_cover", fontSize=8, fontName="Helvetica",
                   alignment=TA_CENTER, textColor=colors.HexColor("#888888"),
                   spaceBefore=4)))

story.append(PageBreak())

# ════════════════════════════════════════════
# PAGE 2 — OVERVIEW
# ════════════════════════════════════════════
story.append(heading_band("🧬  Overview: What is Skin?"))
story.append(sp(3))

story.append(Paragraph(
    "Skin (integument) is the <b>largest organ</b> of the human body. It forms a continuous outer covering "
    "that separates the internal environment from the external world. The total surface area of adult skin "
    "is approximately <b>1.5–2.0 m²</b>, and it accounts for about <b>15% of total body weight</b>.",
    body))

story.append(sp(2))

# 3-layer summary table
story.append(sub_heading("The Three Main Layers"))
story.append(sp(2))

layer_data = [
    ["Layer", "Also Called", "Composition", "Depth"],
    ["Epidermis", "Outer skin", "Stratified squamous keratinized epithelium", "0.05–1.5 mm"],
    ["Dermis",    "True skin",  "Dense irregular connective tissue",          "1–4 mm"],
    ["Hypodermis","Subcutaneous / superficial fascia", "Loose CT + adipose tissue", "Variable"],
]
lt = Table(layer_data, colWidths=[35*mm, 38*mm, 72*mm, 30*mm])
lt.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), TABLE_HDR),
    ("TEXTCOLOR",  (0,0), (-1,0), colors.white),
    ("FONTNAME",   (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",   (0,0), (-1,-1), 9),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.white, TABLE_ALT]),
    ("GRID",       (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ("VALIGN",     (0,0), (-1,-1), "MIDDLE"),
]))
story.append(lt)
story.append(sp(4))

story.append(info_box(
    "💡 Key Fact",
    "The epidermis has NO blood vessels — it gets all its oxygen and nutrients by diffusion from "
    "capillaries in the dermal papillae just below it.",
    bg=YELLOW_HL))
story.append(sp(4))

# Functions overview table
story.append(sub_heading("Key Functions of the Skin"))
story.append(sp(2))

func_data = [
    ["Function", "Mechanism"],
    ["Protection",       "Keratin barrier, melanin (UV shield), Langerhans cells (immune)"],
    ["Sensation",        "Free nerve endings, Meissner, Pacinian, Ruffini, Merkel corpuscles"],
    ["Thermoregulation", "Eccrine sweating, vasodilation/constriction, subcutaneous fat insulation"],
    ["Vitamin D synthesis","UV light converts 7-dehydrocholesterol → Vitamin D3 in keratinocytes"],
    ["Waterproofing",    "Lamellar body lipids in stratum granulosum form permeability barrier"],
    ["Excretion",        "Sweat removes urea, salts, and excess electrolytes"],
    ["Immunity",         "Langerhans cells (APCs), dermal dendritic cells, T-resident memory cells"],
    ["Sexual signaling", "Pigmentation, hair, apocrine pheromones act as visual/chemical signals"],
]
ft = Table(func_data, colWidths=[52*mm, 123*mm])
ft.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), TABLE_HDR),
    ("TEXTCOLOR",  (0,0), (-1,0), colors.white),
    ("FONTNAME",   (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",   (0,0), (-1,-1), 9),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.white, TABLE_ALT]),
    ("GRID",       (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ("VALIGN",     (0,0), (-1,-1), "MIDDLE"),
    ("FONTNAME",   (0,0), (0,-1), "Helvetica-Bold"),
]))
story.append(ft)

story.append(PageBreak())

# ════════════════════════════════════════════
# PAGE 3 — EPIDERMIS
# ════════════════════════════════════════════
story.append(heading_band("Layer 1: The Epidermis", bg=colors.HexColor("#5C4033")))
story.append(sp(3))

story.append(Paragraph(
    "The epidermis is the outermost, avascular layer composed primarily of <b>keratinocytes (85%)</b> "
    "that undergo continuous differentiation from base to surface. Total epidermal turnover time is "
    "approximately <b>47 days</b>. Thickness varies from <b>0.05 mm</b> on eyelids to <b>1.5 mm</b> on palms and soles.",
    body))
story.append(sp(3))

story.append(sub_heading("The 4 (or 5) Strata of the Epidermis", bg=colors.HexColor("#8B5E3C")))
story.append(sp(3))

strata_data = [
    ["Stratum", "Nickname", "Key Features", "Mnemonic"],
    ["Stratum Basale\n(deepest)", "Germinative layer",
     "• Single row of cuboidal/columnar cells\n• Mitotically active (stem cells)\n• Contains melanocytes\n• Attached by hemidesmosomes to basement membrane",
     "BASE = Birth of cells"],
    ["Stratum Spinosum", "Spiny layer",
     "• Several layers of polygonal keratinocytes\n• Connected by desmosomes at spine-like processes\n• Langerhans cells reside here\n• Keratin filaments (tonofilaments) visible",
     "SPINY = Strength"],
    ["Stratum Granulosum", "Granular layer",
     "• 3–5 layers of flattened cells\n• Keratohyalin granules (filaggrin precursor)\n• Lamellar bodies → lipid waterproof barrier\n• Cells begin to die here",
     "GRAINS = Going away"],
    ["Stratum Lucidum\n(thick skin only)", "Clear layer",
     "• Only in thick skin (palms, soles)\n• Translucent, dead cells\n• Filled with eleidin (pre-keratin)",
     "LUCID = Looks clear"],
    ["Stratum Corneum\n(outermost)", "Horny layer",
     "• 15–20 layers of dead, anucleate cells\n• Packed with hard keratin\n• Constantly desquamating\n• Main barrier to environment",
     "CORNEUM = Corny tough skin"],
]
st = Table(strata_data, colWidths=[34*mm, 30*mm, 75*mm, 36*mm])
st.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#8B5E3C")),
    ("TEXTCOLOR",  (0,0), (-1,0), colors.white),
    ("FONTNAME",   (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",   (0,0), (-1,-1), 8.5),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.white, colors.HexColor("#FFF5EE")]),
    ("GRID",       (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ("VALIGN",     (0,0), (-1,-1), "TOP"),
]))
story.append(st)
story.append(sp(4))

story.append(info_box(
    "🔑 Memory Trick — Layers from deep to superficial:",
    "\"<b>Baby Skin Grows Like Crazy</b>\" → Basale · Spinosum · Granulosum · Lucidum · Corneum",
    bg=colors.HexColor("#E8F4FD")))
story.append(sp(4))

# Special cells
story.append(sub_heading("Special Cells of the Epidermis", bg=colors.HexColor("#8B5E3C")))
story.append(sp(2))

cell_data = [
    ["Cell Type", "%", "Location", "Function"],
    ["Keratinocytes",    "~85%", "All layers",     "Produce keratin; form structural/barrier layers"],
    ["Melanocytes",      "~5%",  "Stratum basale", "Produce melanin → UV protection; donate pigment to keratinocytes"],
    ["Langerhans cells", "2–5%", "Stratum spinosum","Antigen-presenting cells (APCs); immune surveillance"],
    ["Merkel cells",     "6–10%","Stratum basale", "Mechanoreceptors for fine touch; associated with nerve endings"],
]
ct2 = Table(cell_data, colWidths=[38*mm, 14*mm, 38*mm, 85*mm])
ct2.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#8B5E3C")),
    ("TEXTCOLOR",  (0,0), (-1,0), colors.white),
    ("FONTNAME",   (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",   (0,0), (-1,-1), 9),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.white, colors.HexColor("#FFF5EE")]),
    ("GRID",       (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ("VALIGN",     (0,0), (-1,-1), "MIDDLE"),
]))
story.append(ct2)

story.append(PageBreak())

# ════════════════════════════════════════════
# PAGE 4 — DERMIS
# ════════════════════════════════════════════
story.append(heading_band("Layer 2: The Dermis", bg=colors.HexColor("#1B4332")))
story.append(sp(3))

story.append(Paragraph(
    "The dermis is the thick middle layer of connective tissue that gives skin its <b>strength, "
    "elasticity, and flexibility</b>. It is composed primarily of <b>type I collagen</b> (the most "
    "abundant protein), elastic fibers, and ground substance. The dermis is <b>1–4 mm thick</b> and "
    "houses blood vessels, lymphatics, nerves, and skin appendages.",
    body))
story.append(sp(3))

story.append(sub_heading("Two Layers of the Dermis", bg=colors.HexColor("#2D6A4F")))
story.append(sp(2))

dermis_data = [
    ["Feature",             "Papillary Layer (upper)",                "Reticular Layer (lower)"],
    ["Composition",         "Loose connective tissue",                "Dense irregular connective tissue"],
    ["Collagen",            "Type I + III (thin fibers)",             "Type I (thick bundles)"],
    ["Blood vessels",       "Rich capillary plexus",                  "Larger arteries and veins"],
    ["Nerve endings",       "Meissner corpuscles, free endings",      "Pacinian, Ruffini corpuscles"],
    ["Special feature",     "Dermal papillae (fingerprints!)",        "Sebaceous glands, hair follicles"],
    ["Primary function",    "Nourish epidermis, fine sensation",      "Structural strength, elasticity"],
]
dt = Table(dermis_data, colWidths=[42*mm, 66*mm, 67*mm])
dt.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#2D6A4F")),
    ("TEXTCOLOR",  (0,0), (-1,0), colors.white),
    ("FONTNAME",   (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTNAME",   (0,1), (0,-1), "Helvetica-Bold"),
    ("TEXTCOLOR",  (0,1), (0,-1), colors.HexColor("#1B4332")),
    ("FONTSIZE",   (0,0), (-1,-1), 9),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.white, colors.HexColor("#D8F3DC")]),
    ("GRID",       (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ("VALIGN",     (0,0), (-1,-1), "MIDDLE"),
]))
story.append(dt)
story.append(sp(4))

story.append(sub_heading("Sensory Receptors in the Skin", bg=colors.HexColor("#2D6A4F")))
story.append(sp(2))

receptor_data = [
    ["Receptor",             "Location",          "Detects",                "Type"],
    ["Free nerve endings",   "Epidermis",         "Pain, heat, cold, itch", "Non-encapsulated"],
    ["Merkel corpuscles",    "Dermo-epidermal jxn","Sustained pressure, texture","Non-encapsulated"],
    ["Meissner corpuscles",  "Dermal papillae",   "Light touch, 2-pt discrimination","Encapsulated"],
    ["Pacinian corpuscles",  "Deep dermis / hypodermis","Deep pressure, vibration","Encapsulated"],
    ["Ruffini corpuscles",   "Deep dermis",       "Skin stretch and torque", "Encapsulated"],
]
rt = Table(receptor_data, colWidths=[45*mm, 40*mm, 55*mm, 35*mm])
rt.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#2D6A4F")),
    ("TEXTCOLOR",  (0,0), (-1,0), colors.white),
    ("FONTNAME",   (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",   (0,0), (-1,-1), 9),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.white, colors.HexColor("#D8F3DC")]),
    ("GRID",       (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ("VALIGN",     (0,0), (-1,-1), "MIDDLE"),
]))
story.append(rt)
story.append(sp(4))

story.append(sub_heading("Immune Cells of the Dermis", bg=colors.HexColor("#2D6A4F")))
story.append(sp(2))

story.append(bullet("<b>Dermal fibroblasts</b> — Express toll-like receptors; produce inflammatory cytokines when they detect pathogens"))
story.append(bullet("<b>Dermal dendritic cells</b> — Present antigens to T-cells; migrate to lymph nodes to initiate immune response"))
story.append(bullet("<b>Resident macrophages</b> — Yolk sac-derived APCs; respond to foreign substances and tissue damage"))
story.append(bullet("<b>T-resident memory (T<sub>rm</sub>) cells</b> — Non-circulating memory T-cells that provide rapid local immunity"))

story.append(PageBreak())

# ════════════════════════════════════════════
# PAGE 5 — HYPODERMIS + APPENDAGES
# ════════════════════════════════════════════
story.append(heading_band("Layer 3: Hypodermis  &amp;  Skin Appendages", bg=colors.HexColor("#4A235A")))
story.append(sp(3))

story.append(sub_heading("Hypodermis (Subcutaneous Tissue)", bg=colors.HexColor("#6C3483")))
story.append(sp(2))

story.append(Paragraph(
    "The hypodermis lies beneath the dermis and connects skin to underlying fascia and muscle. "
    "It is <b>not technically part of the skin</b> itself but is functionally inseparable from it.",
    body))
story.append(sp(2))

hypo_data = [
    ["Component",          "Function"],
    ["Adipocytes (fat cells)", "Energy storage, thermal insulation, mechanical cushioning"],
    ["Areolar connective tissue","Loose framework allowing skin mobility over deep structures"],
    ["Large blood vessels", "Feed the dermal capillary network"],
    ["Nerve trunks",       "Branch into smaller nerve fibers supplying dermis and epidermis"],
    ["Pacinian corpuscles","Deep pressure and vibration sensing"],
]
ht = Table(hypo_data, colWidths=[60*mm, 115*mm])
ht.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#6C3483")),
    ("TEXTCOLOR",  (0,0), (-1,0), colors.white),
    ("FONTNAME",   (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",   (0,0), (-1,-1), 9),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.white, colors.HexColor("#F5EEF8")]),
    ("GRID",       (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ("VALIGN",     (0,0), (-1,-1), "MIDDLE"),
]))
story.append(ht)
story.append(sp(4))

story.append(sub_heading("Skin Appendages", bg=colors.HexColor("#6C3483")))
story.append(sp(3))

appendage_data = [
    ["Appendage",       "Origin",        "Structure",                             "Function"],
    ["Hair follicle",   "Epidermis",     "Tube extending into dermis/hypodermis; hair bulb at base with matrix cells","Thermoregulation, sensory, protection; stem cell reservoir"],
    ["Sebaceous glands","Epidermis",     "Acinar glands; secretion via pilosebaceous canal","Produce sebum (holocrine); moisturize hair and skin; antimicrobial"],
    ["Eccrine sweat\nglands","Epidermis","Coiled tubular; open directly on skin surface","Thermoregulation via evaporative cooling; found all over body"],
    ["Apocrine sweat\nglands","Epidermis","Coiled tubular; open into hair follicle","Protein-rich secretion; pheromone signaling; limited to axillae, groin"],
    ["Nails",           "Epidermis",     "Hard keratin plates; grow from nail root (nail matrix)","Protection of fingertips; fine manipulation"],
    ["Arrector pili\nmuscle","Dermis",   "Smooth muscle attached to hair follicle","Contracts in cold/fear → erects hair → 'goosebumps' (piloerection)"],
]
at = Table(appendage_data, colWidths=[30*mm, 22*mm, 65*mm, 58*mm])
at.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#6C3483")),
    ("TEXTCOLOR",  (0,0), (-1,0), colors.white),
    ("FONTNAME",   (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",   (0,0), (-1,-1), 8.5),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.white, colors.HexColor("#F5EEF8")]),
    ("GRID",       (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ("VALIGN",     (0,0), (-1,-1), "TOP"),
]))
story.append(at)

story.append(PageBreak())

# ════════════════════════════════════════════
# PAGE 6 — DIAGRAM + CLINICAL NOTES
# ════════════════════════════════════════════
story.append(heading_band("Skin Diagram + Clinical Relevance", bg=DERM_BLUE))
story.append(sp(3))

if os.path.exists(img_path):
    img2 = Image(img_path, width=155*mm, height=92*mm)
    story.append(Table([[img2]], colWidths=[175*mm],
                 style=[("ALIGN",(0,0),(-1,-1),"CENTER")]))
    story.append(Paragraph(
        "Cross-section of skin showing all three main layers with hair follicles, blood vessels, dermal papillae, "
        "sensory receptors, and adipocytes. (Source: Junqueira's Basic Histology, 17e)",
        caption_style))
story.append(sp(3))

story.append(sub_heading("Clinical Relevance", bg=ACCENT))
story.append(sp(3))

clinical = [
    ("Melanoma", "Malignant transformation of melanocytes; excess UV exposure is the main risk factor. "
                 "ABCDE rule: Asymmetry, Border, Color, Diameter, Evolution."),
    ("Psoriasis","Rapid epidermal turnover (7 days vs normal 47 days) due to immune-mediated inflammation. "
                 "Results in thickened, scaly plaques from stratum corneum buildup."),
    ("Burns",    "Classified by depth of skin damage:\n"
                 "• 1st degree: Epidermis only (sunburn)\n"
                 "• 2nd degree: Epidermis + partial dermis (blisters)\n"
                 "• 3rd degree: Full thickness (epidermis + all dermis, may need grafting)"),
    ("Pressure Ulcers","Prolonged pressure occludes dermal capillaries → ischemia → necrosis, "
                 "starting deep in the hypodermis and progressing outward."),
    ("Vitiligo", "Autoimmune destruction of melanocytes → patchy loss of skin pigmentation."),
    ("Acne Vulgaris","Blockage of pilosebaceous canal by excess sebum + dead keratinocytes + "
                 "Cutibacterium acnes colonization → follicular inflammation."),
]
for title, text in clinical:
    story.append(info_box(title, text, bg=colors.HexColor("#EBF5FB"),
                          title_color=DERM_BLUE))
    story.append(sp(2))

story.append(PageBreak())

# ════════════════════════════════════════════
# PAGE 7 — QUICK REVIEW / FLASHCARD SECTION
# ════════════════════════════════════════════
story.append(heading_band("Quick Review: Key Facts &amp; Q&amp;A", bg=colors.HexColor("#922B21")))
story.append(sp(3))

story.append(sub_heading("Important Numbers to Remember", bg=colors.HexColor("#C0392B")))
story.append(sp(2))

numbers_data = [
    ["Fact",                             "Value"],
    ["Epidermal turnover time",          "~47 days"],
    ["Skin surface area (adult)",        "1.5–2.0 m²"],
    ["% body weight",                    "~15%"],
    ["Epidermis thickness (thin skin)",  "0.05–0.1 mm"],
    ["Epidermis thickness (thick skin)", "Up to 1.5 mm"],
    ["Dermis thickness",                 "1–4 mm"],
    ["Keratinocytes % in epidermis",     "~85%"],
    ["Melanocytes % in epidermis",       "~5%"],
    ["Langerhans cells % in epidermis",  "2–5%"],
    ["Merkel cells % in epidermis",      "6–10%"],
    ["UV wavelength (damage range)",     "280–320 nm (UVB)"],
]
nt = Table(numbers_data, colWidths=[110*mm, 65*mm])
nt.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#C0392B")),
    ("TEXTCOLOR",  (0,0), (-1,0), colors.white),
    ("FONTNAME",   (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",   (0,0), (-1,-1), 9),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.white, colors.HexColor("#FDEDEC")]),
    ("GRID",       (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 5),
    ("VALIGN",     (0,0), (-1,-1), "MIDDLE"),
]))
story.append(nt)
story.append(sp(5))

story.append(sub_heading("Practice Q&amp;A", bg=colors.HexColor("#C0392B")))
story.append(sp(3))

qa = [
    ("Q1. Which layer of the epidermis forms the main waterproof barrier?",
     "A. Stratum granulosum — lamellar bodies release lipids that form the epidermal permeability barrier."),
    ("Q2. Why does the epidermis have no blood vessels?",
     "A. It is avascular; all nutrients diffuse from capillaries in the dermal papillae (papillary dermis)."),
    ("Q3. What are the functions of melanocytes and where are they located?",
     "A. Located in stratum basale; produce melanin in melanosomes and donate it to keratinocytes; "
     "melanin acts as a UV shield to protect nuclear DNA."),
    ("Q4. What is the difference between eccrine and apocrine sweat glands?",
     "A. Eccrine: found all over body, open directly on skin surface, produce watery sweat for thermoregulation. "
     "Apocrine: found in axillae/groin, open into hair follicles, produce protein-rich secretion involved in signaling."),
    ("Q5. Name the 5 strata of thick skin from deep to superficial.",
     "A. Basale → Spinosum → Granulosum → Lucidum → Corneum. "
     "Memory: 'Baby Skin Grows Like Crazy'"),
    ("Q6. What is the role of dermal papillae?",
     "A. Finger-like upward projections of dermis that interdigitate with epidermal ridges, "
     "increasing surface area for attachment; contain capillaries and sensory nerve endings; "
     "form the basis of fingerprints."),
    ("Q7. Which receptor detects vibration and deep pressure?",
     "A. Pacinian corpuscles (located in deep dermis and hypodermis)."),
    ("Q8. What is sebum and how is it secreted?",
     "A. Sebum is an oily substance produced by sebaceous glands via holocrine secretion "
     "(the entire cell breaks down to release its contents); lubricates hair and skin."),
]
for i, (q, a) in enumerate(qa):
    qcolor = colors.HexColor("#FDEDEC") if i % 2 == 0 else colors.HexColor("#FFF5F5")
    qa_data = [
        [Paragraph(q, ParagraphStyle("qp", fontSize=9.5, fontName="Helvetica-Bold",
                                      textColor=colors.HexColor("#922B21"), leading=13))],
        [Paragraph(a, ParagraphStyle("ap", fontSize=9, fontName="Helvetica",
                                      textColor=colors.HexColor("#1a1a1a"), leading=13))],
    ]
    qt = Table(qa_data, colWidths=[175*mm])
    qt.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (0,0), colors.HexColor("#FDEDEC")),
        ("BACKGROUND", (0,1), (0,1), colors.white),
        ("BOX",        (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
        ("RIGHTPADDING",  (0,0), (-1,-1), 8),
    ]))
    story.append(qt)
    story.append(sp(2))

story.append(PageBreak())

# ════════════════════════════════════════════
# PAGE 8 — SUMMARY TABLE (MASTER OVERVIEW)
# ════════════════════════════════════════════
story.append(heading_band("Master Summary Table", bg=colors.HexColor("#0B3954")))
story.append(sp(3))

master_data = [
    ["Structure",           "Layer",        "Cell/Component",        "Key Function"],
    # Epidermis
    ["Stratum Basale",      "Epidermis",    "Keratinocytes, melanocytes, Merkel cells","Cell division, pigment production, touch reception"],
    ["Stratum Spinosum",    "Epidermis",    "Keratinocytes, Langerhans cells","Structural strength, immune surveillance"],
    ["Stratum Granulosum",  "Epidermis",    "Keratinocytes + lamellar bodies","Waterproofing (lipid barrier), keratinization"],
    ["Stratum Lucidum",     "Epidermis\n(thick skin only)","Dead keratinocytes with eleidin","Transitional clear zone"],
    ["Stratum Corneum",     "Epidermis",    "Anucleate keratinocytes (squames)","Main protective barrier, desquamation"],
    # Dermis
    ["Papillary layer",     "Dermis",       "Loose CT, capillaries, Meissner corpuscles","Nourish epidermis, light touch"],
    ["Reticular layer",     "Dermis",       "Dense CT, collagen I, elastic fibers","Strength, elasticity, houses appendages"],
    ["Dermal papillae",     "Dermis",       "Capillary loops + nerve endings","Fingerprints, epidermal nutrition"],
    # Hypodermis
    ["Hypodermis",          "Subcutaneous", "Adipocytes, loose CT","Insulation, energy, cushioning"],
    # Appendages
    ["Sebaceous gland",     "Appendage",    "Sebocytes",             "Sebum production (holocrine), lubrication"],
    ["Eccrine sweat gland", "Appendage",    "Secretory + ductal cells","Thermoregulation (watery sweat)"],
    ["Apocrine gland",      "Appendage",    "Secretory cells",       "Pheromone signaling (axillae/groin)"],
    ["Hair follicle",       "Appendage",    "Matrix cells, bulge stem cells","Hair formation, stem cell niche"],
    ["Nail",                "Appendage",    "Hard keratin plate",    "Finger protection, fine manipulation"],
    ["Arrector pili",       "Appendage",    "Smooth muscle",         "Piloerection (goosebumps)"],
]
mst = Table(master_data, colWidths=[38*mm, 28*mm, 52*mm, 57*mm])
mst.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#0B3954")),
    ("TEXTCOLOR",  (0,0), (-1,0), colors.white),
    ("FONTNAME",   (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",   (0,0), (-1,-1), 8.5),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.white, colors.HexColor("#EBF5FB")]),
    ("GRID",       (0,0), (-1,-1), 0.4, colors.HexColor("#BBBBBB")),
    ("TOPPADDING",    (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING",   (0,0), (-1,-1), 4),
    ("VALIGN",     (0,0), (-1,-1), "MIDDLE"),
    # Color-code rows by section
    ("BACKGROUND", (0,1),  (-1,5),  colors.HexColor("#FFF8F0")),   # epidermis
    ("BACKGROUND", (0,6),  (-1,9),  colors.HexColor("#F0FAF0")),   # dermis
    ("BACKGROUND", (0,10), (-1,10), colors.HexColor("#FAF0FA")),   # hypodermis
    ("BACKGROUND", (0,11), (-1,-1), colors.HexColor("#F0F0FA")),   # appendages
]))
story.append(mst)
story.append(sp(5))

story.append(Paragraph(
    "<b>Color coding:</b> &nbsp; "
    "<font color='#A0522D'>■</font> Epidermis &nbsp;&nbsp; "
    "<font color='#2D6A4F'>■</font> Dermis &nbsp;&nbsp; "
    "<font color='#6C3483'>■</font> Hypodermis &nbsp;&nbsp; "
    "<font color='#2E4057'>■</font> Appendages",
    ParagraphStyle("legend", fontSize=9, fontName="Helvetica",
                   alignment=TA_CENTER, textColor=colors.HexColor("#555555"))))

story.append(sp(5))
story.append(hr())
story.append(sp(2))
story.append(Paragraph(
    "<i>Sources: Histology: A Text &amp; Atlas (Ross &amp; Pawlina, 8th Ed.) | "
    "Junqueira's Basic Histology, 17e | Fitzpatrick's Dermatology, 9th Ed. | "
    "Campbell-Walsh-Wein Urology, 12e</i>",
    ParagraphStyle("bib", fontSize=8, fontName="Helvetica-Oblique",
                   alignment=TA_CENTER, textColor=colors.grey)))

# ── Build PDF ────────────────────────────────────────────────────
def on_first_page(c, doc):
    w, h = A4
    c.saveState()
    c.setFillColor(DERM_BLUE)
    c.rect(0, 0, w, h, fill=1, stroke=0)
    c.setFillColor(ACCENT)
    c.rect(0, h*0.38, w, 8, fill=1, stroke=0)
    c.setFillColor(SKIN_TAN)
    c.rect(0, h*0.38-10, w, 4, fill=1, stroke=0)
    c.restoreState()

def on_later_pages(c, doc):
    w, h = A4
    c.saveState()
    # Header bar
    c.setFillColor(DERM_BLUE)
    c.rect(0, h-15*mm, w, 15*mm, fill=1, stroke=0)
    c.setFillColor(colors.white)
    c.setFont("Helvetica-Bold", 9)
    c.drawString(18*mm, h-9*mm, "SKIN STRUCTURE & FUNCTIONS — STUDY GUIDE")
    c.setFont("Helvetica", 9)
    c.drawRightString(w-18*mm, h-9*mm, f"Page {doc.page}")
    # Footer bar
    c.setFillColor(colors.HexColor("#EEEEEE"))
    c.rect(0, 0, w, 10*mm, fill=1, stroke=0)
    c.setFillColor(colors.HexColor("#888888"))
    c.setFont("Helvetica", 7)
    c.drawCentredString(w/2, 3.5*mm,
        "Sources: Histology: A Text & Atlas (Ross & Pawlina, 8e) | Junqueira's Basic Histology, 17e | Fitzpatrick's Dermatology, 9e")
    c.restoreState()

doc = SimpleDocTemplate(
    OUTPUT, pagesize=A4,
    topMargin=20*mm, bottomMargin=15*mm,
    leftMargin=17*mm, rightMargin=17*mm,
    title="Skin Structure & Functions Study Guide",
    author="Orris Medical"
)

doc.build(story,
          onFirstPage=on_first_page,
          onLaterPages=on_later_pages)

print(f"PDF created: {OUTPUT}")
Running Command

cd /home/daytona/workspace/skin-study-guide && python3 generate_pdf.py 2>&1

Running Command

ls -lh /home/daytona/workspace/skin-study-guide/Skin_Structure_Study_Guide.pdf

Your study guide PDF is ready (1.2 MB, 8 pages):

Skin Structure Study Guide

PDF Document · PDF


Here's what's inside across the 8 pages:
PageContent
1 - CoverTitle page with the full skin cross-section diagram
2 - OverviewWhat skin is, the 3-layer summary table, 8 key functions table
3 - EpidermisAll 5 strata with features + mnemonic, special cells table (melanocytes, Langerhans, Merkel)
4 - DermisPapillary vs reticular layer comparison, sensory receptors table, immune cells
5 - Hypodermis & AppendagesHypodermis components, all 6 appendages (hair, sebaceous, eccrine, apocrine, nails, arrector pili)
6 - Diagram + ClinicalLabeled skin diagram, 6 clinical conditions (melanoma, psoriasis, burns, acne, vitiligo, pressure ulcers)
7 - Quick Review Q&AKey numbers table + 8 practice questions with full answers
8 - Master SummaryColor-coded mega-table covering every structure, layer, cell, and function

rough diagram of pituitary gland

Generating Image

Rough hand-drawn style anatomical diagram of the pituitary gland (hypophysis) showing: anterior lobe (adenohypophysis) and posterior lobe (neurohypophysis), pars tuberalis, pars intermedia, infundibulum/pituitary stalk connecting to hypothalamus, optic chiasm above, sella turcica bony cavity, labeled arrows pointing to each part, simple sketch style with clear labels

!

400, message: Got more than 4194304 bytes when reading: b'data: {"candidates": [{"content": {"role": "model","parts": [{"inlineData": {"mimeType": "image/png"...'.

We encountered an error while processing your request. Please try again or reach out to us for help.

This is a shared conversation. Sign in to Orris to start your own chat.