// endocrine.sy -- All endocrine glands, hormones, feedback axes,
// and clinical endocrinology as native Scyla.
//
// The endocrine system is the body's long-range signaling network. Where the
// nervous system signals in milliseconds via action potentials, the endocrine
// system signals in minutes to hours via hormones carried in blood. These two
// systems are not separate -- they converge at the hypothalamus, which is
// both a neural structure and a master endocrine gland. Every feedback axis
// encoded here is a biological control loop: sensor, integrator, effector.
//
// This module encodes the complete hypothalamic-pituitary-target gland axes,
// all major hormones with their receptors and clinical pathology, the adrenal
// cortex zonation and steroidogenesis pathway, the catecholamine synthesis
// pathway, pancreatic islet cell signaling, gonadal steroidogenesis, and the
// receptor classification system that determines how each hormone acts.
//
// Sources:
//   Guyton AC, Hall JE. Textbook of Medical Physiology, 14th ed, 2021.
//   Boron WF, Boulpaep EL. Medical Physiology, 3rd ed, 2017.
//   Molina PE. Endocrine Physiology, 5th ed, 2018.
//   UniProt Consortium. UniProt: the Universal Protein Knowledgebase, 2025.
//
// Marjorie McCubbins + Aether, April 2026
// Patent pending: 64/034,536


// ═══════════════════════════════════════════════════════════════════
// STRUCTS
// ═══════════════════════════════════════════════════════════════════

struct Hormone {
    name: String,
    source_gland: String,
    target: String,
    mechanism: String,
    clinical: String,
    citation: String,
}

struct Enzyme {
    name: String,
    gene: String,
    uniprot: String,
    reaction: String,
    clinical: String,
    citation: String,
}

struct Receptor {
    name: String,
    receptor_type: String,
    uniprot: String,
    ligand: String,
    signaling: String,
    clinical: String,
    citation: String,
}

struct FeedbackAxis {
    name: String,
    step_one: String,
    step_two: String,
    step_three: String,
    negative_feedback: String,
    clinical_excess: String,
    clinical_deficiency: String,
    citation: String,
}

struct AdrenalZone {
    zone_name: String,
    location: String,
    primary_product: String,
    regulator: String,
    key_enzyme: String,
    enzyme_uniprot: String,
    clinical: String,
    citation: String,
}

struct CatecholamineSynthStep {
    step_number: Int,
    substrate: String,
    product: String,
    enzyme_name: String,
    enzyme_gene: String,
    enzyme_uniprot: String,
    cofactor: String,
    location: String,
    citation: String,
}

struct IsletCell {
    cell_type: String,
    percentage: Float,
    hormone_produced: String,
    primary_stimulus: String,
    primary_action: String,
    clinical: String,
    citation: String,
}

struct ReceptorClass {
    class_name: String,
    hormone_examples: String,
    location: String,
    signaling_mechanism: String,
    onset_speed: String,
    duration: String,
    citation: String,
}


// ═══════════════════════════════════════════════════════════════════
// CONSTRUCTORS
// ═══════════════════════════════════════════════════════════════════

fn hormone(n: String, sg: String, t: String, m: String, cl: String, ci: String) -> Hormone {
    return Hormone { name: n, source_gland: sg, target: t, mechanism: m, clinical: cl, citation: ci }
}

fn enzyme(n: String, g: String, u: String, r: String, cl: String, ci: String) -> Enzyme {
    return Enzyme { name: n, gene: g, uniprot: u, reaction: r, clinical: cl, citation: ci }
}

fn receptor(n: String, rt: String, u: String, l: String, s: String, cl: String, ci: String) -> Receptor {
    return Receptor { name: n, receptor_type: rt, uniprot: u, ligand: l, signaling: s, clinical: cl, citation: ci }
}

fn feedback_axis(n: String, s1: String, s2: String, s3: String, nf: String, ce: String, cd: String, ci: String) -> FeedbackAxis {
    return FeedbackAxis { name: n, step_one: s1, step_two: s2, step_three: s3, negative_feedback: nf, clinical_excess: ce, clinical_deficiency: cd, citation: ci }
}

fn adrenal_zone(zn: String, lo: String, pp: String, rg: String, ke: String, eu: String, cl: String, ci: String) -> AdrenalZone {
    return AdrenalZone { zone_name: zn, location: lo, primary_product: pp, regulator: rg, key_enzyme: ke, enzyme_uniprot: eu, clinical: cl, citation: ci }
}

fn cat_step(sn: Int, su: String, pr: String, en: String, eg: String, eu: String, co: String, lo: String, ci: String) -> CatecholamineSynthStep {
    return CatecholamineSynthStep { step_number: sn, substrate: su, product: pr, enzyme_name: en, enzyme_gene: eg, enzyme_uniprot: eu, cofactor: co, location: lo, citation: ci }
}

fn islet_cell(ct: String, pct: Float, hp: String, ps: String, pa: String, cl: String, ci: String) -> IsletCell {
    return IsletCell { cell_type: ct, percentage: pct, hormone_produced: hp, primary_stimulus: ps, primary_action: pa, clinical: cl, citation: ci }
}

fn receptor_class(cn: String, he: String, lo: String, sm: String, os: String, du: String, ci: String) -> ReceptorClass {
    return ReceptorClass { class_name: cn, hormone_examples: he, location: lo, signaling_mechanism: sm, onset_speed: os, duration: du, citation: ci }
}


// ═══════════════════════════════════════════════════════════════════
// SECTION I: HYPOTHALAMIC HORMONES
// ═══════════════════════════════════════════════════════════════════
//
// The hypothalamus sits at the base of the diencephalon, surrounding the
// third ventricle. It receives neural input from the limbic system, retina,
// and visceral afferents, and converts neural signals into hormonal output.
// Releasing and inhibiting hormones travel via the hypothalamic-hypophyseal
// portal system to the anterior pituitary. Magnocellular neurons project
// directly to the posterior pituitary.
//
// The portal system is key: hypothalamic hormones are released into portal
// capillaries in the median eminence, travel down the pituitary stalk, and
// reach anterior pituitary cells at concentrations far higher than systemic
// blood would achieve. This is targeted endocrine signaling.

fn lookup_hypothalamic_hormone(name: String) -> Hormone {
    if name == "CRH" {
        return hormone(
            "Corticotropin-releasing hormone (CRH)",
            "Hypothalamus (paraventricular nucleus)",
            "Anterior pituitary corticotrophs",
            "41-amino-acid peptide. Binds CRH-R1 (GPCR, Gs-coupled). Activates adenylyl cyclase, raises cAMP, activates PKA. Stimulates POMC gene transcription and ACTH secretion. Also released from placenta during pregnancy. Half-life ~60 min in plasma.",
            "Elevated in stress, depression, anxiety disorders. CRH stimulation test differentiates Cushing disease (pituitary responds) from ectopic ACTH (no response). Placental CRH rises exponentially in third trimester.",
            "Guyton 14th ed, Ch 77; Boron 3rd ed, Ch 50"
        )
    }
    if name == "TRH" {
        return hormone(
            "Thyrotropin-releasing hormone (TRH)",
            "Hypothalamus (paraventricular nucleus)",
            "Anterior pituitary thyrotrophs and lactotrophs",
            "Tripeptide (pGlu-His-Pro-NH2), smallest known hormone. Binds TRH-R1 (GPCR, Gq-coupled). Activates phospholipase C, raises IP3 and DAG, releases intracellular Ca2+. Stimulates TSH and prolactin secretion. Processed from a 242-residue preprohormone.",
            "TRH stimulation test: IV TRH should raise TSH. Flat response suggests secondary hypothyroidism (pituitary failure). Exaggerated response suggests primary hypothyroidism. Also stimulates prolactin -- explains galactorrhea in severe hypothyroidism.",
            "Guyton 14th ed, Ch 77; Boron 3rd ed, Ch 49"
        )
    }
    if name == "GnRH" {
        return hormone(
            "Gonadotropin-releasing hormone (GnRH)",
            "Hypothalamus (arcuate nucleus, preoptic area)",
            "Anterior pituitary gonadotrophs",
            "Decapeptide. Must be released in pulsatile fashion (every 60-120 min) to be effective. Binds GnRH-R (GPCR, Gq-coupled). Activates PLC-IP3-Ca2+ cascade. Stimulates both FSH and LH secretion. Continuous (non-pulsatile) GnRH paradoxically suppresses gonadotropins by receptor downregulation.",
            "Pulsatile GnRH used to treat hypogonadotropic hypogonadism (Kallmann syndrome). Continuous GnRH agonists (leuprolide, goserelin) used to suppress gonadotropins in prostate cancer, endometriosis, precocious puberty, and transgender hormone therapy.",
            "Guyton 14th ed, Ch 81-82; Boron 3rd ed, Ch 55-56"
        )
    }
    if name == "GHRH" {
        return hormone(
            "Growth hormone-releasing hormone (GHRH)",
            "Hypothalamus (arcuate nucleus)",
            "Anterior pituitary somatotrophs",
            "44-amino-acid peptide. Binds GHRH-R (GPCR, Gs-coupled). Raises cAMP via adenylyl cyclase. Stimulates GH gene transcription and GH secretion. Released in pulsatile fashion, especially during slow-wave sleep.",
            "GHRH excess (rare, usually ectopic from pancreatic tumors) causes acromegaly. GHRH receptor mutations cause isolated GH deficiency. Tesamorelin (GHRH analogue) approved for HIV-associated lipodystrophy.",
            "Guyton 14th ed, Ch 76; Boron 3rd ed, Ch 48"
        )
    }
    if name == "somatostatin" {
        return hormone(
            "Somatostatin (SST, GHIH)",
            "Hypothalamus (periventricular nucleus); also pancreatic delta cells, GI tract, and scattered neurons",
            "Anterior pituitary somatotrophs (inhibits GH); also inhibits TSH, insulin, glucagon, gastrin, secretin, VIP",
            "Exists as SST-14 and SST-28 forms. Binds SSTR1-5 (GPCRs, Gi-coupled). Inhibits adenylyl cyclase, lowers cAMP. Also activates K+ channels (hyperpolarization) and inhibits Ca2+ channels. Net effect: broad inhibition of secretion.",
            "Octreotide and lanreotide (SST analogues) used for acromegaly, carcinoid tumors, VIPomas, and variceal bleeding. Somatostatin receptor scintigraphy (OctreoScan) localizes neuroendocrine tumors. SST-producing tumors (somatostatinoma) cause diabetes, gallstones, steatorrhea.",
            "Guyton 14th ed, Ch 76-78; Boron 3rd ed, Ch 48"
        )
    }
    if name == "dopamine" {
        return hormone(
            "Dopamine (prolactin-inhibiting factor, PIF)",
            "Hypothalamus (arcuate nucleus, tuberoinfundibular pathway)",
            "Anterior pituitary lactotrophs",
            "Catecholamine neurotransmitter acting as a hormone in this context. Released tonically into portal blood. Binds D2 receptors (GPCR, Gi-coupled) on lactotrophs. Inhibits adenylyl cyclase, lowers cAMP, suppresses prolactin gene transcription and secretion. Prolactin is the only anterior pituitary hormone under tonic INHIBITION.",
            "Dopamine antagonists (antipsychotics: haloperidol, risperidone) block D2 receptors, causing hyperprolactinemia, galactorrhea, amenorrhea. Dopamine agonists (cabergoline, bromocriptine) treat prolactinomas. Pituitary stalk compression disrupts dopamine delivery, causing mild hyperprolactinemia (stalk effect, prolactin usually <100 ng/mL vs prolactinoma >200).",
            "Guyton 14th ed, Ch 76; Boron 3rd ed, Ch 48"
        )
    }
    return hormone("", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION II: ANTERIOR PITUITARY HORMONES
// ═══════════════════════════════════════════════════════════════════
//
// The anterior pituitary (adenohypophysis) develops from Rathke's pouch,
// an invagination of oral ectoderm. It contains five cell types producing
// six hormones:
//   Somatotrophs (GH) ~50% of cells
//   Lactotrophs (prolactin) ~15-25%
//   Corticotrophs (ACTH) ~15-20%
//   Thyrotrophs (TSH) ~5%
//   Gonadotrophs (FSH, LH) ~10%
//
// All anterior pituitary hormones are regulated by hypothalamic releasing
// and inhibiting hormones arriving via the portal system, plus feedback
// from target gland hormones.

fn lookup_anterior_pituitary(name: String) -> Hormone {
    if name == "ACTH" {
        return hormone(
            "Adrenocorticotropic hormone (ACTH, corticotropin)",
            "Anterior pituitary corticotrophs",
            "Adrenal cortex (zona fasciculata primarily)",
            "39-amino-acid peptide cleaved from POMC (proopiomelanocortin, 241 aa). Binds MC2R (melanocortin-2 receptor, GPCR, Gs-coupled, UniProt Q01718). Activates adenylyl cyclase, raises cAMP, activates PKA. Stimulates steroidogenesis: upregulates StAR protein (cholesterol transport into mitochondria) and steroidogenic enzymes. Also has trophic effect on adrenal cortex (maintains gland size).",
            "Cushing disease: ACTH-secreting pituitary adenoma causes bilateral adrenal hyperplasia and cortisol excess. Ectopic ACTH (small cell lung cancer) causes severe Cushing syndrome. Addison disease: autoimmune adrenal destruction causes low cortisol, high ACTH (loss of feedback), hyperpigmentation (ACTH cross-reacts with MC1R in skin).",
            "Guyton 14th ed, Ch 77-78; Boron 3rd ed, Ch 50"
        )
    }
    if name == "TSH" {
        return hormone(
            "Thyroid-stimulating hormone (TSH, thyrotropin)",
            "Anterior pituitary thyrotrophs",
            "Thyroid gland (follicular cells)",
            "Glycoprotein heterodimer: alpha subunit (common to TSH, LH, FSH, hCG) + beta subunit (specific). Binds TSH-R (GPCR, Gs-coupled, UniProt P16473). Activates adenylyl cyclase. Stimulates all steps of thyroid hormone synthesis: iodine uptake (NIS), thyroglobulin synthesis, TPO activity, T4/T3 release. Also stimulates thyroid growth.",
            "Primary hypothyroidism: TSH elevated (loss of T4 feedback). Graves disease: TSI (thyroid-stimulating immunoglobulin) mimics TSH, TSH suppressed by excess T4. TSH-secreting pituitary adenoma (rare): high TSH with high T4 (secondary hyperthyroidism). TSH is the single best screening test for thyroid function.",
            "Guyton 14th ed, Ch 77; Boron 3rd ed, Ch 49"
        )
    }
    if name == "FSH" {
        return hormone(
            "Follicle-stimulating hormone (FSH)",
            "Anterior pituitary gonadotrophs",
            "Ovary (granulosa cells); testis (Sertoli cells)",
            "Glycoprotein heterodimer (shared alpha + unique beta). Binds FSH-R (GPCR, Gs-coupled, UniProt P23945). In females: stimulates follicular growth, aromatase expression in granulosa cells (converts androgens to estrogens), inhibin B production. In males: stimulates Sertoli cells, supports spermatogenesis, stimulates ABP (androgen-binding protein) and inhibin B.",
            "Elevated FSH with low estradiol/testosterone = primary gonadal failure (menopause, Turner syndrome 45,X, Klinefelter 47,XXY). Low FSH = hypogonadotropic hypogonadism (Kallmann syndrome, pituitary failure). FSH used therapeutically for ovulation induction in IVF.",
            "Guyton 14th ed, Ch 81-82; Boron 3rd ed, Ch 55-56"
        )
    }
    if name == "LH" {
        return hormone(
            "Luteinizing hormone (LH)",
            "Anterior pituitary gonadotrophs",
            "Ovary (theca cells, corpus luteum); testis (Leydig cells)",
            "Glycoprotein heterodimer (shared alpha + unique beta). Binds LH/CG-R (GPCR, Gs-coupled, UniProt P22888). In females: LH surge triggers ovulation (follicle rupture), luteinization of granulosa cells, progesterone production by corpus luteum. In males: stimulates Leydig cells to produce testosterone.",
            "LH surge detection is the basis of ovulation predictor kits. Polycystic ovary syndrome (PCOS): elevated LH:FSH ratio (>2:1). LH-secreting pituitary adenomas rare. hCG (human chorionic gonadotropin) shares the same receptor -- basis of pregnancy tests.",
            "Guyton 14th ed, Ch 81-82; Boron 3rd ed, Ch 55-56"
        )
    }
    if name == "GH" {
        return hormone(
            "Growth hormone (GH, somatotropin)",
            "Anterior pituitary somatotrophs",
            "Liver (IGF-1 production), bone, muscle, adipose -- nearly all tissues",
            "191-amino-acid single-chain polypeptide. Binds GH-R (JAK-STAT type cytokine receptor, UniProt P10912). Receptor dimerization activates JAK2 tyrosine kinase, which phosphorylates STAT5b. Direct effects: lipolysis (adipose), insulin resistance, protein synthesis. Indirect effects via IGF-1 (liver): bone and cartilage growth at epiphyseal plates. Pulsatile secretion, highest during slow-wave sleep.",
            "Excess before epiphyseal closure: gigantism. Excess after closure: acromegaly (coarsened features, enlarged hands/feet/jaw, cardiomegaly, diabetes, colon polyps). Usually from pituitary adenoma. Diagnosed by failure to suppress GH on oral glucose tolerance test, elevated IGF-1. Treated by surgery, octreotide, pegvisomant (GH-R antagonist). Deficiency in children: short stature. Treated with recombinant GH.",
            "Guyton 14th ed, Ch 76; Boron 3rd ed, Ch 48"
        )
    }
    if name == "prolactin" {
        return hormone(
            "Prolactin (PRL)",
            "Anterior pituitary lactotrophs",
            "Mammary gland, reproductive organs, immune cells",
            "199-amino-acid single-chain polypeptide. Binds PRL-R (JAK-STAT type cytokine receptor, UniProt P16471). Activates JAK2-STAT5 pathway. Stimulates mammary gland development and milk production (lactogenesis). Inhibits GnRH pulsatility, causing suppression of FSH/LH (lactational amenorrhea). Under tonic dopaminergic INHIBITION -- unique among anterior pituitary hormones.",
            "Prolactinoma: most common pituitary adenoma. Causes galactorrhea, amenorrhea, infertility (women), erectile dysfunction and gynecomastia (men). Macroadenomas may cause bitemporal hemianopia (optic chiasm compression). Treated with cabergoline (D2 agonist), not surgery as first line. Drug-induced hyperprolactinemia from antipsychotics is common.",
            "Guyton 14th ed, Ch 76, 83; Boron 3rd ed, Ch 48"
        )
    }
    return hormone("", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION III: POSTERIOR PITUITARY HORMONES
// ═══════════════════════════════════════════════════════════════════
//
// The posterior pituitary (neurohypophysis) is NOT a gland -- it is neural
// tissue. Magnocellular neurons in the supraoptic and paraventricular nuclei
// of the hypothalamus synthesize ADH and oxytocin, package them with
// neurophysins into secretory granules, and transport them down axons to
// the posterior pituitary where they are released into systemic blood.
// This is neurosecretion: neurons acting as endocrine cells.

fn lookup_posterior_pituitary(name: String) -> Hormone {
    if name == "ADH" {
        return hormone(
            "Antidiuretic hormone (ADH, vasopressin, AVP)",
            "Hypothalamus (supraoptic nucleus primarily) -- stored/released from posterior pituitary",
            "Kidney collecting duct (V2 receptors), vascular smooth muscle (V1a receptors), anterior pituitary corticotrophs (V1b receptors)",
            "Nonapeptide (9 amino acids, Cys-Tyr-Phe-Gln-Asn-Cys-Pro-Arg-Gly-NH2). V2 receptor (GPCR, Gs, UniProt P30518): activates adenylyl cyclase, raises cAMP, triggers insertion of aquaporin-2 (AQP2) water channels into collecting duct apical membrane, allowing water reabsorption. V1a receptor (Gq): vasoconstriction at high concentrations. Released in response to increased plasma osmolality (detected by osmoreceptors) and decreased blood volume/pressure (detected by baroreceptors).",
            "Diabetes insipidus: Central DI (no ADH production, pituitary surgery, trauma, tumors) -- dilute urine, polydipsia, responds to desmopressin. Nephrogenic DI (kidneys resist ADH, lithium toxicity, hypercalcemia, genetic V2R/AQP2 mutations) -- does not respond to desmopressin. SIADH (syndrome of inappropriate ADH): excess ADH causes water retention, hyponatremia (small cell lung cancer, CNS disease, drugs). Treated with fluid restriction, demeclocycline, vaptans (tolvaptan, conivaptan).",
            "Guyton 14th ed, Ch 29, 76; Boron 3rd ed, Ch 38, 48"
        )
    }
    if name == "oxytocin" {
        return hormone(
            "Oxytocin",
            "Hypothalamus (paraventricular nucleus primarily) -- stored/released from posterior pituitary",
            "Uterine smooth muscle, mammary myoepithelial cells, brain (social behavior circuits)",
            "Nonapeptide (differs from ADH by 2 amino acids: Ile3 and Leu8 vs Phe3 and Arg8). Binds oxytocin receptor (GPCR, Gq-coupled, UniProt P30559). Activates PLC-IP3-Ca2+ cascade. Uterus: stimulates rhythmic contractions during labor (positive feedback -- Ferguson reflex: cervical stretch stimulates more oxytocin release). Breast: milk ejection (letdown reflex: suckling stimulates oxytocin, which contracts myoepithelial cells around alveoli).",
            "Pitocin (synthetic oxytocin) used for labor induction and augmentation, and to control postpartum hemorrhage. Oxytocin receptor antagonist (atosiban) used as tocolytic to delay preterm labor in some countries. Intranasal oxytocin studied for autism spectrum disorder and social anxiety (results mixed). Water intoxication risk with high-dose IV oxytocin (has weak V2R activity).",
            "Guyton 14th ed, Ch 76, 83; Boron 3rd ed, Ch 48, 56"
        )
    }
    return hormone("", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION IV: THYROID HORMONES
// ═══════════════════════════════════════════════════════════════════
//
// The thyroid gland synthesizes T4 (thyroxine) and T3 (triiodothyronine)
// from thyroglobulin iodination. The synthesis pathway:
//   (a) Iodide trapping: NIS (Na+/I- symporter, SLC5A5, UniProt Q92911)
//       concentrates I- 20-40x in follicular cells
//   (b) Oxidation: TPO (thyroid peroxidase, UniProt P07202) oxidizes I- to I0
//   (c) Organification: TPO iodinates tyrosine residues on thyroglobulin
//       to form MIT (monoiodotyrosine) and DIT (diiodotyrosine)
//   (d) Coupling: TPO couples DIT+DIT=T4, DIT+MIT=T3
//   (e) Secretion: thyroglobulin endocytosed, proteolyzed, T4/T3 released
//
// T4 is the major secretory product (~90%), but T3 is 3-5x more potent.
// Peripheral conversion of T4 to T3 by deiodinases (DIO1/DIO2) is the
// primary source of circulating T3.

fn lookup_thyroid_hormone(name: String) -> Hormone {
    if name == "T4" {
        return hormone(
            "Thyroxine (T4, levothyroxine, 3,5,3',5'-tetraiodothyronine)",
            "Thyroid gland (follicular cells)",
            "Nearly all cells (after conversion to T3). Binds thyroid hormone receptors (TR-alpha, TR-beta) in nucleus.",
            "Iodinated amino acid derivative (tyrosine-based, MW 776.87). ~90% of thyroid output. Circulates >99% protein-bound (TBG 70%, albumin 15%, transthyretin 10%). Only free T4 is biologically active. Half-life ~6-7 days (long due to protein binding). Converted to active T3 by type-1 deiodinase (DIO1, UniProt Q16762) in liver/kidney and type-2 deiodinase (DIO2, UniProt Q92813) in brain/pituitary/BAT. Can also be converted to inactive reverse T3 (rT3) by DIO3.",
            "Hypothyroidism: fatigue, weight gain, cold intolerance, constipation, bradycardia, myxedema, elevated TSH. Hashimoto thyroiditis (anti-TPO, anti-thyroglobulin antibodies) is most common cause. Treated with levothyroxine. Hyperthyroidism: weight loss, heat intolerance, tachycardia, tremor, suppressed TSH. Graves disease (TSI antibodies) most common cause -- also causes exophthalmos (retro-orbital inflammation, unique to Graves). Thyroid storm: life-threatening thyrotoxicosis with fever, tachycardia, delirium. Treated with PTU (blocks synthesis AND peripheral conversion), beta-blockers, iodine (Wolff-Chaikoff effect), glucocorticoids.",
            "Guyton 14th ed, Ch 77; Boron 3rd ed, Ch 49"
        )
    }
    if name == "T3" {
        return hormone(
            "Triiodothyronine (T3, liothyronine, 3,5,3'-triiodothyronine)",
            "Thyroid gland (~10% direct secretion); peripheral tissues (~90% from T4 deiodination)",
            "Nearly all nucleated cells via nuclear thyroid hormone receptors (TR-alpha1 UniProt P10827, TR-beta1 UniProt P10828)",
            "The active form of thyroid hormone. 3-5x more potent than T4. Enters cells via MCT8 transporter (UniProt P36021). Binds nuclear thyroid hormone receptors (TRs) which form heterodimers with RXR on thyroid response elements (TREs) in DNA. Unliganded TR recruits corepressors (transcriptional repression). T3 binding switches to coactivators (transcriptional activation). Effects: increases basal metabolic rate (upregulates Na+/K+ ATPase, mitochondrial uncoupling), increases cardiac contractility and heart rate (upregulates beta-1 adrenergic receptors and MHC-alpha), stimulates bone growth, essential for CNS development in fetus/neonate. Half-life ~1 day.",
            "Free T3 toxicosis: elevated T3 with normal T4, can occur early in Graves disease. Euthyroid sick syndrome (nonthyroidal illness): low T3 with normal TSH in critically ill patients (reduced DIO1 activity, increased DIO3). MCT8 mutations (Allan-Herndon-Dudley syndrome): X-linked, severe psychomotor retardation, high T3, low T4. Amiodarone: contains iodine, can cause both hypo- and hyperthyroidism (type 1: Jod-Basedow in predisposed glands; type 2: destructive thyroiditis).",
            "Guyton 14th ed, Ch 77; Boron 3rd ed, Ch 49"
        )
    }
    if name == "calcitonin" {
        return hormone(
            "Calcitonin",
            "Thyroid gland (parafollicular C cells, derived from neural crest)",
            "Bone (osteoclasts), kidney",
            "32-amino-acid peptide. Binds calcitonin receptor (GPCR, Gs-coupled, UniProt P30988). In bone: inhibits osteoclast activity (reduces bone resorption), lowers serum calcium. In kidney: inhibits Ca2+ and phosphate reabsorption (promotes excretion). Physiological role in adult humans is minimal -- thyroidectomized patients maintain normal calcium. More important in fish and rodents.",
            "Medullary thyroid carcinoma: C cell tumor, secretes calcitonin (tumor marker). Associated with MEN2A (RET proto-oncogene mutation, UniProt P07949) and MEN2B. Prophylactic thyroidectomy recommended for RET mutation carriers. Calcitonin (salmon calcitonin, more potent) used therapeutically for Paget disease of bone, osteoporosis (second-line), and hypercalcemia (short-term).",
            "Guyton 14th ed, Ch 80; Boron 3rd ed, Ch 52"
        )
    }
    return hormone("", "", "", "", "", "")
}

// Thyroid synthesis enzymes

fn lookup_thyroid_enzyme(name: String) -> Enzyme {
    if name == "NIS" {
        return enzyme(
            "Sodium-iodide symporter (NIS)",
            "SLC5A5",
            "Q92911",
            "Cotransports 2 Na+ with 1 I- across the basolateral membrane of thyroid follicular cells. Concentrates iodide 20-40x over plasma. Also expressed in salivary glands, gastric mucosa, lactating breast, and placenta.",
            "NIS is the basis of radioactive iodine (RAI) therapy for Graves disease and thyroid cancer (I-131 concentrates in thyroid via NIS). NIS mutations cause congenital hypothyroidism with iodide transport defect. Perchlorate and thiocyanate competitively inhibit NIS (environmental goitrogens).",
            "Boron 3rd ed, Ch 49; UniProt Q92911"
        )
    }
    if name == "TPO" {
        return enzyme(
            "Thyroid peroxidase (TPO)",
            "TPO",
            "P07202",
            "Heme-containing enzyme at the apical membrane of follicular cells. Catalyzes three reactions: (a) Oxidation of I- to reactive iodine species using H2O2, (b) Organification: iodinates tyrosine residues on thyroglobulin to form MIT and DIT, (c) Coupling: DIT+DIT=T4, DIT+MIT=T3. H2O2 generated by DUOX2 (dual oxidase 2, UniProt Q9NRD8).",
            "Anti-TPO antibodies are the hallmark of Hashimoto thyroiditis (present in >90% of cases). Propylthiouracil (PTU) and methimazole both inhibit TPO (thionamides), blocking hormone synthesis. PTU also inhibits peripheral DIO1 conversion of T4 to T3 (preferred in thyroid storm and first trimester pregnancy).",
            "Boron 3rd ed, Ch 49; UniProt P07202"
        )
    }
    if name == "thyroglobulin" {
        return enzyme(
            "Thyroglobulin (Tg)",
            "TG",
            "P01266",
            "660 kDa homodimeric glycoprotein synthesized by follicular cells and secreted into the colloid. Contains ~70 tyrosine residues, of which ~20 can be iodinated. Serves as the scaffold for T4/T3 synthesis. After TSH stimulation, colloid is endocytosed, Tg is proteolyzed in lysosomes, and T4/T3 are released. MIT and DIT are recycled by dehalogenase (DEHAL1).",
            "Serum thyroglobulin is the primary tumor marker for differentiated thyroid cancer (papillary, follicular) after thyroidectomy. Rising Tg indicates recurrence. Anti-thyroglobulin antibodies (present in Hashimoto and some cancers) interfere with Tg measurement. Congenital Tg mutations cause goitrous hypothyroidism.",
            "Boron 3rd ed, Ch 49; UniProt P01266"
        )
    }
    return enzyme("", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION V: PARATHYROID HORMONE AND CALCIUM HOMEOSTASIS
// ═══════════════════════════════════════════════════════════════════
//
// Four parathyroid glands sit on the posterior surface of the thyroid.
// PTH is the master regulator of calcium homeostasis, acting on bone
// and kidney to raise serum Ca2+. The calcium-sensing receptor (CaSR)
// on parathyroid chief cells directly senses ionized Ca2+ and adjusts
// PTH secretion inversely. Vitamin D (calcitriol) acts as a partner
// hormone: PTH stimulates its activation, and calcitriol raises calcium
// by increasing intestinal absorption.

fn lookup_parathyroid(name: String) -> Hormone {
    if name == "PTH" {
        return hormone(
            "Parathyroid hormone (PTH, parathormone)",
            "Parathyroid glands (chief cells)",
            "Bone (osteoblasts, which signal osteoclasts via RANKL), kidney (proximal tubule, distal tubule, thick ascending limb)",
            "84-amino-acid polypeptide. Binds PTH1R (GPCR, Gs/Gq-coupled, UniProt Q03431). Secretion inversely regulated by ionized Ca2+ via calcium-sensing receptor (CaSR, UniProt P41180). Actions: (a) Bone: stimulates osteoblasts to produce RANKL, which activates osteoclasts (bone resorption releases Ca2+ and PO4). Intermittent PTH is anabolic; continuous PTH is catabolic. (b) Kidney: stimulates Ca2+ reabsorption in DCT (TRPV5 channels), inhibits phosphate reabsorption in PCT (downregulates NaPi-IIa/c), stimulates 1-alpha-hydroxylase (CYP27B1) to convert 25-OH-D to active 1,25-(OH)2-D (calcitriol). Net effect: raises Ca2+, lowers PO4.",
            "Primary hyperparathyroidism: adenoma (85%), hyperplasia (15%), carcinoma (rare). Hypercalcemia with elevated PTH (inappropriately normal PTH also diagnostic). Stones, bones, groans, moans, psychiatric overtones. Treat: parathyroidectomy. Secondary hyperparathyroidism: CKD causes phosphate retention and low calcitriol, driving compensatory PTH elevation. Tertiary: autonomous PTH after prolonged secondary. Hypoparathyroidism: post-surgical (most common), autoimmune (DiGeorge syndrome -- 22q11.2 deletion), low Ca2+, high PO4, Chvostek sign, Trousseau sign. PTH(1-34) teriparatide used for osteoporosis (intermittent dosing is anabolic). CaSR-activating mutations cause autosomal dominant hypocalcemia.",
            "Guyton 14th ed, Ch 80; Boron 3rd ed, Ch 52"
        )
    }
    if name == "calcitriol" {
        return hormone(
            "Calcitriol (1,25-dihydroxyvitamin D3, active vitamin D)",
            "Kidney proximal tubule (final hydroxylation step); precursors from skin (UV-B) and diet",
            "Small intestine (duodenum), bone, kidney, parathyroid glands, immune cells",
            "Secosteroid hormone. Synthesis: (a) Skin: UV-B converts 7-dehydrocholesterol to previtamin D3, then thermal isomerization to vitamin D3 (cholecalciferol). (b) Liver: CYP2R1 (25-hydroxylase, UniProt Q6VVX0) converts D3 to 25-OH-D3 (calcidiol, main circulating form, half-life 2-3 weeks). (c) Kidney: CYP27B1 (1-alpha-hydroxylase, UniProt O15528) converts 25-OH-D3 to 1,25-(OH)2-D3 (calcitriol, active form, half-life 4-6 hours). PTH stimulates CYP27B1; FGF23 and calcitriol itself inhibit it. Calcitriol binds VDR (vitamin D receptor, nuclear receptor, UniProt P11473), heterodimerizes with RXR, regulates gene transcription. Intestine: upregulates calbindin-D, TRPV6 calcium channels, increasing Ca2+ and PO4 absorption. Bone: permissive for mineralization. Parathyroid: suppresses PTH gene transcription.",
            "Vitamin D deficiency: rickets (children, bowed legs, rachitic rosary), osteomalacia (adults, bone pain, proximal myopathy). Risk factors: dark skin, limited sun exposure, malabsorption, CKD. 25-OH-D <20 ng/mL = deficiency. CKD patients cannot make calcitriol (lost renal mass) -- treated with calcitriol or paricalcitol. Granulomatous diseases (sarcoidosis, TB): macrophages express CYP27B1, causing hypercalcemia. Vitamin D toxicity (excessive supplementation): hypercalcemia, nephrocalcinosis.",
            "Guyton 14th ed, Ch 80; Boron 3rd ed, Ch 52"
        )
    }
    return hormone("", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION VI: ADRENAL CORTEX
// ═══════════════════════════════════════════════════════════════════
//
// The adrenal cortex has three zones, remembered as GFR (from outside in):
//   Glomerulosa -- mineralocorticoids (aldosterone)
//   Fasciculata -- glucocorticoids (cortisol)
//   Reticularis  -- androgens (DHEA, DHEA-S)
//
// All adrenocortical hormones are synthesized from cholesterol. The rate-
// limiting step is cholesterol transport from outer to inner mitochondrial
// membrane by StAR protein (steroidogenic acute regulatory protein,
// UniProt P49675), stimulated by ACTH.

fn lookup_adrenal_zone(name: String) -> AdrenalZone {
    if name == "glomerulosa" {
        return adrenal_zone(
            "Zona glomerulosa",
            "Outermost layer of adrenal cortex",
            "Aldosterone (mineralocorticoid)",
            "Angiotensin II (primary), hyperkalemia, ACTH (permissive)",
            "Aldosterone synthase (CYP11B2)",
            "P19099",
            "Conn syndrome (primary hyperaldosteronism): aldosterone-producing adenoma. Hypertension, hypokalemia, metabolic alkalosis, low renin. Most common cause of secondary hypertension. Diagnosed by elevated aldosterone:renin ratio (>30). Treated with spironolactone (MR antagonist) or adrenalectomy.",
            "Guyton 14th ed, Ch 78; Boron 3rd ed, Ch 50"
        )
    }
    if name == "fasciculata" {
        return adrenal_zone(
            "Zona fasciculata",
            "Middle (widest) layer of adrenal cortex",
            "Cortisol (glucocorticoid)",
            "ACTH (primary), CRH (indirect via ACTH)",
            "11-beta-hydroxylase (CYP11B1)",
            "P15538",
            "Cushing syndrome (cortisol excess): central obesity, moon facies, buffalo hump, striae, hyperglycemia, osteoporosis, immunosuppression, proximal myopathy. Causes: exogenous steroids (most common), pituitary adenoma (Cushing disease), ectopic ACTH, adrenal adenoma/carcinoma. Diagnosed by 24h urine free cortisol, late-night salivary cortisol, overnight dexamethasone suppression test. Addison disease (primary adrenal insufficiency): fatigue, hypotension, hyperpigmentation (elevated ACTH), hyperkalemia, hyponatremia. Adrenal crisis is life-threatening (IV hydrocortisone).",
            "Guyton 14th ed, Ch 78; Boron 3rd ed, Ch 50"
        )
    }
    if name == "reticularis" {
        return adrenal_zone(
            "Zona reticularis",
            "Innermost layer of adrenal cortex",
            "DHEA and DHEA-S (adrenal androgens)",
            "ACTH",
            "17,20-lyase activity of CYP17A1 (17-alpha-hydroxylase/17,20-lyase)",
            "P05093",
            "Congenital adrenal hyperplasia (CAH): most commonly 21-hydroxylase (CYP21A2, UniProt P08686) deficiency. Cannot make cortisol or aldosterone. ACTH rises (no cortisol feedback), driving adrenal hyperplasia and shunting precursors to androgen pathway. Classic form: ambiguous genitalia in 46,XX females, salt-wasting crisis in neonates. Nonclassic (late-onset): hirsutism, acne, oligomenorrhea in women. Diagnosed by elevated 17-hydroxyprogesterone. Treated with glucocorticoid replacement (suppresses ACTH, reduces androgen excess).",
            "Guyton 14th ed, Ch 78; Boron 3rd ed, Ch 50"
        )
    }
    return adrenal_zone("", "", "", "", "", "", "", "")
}

// Adrenocortical hormones

fn lookup_adrenal_cortex_hormone(name: String) -> Hormone {
    if name == "cortisol" {
        return hormone(
            "Cortisol (hydrocortisone)",
            "Adrenal cortex (zona fasciculata)",
            "Nearly all cells (ubiquitous glucocorticoid receptor expression)",
            "Steroid hormone derived from cholesterol. Circulates ~90% bound to CBG (cortisol-binding globulin, transcortin) and ~7% to albumin. Only free cortisol is active. Binds glucocorticoid receptor (GR, NR3C1, nuclear receptor, UniProt P04150). GR-cortisol complex translocates to nucleus, binds glucocorticoid response elements (GREs). Effects: (a) Metabolism: gluconeogenesis, glycogenolysis, protein catabolism, lipolysis (permissive for catecholamines), insulin resistance. (b) Immune: anti-inflammatory (inhibits NF-kB, phospholipase A2, COX-2; reduces IL-1, IL-6, TNF-alpha; causes lymphocyte apoptosis and neutrophil demargination). (c) Cardiovascular: permissive for catecholamine vasoconstriction, maintains vascular tone. (d) CNS: mood, cognition, hippocampal memory. Diurnal rhythm: peaks at 6-8 AM (ACTH-driven), nadir at midnight.",
            "See zona fasciculata clinical notes (Cushing syndrome, Addison disease). Additional: chronic stress elevates cortisol -- hippocampal atrophy, depression, metabolic syndrome. Exogenous glucocorticoids (prednisone, dexamethasone) suppress HPA axis -- must taper to avoid adrenal crisis. Cortisol is inactivated by 11-beta-HSD2 (UniProt P80365) in kidney to prevent MR activation (cortisone). Licorice inhibits 11-beta-HSD2, causing apparent mineralocorticoid excess (hypertension, hypokalemia).",
            "Guyton 14th ed, Ch 78; Boron 3rd ed, Ch 50"
        )
    }
    if name == "aldosterone" {
        return hormone(
            "Aldosterone",
            "Adrenal cortex (zona glomerulosa)",
            "Kidney (distal convoluted tubule, collecting duct principal cells)",
            "Mineralocorticoid steroid. Binds mineralocorticoid receptor (MR, NR3C2, nuclear receptor, UniProt P08235). MR-aldosterone complex enters nucleus, upregulates ENaC (epithelial sodium channel, alpha: UniProt P37088), Na+/K+ ATPase, and ROMK (renal outer medullary K+ channel). Net effect: Na+ reabsorption (water follows), K+ and H+ secretion. Regulated by RAAS: renin (from JGA cells in response to low renal perfusion, low NaCl at macula densa, sympathetic stimulation) cleaves angiotensinogen to angiotensin I, ACE converts to angiotensin II, which stimulates aldosterone release. Also stimulated directly by hyperkalemia (K+ depolarizes glomerulosa cells). ACTH has permissive role.",
            "See zona glomerulosa clinical notes (Conn syndrome). Additional: secondary hyperaldosteronism (high renin): renal artery stenosis, heart failure, cirrhosis (low effective circulating volume). Hypoaldosteronism: type IV RTA, hyperkalemia, mild metabolic acidosis (hyporeninemic hypoaldosteronism in diabetic nephropathy). Spironolactone/eplerenone (MR antagonists) used in heart failure, resistant hypertension, ascites. Fludrocortisone (synthetic mineralocorticoid) used in Addison disease replacement and orthostatic hypotension.",
            "Guyton 14th ed, Ch 28, 78; Boron 3rd ed, Ch 35, 50"
        )
    }
    if name == "DHEA" {
        return hormone(
            "Dehydroepiandrosterone (DHEA) and DHEA-sulfate (DHEA-S)",
            "Adrenal cortex (zona reticularis)",
            "Peripheral tissues (converted to testosterone and estrogens)",
            "Weak androgen, serves as precursor. DHEA-S is the sulfated storage form (longest half-life of any steroid, ~7-10 hours). Both are converted peripherally to androstenedione, then to testosterone (by 17-beta-HSD) and estrogens (by aromatase). In women, adrenal androgens are the major source of androgens. In men, testicular testosterone dominates. DHEA-S levels peak in the 20s and decline ~2% per year (adrenopause).",
            "See zona reticularis clinical notes (CAH). Elevated DHEA-S suggests adrenal source of androgen excess (vs ovarian). Adrenal carcinoma often produces very high DHEA-S levels. DHEA supplementation marketed as anti-aging -- evidence weak, not FDA-regulated as a drug. In CAH, DHEA-S suppression by glucocorticoids confirms adrenal source.",
            "Guyton 14th ed, Ch 78, 82; Boron 3rd ed, Ch 50, 55"
        )
    }
    return hormone("", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION VII: ADRENAL MEDULLA -- CATECHOLAMINE SYNTHESIS
// ═══════════════════════════════════════════════════════════════════
//
// The adrenal medulla is a modified sympathetic ganglion. Chromaffin cells
// are postganglionic sympathetic neurons that lost their axons and became
// endocrine cells. They synthesize catecholamines from tyrosine in a
// four-step enzymatic pathway. The critical final step (NE to epinephrine)
// requires PNMT, which is induced by cortisol flowing from the cortex
// through the adrenal portal system -- this is why the medulla is INSIDE
// the cortex anatomically.

fn lookup_catecholamine_step(step: Int) -> CatecholamineSynthStep {
    if step == 1 {
        return cat_step(
            1,
            "L-Tyrosine",
            "L-DOPA (3,4-dihydroxyphenylalanine)",
            "Tyrosine hydroxylase (TH)",
            "TH",
            "P07101",
            "Tetrahydrobiopterin (BH4), O2, Fe2+",
            "Cytoplasm of chromaffin cells and sympathetic neurons",
            "Guyton 14th ed, Ch 61; Boron 3rd ed, Ch 13"
        )
    }
    if step == 2 {
        return cat_step(
            2,
            "L-DOPA",
            "Dopamine",
            "DOPA decarboxylase (aromatic L-amino acid decarboxylase, AADC)",
            "DDC",
            "P20711",
            "Pyridoxal phosphate (vitamin B6, PLP)",
            "Cytoplasm",
            "Guyton 14th ed, Ch 61; Boron 3rd ed, Ch 13"
        )
    }
    if step == 3 {
        return cat_step(
            3,
            "Dopamine",
            "Norepinephrine (noradrenaline)",
            "Dopamine beta-hydroxylase (DBH)",
            "DBH",
            "P09172",
            "Ascorbic acid (vitamin C), O2, Cu2+",
            "Inside secretory vesicles (dopamine transported into vesicles by VMAT2 before this step)",
            "Guyton 14th ed, Ch 61; Boron 3rd ed, Ch 13"
        )
    }
    if step == 4 {
        return cat_step(
            4,
            "Norepinephrine",
            "Epinephrine (adrenaline)",
            "Phenylethanolamine N-methyltransferase (PNMT)",
            "PNMT",
            "P11086",
            "S-adenosylmethionine (SAM) as methyl donor",
            "Cytoplasm of adrenal chromaffin cells ONLY (NE must exit vesicle, be methylated, then re-enter). PNMT expression requires cortisol from zona fasciculata (portal blood flow). This is why the medulla is anatomically surrounded by cortex.",
            "Guyton 14th ed, Ch 61; Boron 3rd ed, Ch 13"
        )
    }
    return cat_step(0, "", "", "", "", "", "", "", "")
}

// Adrenal medulla hormones

fn lookup_adrenal_medulla_hormone(name: String) -> Hormone {
    if name == "epinephrine" {
        return hormone(
            "Epinephrine (adrenaline)",
            "Adrenal medulla (chromaffin cells, ~80% of medullary output)",
            "Heart (beta-1), bronchioles (beta-2), liver (beta-2, alpha-1), skeletal muscle vasculature (beta-2), skin/splanchnic vasculature (alpha-1), adipose (beta-3)",
            "Catecholamine. Acts on adrenergic receptors (GPCRs): alpha-1 (Gq, vasoconstriction, UniProt P35348), alpha-2 (Gi, presynaptic inhibition, UniProt P08913), beta-1 (Gs, increases heart rate and contractility, UniProt P08588), beta-2 (Gs, bronchodilation, vasodilation in skeletal muscle, glycogenolysis, UniProt P07550), beta-3 (Gs, lipolysis, UniProt P13945). Released during fight-or-flight response via sympathetic preganglionic cholinergic stimulation of chromaffin cells. Metabolized by COMT and MAO. Half-life ~2 minutes.",
            "Pheochromocytoma: catecholamine-secreting tumor of chromaffin cells. Episodic hypertension, headache, sweating, palpitations (paroxysmal). Rule of 10s: 10% bilateral, 10% malignant, 10% extra-adrenal (paraganglioma), 10% familial (MEN2A/2B, VHL, NF1, SDH mutations). Diagnosed by 24h urine catecholamines/metanephrines or plasma free metanephrines. Treat: alpha-blockade FIRST (phenoxybenzamine), then beta-blockade, then surgery. Never beta-block first (unopposed alpha causes hypertensive crisis). Anaphylaxis: IM epinephrine is first-line treatment.",
            "Guyton 14th ed, Ch 61, 79; Boron 3rd ed, Ch 13, 50"
        )
    }
    if name == "norepinephrine" {
        return hormone(
            "Norepinephrine (noradrenaline)",
            "Adrenal medulla (~20% of medullary output); sympathetic postganglionic nerve terminals (primary source systemically)",
            "Heart (beta-1), vascular smooth muscle (alpha-1), presynaptic terminals (alpha-2 autoreceptors)",
            "Catecholamine. Primarily an alpha-1 and beta-1 agonist. Minimal beta-2 activity (unlike epinephrine). As a neurotransmitter: released from sympathetic nerve varicosities, acts locally, reuptaken by NET (norepinephrine transporter, SLC6A2, UniProt P23975). As a hormone from adrenal medulla: enters systemic circulation. Effects: vasoconstriction (alpha-1), increased heart rate and contractility (beta-1), but reflex bradycardia may occur due to strong vasoconstriction raising blood pressure.",
            "Pheochromocytoma may secrete predominantly NE (especially extra-adrenal paragangliomas). Neuroblastoma: childhood tumor of sympathetic nervous system precursor cells (neural crest), secretes catecholamine metabolites (VMA, HVA in urine). Norepinephrine reuptake inhibitors (SNRIs, TCAs) used in depression. Norepinephrine IV infusion (Levophed) used as vasopressor in septic shock.",
            "Guyton 14th ed, Ch 61, 79; Boron 3rd ed, Ch 13, 50"
        )
    }
    return hormone("", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION VIII: PANCREATIC ISLET HORMONES
// ═══════════════════════════════════════════════════════════════════
//
// Islets of Langerhans comprise ~1-2% of pancreatic mass but receive
// ~10% of pancreatic blood flow. Three main cell types:
//   Alpha cells (~20%): glucagon
//   Beta cells  (~70%): insulin
//   Delta cells (~5-10%): somatostatin
//
// Beta cell insulin secretion mechanism:
//   Glucose enters via GLUT2 -> glucokinase phosphorylates glucose ->
//   glycolysis + oxidative phosphorylation -> ATP rises ->
//   ATP-sensitive K+ channels close (Kir6.2/SUR1 complex) ->
//   membrane depolarizes -> voltage-gated Ca2+ channels open ->
//   Ca2+ influx triggers insulin exocytosis

fn lookup_islet_cell(name: String) -> IsletCell {
    if name == "beta" {
        return islet_cell(
            "Beta cell",
            70.0,
            "Insulin (and C-peptide, and amylin/IAPP)",
            "Elevated blood glucose (primary). Also amino acids (leucine, arginine), fatty acids, GLP-1 and GIP (incretins), vagal (parasympathetic) stimulation, sulfonylureas (close KATP channels directly).",
            "Anabolic hormone. Binds insulin receptor (receptor tyrosine kinase, UniProt P06213). Autophosphorylation activates IRS proteins -> PI3K -> Akt/PKB pathway. Effects: (a) Liver: glycogen synthesis, lipogenesis, inhibits gluconeogenesis. (b) Muscle: GLUT4 translocation (glucose uptake), glycogen synthesis, protein synthesis. (c) Adipose: GLUT4 translocation, lipogenesis, inhibits lipolysis (inhibits hormone-sensitive lipase). (d) Also stimulates K+ uptake into cells (used therapeutically in hyperkalemia: insulin + glucose).",
            "Type 1 DM: autoimmune destruction of beta cells (anti-GAD65, anti-IA-2, anti-insulin, anti-ZnT8 antibodies). No insulin production. Requires exogenous insulin. Prone to DKA (no insulin -> unopposed glucagon -> ketogenesis). C-peptide low/absent. Type 2 DM: insulin resistance + progressive beta cell failure. Initially hyperinsulinemic, then insulin-deficient. Associated with obesity, metabolic syndrome. Prone to hyperosmolar hyperglycemic state (HHS). Insulinoma: beta cell tumor, causes fasting hypoglycemia (Whipple triad). Diagnosed by high insulin and C-peptide during hypoglycemia.",
            "Guyton 14th ed, Ch 79; Boron 3rd ed, Ch 51"
        )
    }
    if name == "alpha" {
        return islet_cell(
            "Alpha cell",
            20.0,
            "Glucagon",
            "Low blood glucose (primary). Also amino acids (especially arginine and alanine), sympathetic stimulation (epinephrine via beta-2 receptors), cortisol, exercise. Inhibited by insulin, somatostatin, GLP-1, and hyperglycemia.",
            "Catabolic hormone. Binds glucagon receptor (GPCR, Gs-coupled, UniProt P47871). Activates adenylyl cyclase, raises cAMP, activates PKA. Acts primarily on liver: (a) Glycogenolysis (glycogen phosphorylase activation via phosphorylase kinase cascade). (b) Gluconeogenesis (upregulates PEPCK and G6Pase). (c) Ketogenesis (from fatty acid beta-oxidation when insulin is absent). (d) Inhibits glycolysis and glycogen synthesis. Net effect: raises blood glucose. Does NOT act on muscle (muscle lacks glucagon receptors).",
            "Glucagonoma: alpha cell tumor (rare), part of glucagonoma syndrome -- necrolytic migratory erythema (distinctive rash), diabetes, weight loss, DVT, depression. Diagnosed by glucagon >500 pg/mL. In DKA: glucagon excess (unrestrained by insulin) drives hepatic glucose and ketone production -- the glucagon:insulin ratio is the key determinant. Exogenous glucagon used as rescue for severe hypoglycemia (IM or nasal).",
            "Guyton 14th ed, Ch 79; Boron 3rd ed, Ch 51"
        )
    }
    if name == "delta" {
        return islet_cell(
            "Delta cell",
            8.0,
            "Somatostatin (SST-14 predominant form in islets)",
            "Elevated blood glucose, elevated amino acids, GLP-1. Paracrine signaling -- delta cells extend cytoplasmic processes to contact alpha and beta cells.",
            "Paracrine inhibitor within the islet. Inhibits both insulin (from beta cells) and glucagon (from alpha cells) via SSTR2 and SSTR5 (Gi-coupled GPCRs). Also inhibits exocrine pancreatic secretion, GI motility, and splanchnic blood flow. Acts as a local brake preventing excessive hormone secretion in either direction. Somatostatin from islets acts paracrine; somatostatin from hypothalamus acts endocrine on anterior pituitary.",
            "Somatostatinoma: rare, usually in pancreas or duodenum. Triad of diabetes (inhibits insulin), cholelithiasis (inhibits CCK/gallbladder contraction), steatorrhea (inhibits pancreatic enzymes). May be part of MEN1 (pituitary, parathyroid, pancreas). Octreotide (SST analogue) can unmask diabetes by inhibiting insulin secretion.",
            "Guyton 14th ed, Ch 79; Boron 3rd ed, Ch 51"
        )
    }
    return islet_cell("", 0.0, "", "", "", "", "")
}

// Pancreatic hormones as Hormone struct

fn lookup_pancreatic_hormone(name: String) -> Hormone {
    if name == "insulin" {
        return hormone(
            "Insulin",
            "Pancreas (beta cells of islets of Langerhans)",
            "Liver, skeletal muscle, adipose tissue (primary); nearly all cells",
            "51-amino-acid peptide (A chain 21 aa + B chain 30 aa, linked by 2 disulfide bonds). Synthesized as preproinsulin -> proinsulin (C-peptide connecting A and B) -> insulin + C-peptide (equimolar secretion, C-peptide used clinically to assess endogenous insulin production). Binds insulin receptor (RTK, UniProt P06213). Receptor autophosphorylation -> IRS-1/2 -> PI3K -> PIP3 -> Akt/PKB. GLUT4 translocation in muscle/adipose. Half-life ~5 min (hepatic clearance).",
            "See beta cell clinical notes (DM1, DM2, DKA, HHS, insulinoma). Additional: insulin preparations classified by onset/duration: rapid (lispro, aspart, glulisine), short (regular), intermediate (NPH), long (glargine, detemir, degludec). Insulin pump therapy and continuous glucose monitoring for tight glycemic control. Factitious hypoglycemia: exogenous insulin causes low glucose with high insulin but LOW C-peptide (vs insulinoma where C-peptide is HIGH).",
            "Guyton 14th ed, Ch 79; Boron 3rd ed, Ch 51"
        )
    }
    if name == "glucagon" {
        return hormone(
            "Glucagon",
            "Pancreas (alpha cells of islets of Langerhans)",
            "Liver (primary); adipose tissue",
            "29-amino-acid peptide. Derived from preproglucagon (same gene as GLP-1 and GLP-2 -- tissue-specific processing by PC2 in alpha cells yields glucagon, while PC1/3 in L cells yields GLP-1/2). Binds glucagon receptor (GPCR, Gs, UniProt P47871). cAMP-PKA cascade. Hepatic actions: glycogenolysis (via phosphorylase kinase), gluconeogenesis (PEPCK, G6Pase), ketogenesis, inhibition of glycolysis. Does not affect skeletal muscle.",
            "See alpha cell clinical notes. Additional: glucagon used as cardiac stimulant in beta-blocker overdose (bypasses blocked beta receptors, directly activates Gs in cardiomyocytes). Glucagon stress test for pheochromocytoma (can provoke catecholamine release -- use with caution). GLP-1 receptor agonists (semaglutide, liraglutide) are incretin mimetics that enhance glucose-dependent insulin secretion, suppress glucagon, slow gastric emptying, and promote weight loss.",
            "Guyton 14th ed, Ch 79; Boron 3rd ed, Ch 51"
        )
    }
    return hormone("", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION IX: GONADAL HORMONES
// ═══════════════════════════════════════════════════════════════════
//
// Gonadal steroidogenesis follows the same cholesterol -> pregnenolone
// -> progesterone/androgens/estrogens pathway as adrenal steroidogenesis,
// using many of the same enzymes. The key sex-specific difference:
//   - Ovarian granulosa cells express aromatase (CYP19A1) to convert
//     androgens to estrogens
//   - Testicular Leydig cells produce testosterone but lack significant
//     aromatase activity (peripheral aromatization occurs in adipose)
//
// Two-cell model of ovarian steroidogenesis:
//   Theca cells (LH-stimulated): cholesterol -> androstenedione
//   Granulosa cells (FSH-stimulated): androstenedione -> estradiol
//   (aromatase, CYP19A1, UniProt P11511)

fn lookup_gonadal_hormone(name: String) -> Hormone {
    if name == "testosterone" {
        return hormone(
            "Testosterone",
            "Testis (Leydig cells, ~95%); adrenal cortex (~5%); ovary (theca cells, small amounts)",
            "Skeletal muscle, bone, skin, prostate, seminal vesicles, brain, bone marrow, liver",
            "C19 steroid (MW 288.42). Synthesized from cholesterol via pregnenolone -> 17-OH-pregnenolone -> DHEA -> androstenedione -> testosterone (or via delta-4 pathway: pregnenolone -> progesterone -> 17-OH-progesterone -> androstenedione -> testosterone). Circulates ~60% bound to SHBG (sex hormone-binding globulin), ~38% to albumin, ~2% free. Binds androgen receptor (AR, nuclear receptor, UniProt P10275). Converted to DHT (5-alpha-dihydrotestosterone) by 5-alpha-reductase (SRD5A2, UniProt P31213) in prostate, skin, hair follicles -- DHT is 2-3x more potent at AR. Converted to estradiol by aromatase in adipose tissue.",
            "Male hypogonadism: primary (Klinefelter 47,XXY, testicular failure -- high LH/FSH) or secondary (Kallmann syndrome, pituitary failure -- low LH/FSH). Low testosterone causes: decreased libido, erectile dysfunction, reduced muscle mass, osteoporosis, infertility. Testosterone replacement: gels, patches, IM injections. Anabolic steroid abuse: exogenous testosterone suppresses LH/FSH, causing testicular atrophy, infertility, gynecomastia (peripheral aromatization to estrogen). Prostate cancer: androgen-dependent, treated with GnRH agonists (chemical castration), antiandrogens (enzalutamide), or abiraterone (CYP17A1 inhibitor). BPH: DHT-driven, treated with finasteride/dutasteride (5-alpha-reductase inhibitors).",
            "Guyton 14th ed, Ch 81; Boron 3rd ed, Ch 55"
        )
    }
    if name == "estrogen" {
        return hormone(
            "Estradiol (E2, 17-beta-estradiol) -- primary estrogen",
            "Ovary (granulosa cells, corpus luteum); placenta (pregnancy); peripheral aromatization (adipose tissue, male and postmenopausal)",
            "Uterus, breast, bone, liver, brain, cardiovascular system, skin",
            "C18 steroid (MW 272.38). Most potent natural estrogen. Synthesis requires aromatase (CYP19A1, UniProt P11511) which converts androstenedione to estrone (E1) and testosterone to estradiol (E2). Binds estrogen receptors: ER-alpha (ESR1, UniProt P03372, predominant in uterus, breast, hypothalamus) and ER-beta (ESR2, UniProt Q92731, predominant in ovary, prostate, lung, CNS). Nuclear receptors that dimerize and bind estrogen response elements (EREs). Also rapid non-genomic effects via membrane-associated ER (activates MAPK, PI3K). Circulates bound to SHBG and albumin. Metabolized in liver (CYP1A2, CYP3A4). Other estrogens: estrone (E1, postmenopausal, weaker), estriol (E3, pregnancy, from placental metabolism of fetal DHEA-S).",
            "Estrogen deficiency (menopause): vasomotor symptoms (hot flashes), vaginal atrophy, osteoporosis (bone resorption > formation without estrogen). Hormone replacement therapy (HRT) with estrogen +/- progesterone -- risk/benefit depends on age and time since menopause (timing hypothesis). Breast cancer: ER-positive (~70%) treated with tamoxifen (SERM, partial antagonist at breast) or aromatase inhibitors (letrozole, anastrozole). Endometrial cancer risk: unopposed estrogen (without progesterone) causes endometrial hyperplasia. Estrogen in males: aromatase excess causes gynecomastia; aromatase deficiency causes tall stature (no epiphyseal closure), osteoporosis, and insulin resistance.",
            "Guyton 14th ed, Ch 82; Boron 3rd ed, Ch 56"
        )
    }
    if name == "progesterone" {
        return hormone(
            "Progesterone",
            "Corpus luteum (luteal phase); placenta (after week 8-12 of pregnancy); adrenal cortex (small amounts)",
            "Uterus (endometrium, myometrium), breast, brain, bone",
            "C21 steroid (MW 314.46). The progestational hormone -- prepares endometrium for implantation. Binds progesterone receptor (PR, nuclear receptor, UniProt P06401, two isoforms PR-A and PR-B from same gene). PR-B is the activator; PR-A can repress PR-B. Effects: (a) Uterus: converts proliferative endometrium (estrogen-driven) to secretory endometrium (glycogen-rich glands, spiral arteries), maintains pregnancy (relaxes myometrium via reduced gap junctions and prostaglandins, maintains thick cervical mucus). (b) Breast: alveolar development (lobules). (c) Thermogenic: raises basal body temperature ~0.5C in luteal phase (basis of BBT charting for ovulation). (d) CNS: anxiolytic effect (metabolite allopregnanolone acts on GABA-A receptors).",
            "Progesterone withdrawal causes menstruation (corpus luteum regression if no hCG from embryo). Luteal phase deficiency: inadequate progesterone, recurrent early miscarriage. Progesterone supplementation in IVF and threatened miscarriage. Progestin-only contraceptives: thicken cervical mucus, thin endometrium, inhibit ovulation (not consistently). Combined oral contraceptives: estrogen + progestin suppress LH surge (prevent ovulation). Mifepristone (RU-486): progesterone receptor antagonist, used for medical abortion (with misoprostol). Medroxyprogesterone (Depo-Provera): long-acting injectable contraceptive.",
            "Guyton 14th ed, Ch 82; Boron 3rd ed, Ch 56"
        )
    }
    return hormone("", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION X: OTHER HORMONES
// ═══════════════════════════════════════════════════════════════════
//
// Hormones from organs not primarily classified as endocrine glands.
// The endocrine system extends far beyond the classic glands -- adipose
// tissue, gut, heart, kidney, and pineal gland all produce hormones
// that regulate critical physiological functions.

fn lookup_other_hormone(name: String) -> Hormone {
    if name == "leptin" {
        return hormone(
            "Leptin",
            "Adipose tissue (white fat, proportional to fat mass)",
            "Hypothalamus (arcuate nucleus: POMC/CART neurons stimulated, NPY/AgRP neurons inhibited)",
            "167-amino-acid peptide (16 kDa, product of the ob gene). Binds leptin receptor (Ob-Rb, JAK-STAT type, UniProt P48357). Activates JAK2-STAT3 pathway in hypothalamus. Signals satiety: 'I have enough energy stores.' Suppresses appetite (inhibits NPY/AgRP orexigenic neurons, activates POMC/CART anorexigenic neurons), increases energy expenditure (sympathetic activation, thermogenesis), permits reproductive function (low leptin suppresses GnRH). Circulating levels proportional to adiposity. Crosses blood-brain barrier via saturable transport.",
            "ob/ob mouse: leptin-deficient, massively obese, infertile -- completely rescued by exogenous leptin. db/db mouse: leptin receptor-deficient, obese, does not respond to leptin. Human congenital leptin deficiency: extremely rare, severe obesity from infancy, responds dramatically to recombinant leptin (metreleptin). Common obesity: HIGH leptin (proportional to fat mass) but LEPTIN RESISTANCE (impaired receptor signaling, reduced BBB transport). Leptin administration does not help common obesity. Lipodystrophy: low fat = low leptin -- metreleptin approved for generalized lipodystrophy.",
            "Guyton 14th ed, Ch 72; Boron 3rd ed, Ch 48"
        )
    }
    if name == "ghrelin" {
        return hormone(
            "Ghrelin",
            "Stomach (oxyntic/fundic glands, P/D1 cells)",
            "Hypothalamus (arcuate nucleus NPY/AgRP neurons), anterior pituitary (GH secretagogue receptor)",
            "28-amino-acid peptide with unique octanoyl modification on Ser3 (essential for receptor binding). Binds GHS-R1a (growth hormone secretagogue receptor, GPCR, Gq-coupled, UniProt Q92847). The only known circulating orexigenic (appetite-stimulating) hormone. Rises before meals, falls after eating. Actions: stimulates appetite (activates NPY/AgRP neurons), stimulates GH release (synergizes with GHRH), increases gastric motility, promotes adipogenesis. Counter-regulatory to leptin.",
            "Prader-Willi syndrome: elevated ghrelin contributes to hyperphagia and obesity. Post-bariatric surgery (Roux-en-Y gastric bypass): ghrelin levels decrease (fundus removed/bypassed), contributing to appetite suppression. Ghrelin agonists studied for cachexia and anorexia. Ghrelin receptor antagonists studied for obesity (limited success). Ghrelin is suppressed by somatostatin.",
            "Boron 3rd ed, Ch 43, 48; Guyton 14th ed, Ch 72"
        )
    }
    if name == "ANP" {
        return hormone(
            "Atrial natriuretic peptide (ANP)",
            "Heart (atrial cardiomyocytes, released from storage granules)",
            "Kidney (glomeruli, collecting duct), adrenal cortex, vascular smooth muscle",
            "28-amino-acid peptide released in response to atrial stretch (volume overload). Binds NPR-A (natriuretic peptide receptor A, guanylyl cyclase receptor, UniProt P16066). Generates cGMP. Actions: (a) Kidney: increases GFR (afferent arteriole dilation + efferent constriction), inhibits Na+ reabsorption in collecting duct, inhibits renin secretion. (b) Adrenal: inhibits aldosterone secretion. (c) Vasculature: vasodilation. Net effect: reduce blood volume and blood pressure. Opposes RAAS.",
            "Heart failure: ANP and BNP elevated due to volume overload and ventricular wall stress. BNP/NT-proBNP used as biomarkers for heart failure diagnosis and monitoring. Sacubitril (neprilysin inhibitor) prevents ANP/BNP degradation, enhancing their effects -- combined with valsartan (ARB) as sacubitril/valsartan (Entresto) for heart failure with reduced ejection fraction.",
            "Guyton 14th ed, Ch 28; Boron 3rd ed, Ch 35"
        )
    }
    if name == "BNP" {
        return hormone(
            "B-type natriuretic peptide (BNP, brain natriuretic peptide)",
            "Heart (ventricular cardiomyocytes, in response to wall stress)",
            "Kidney, adrenal cortex, vasculature (same targets as ANP)",
            "32-amino-acid peptide. Synthesized as proBNP, cleaved to active BNP + inactive NT-proBNP. Binds NPR-A (same receptor as ANP). Same mechanism: cGMP generation, natriuresis, diuresis, vasodilation, RAAS suppression. Despite its name (first isolated from porcine brain), primary physiological source is ventricular myocardium in response to volume and pressure overload.",
            "BNP <100 pg/mL: heart failure unlikely. BNP >400 pg/mL: heart failure likely. NT-proBNP has longer half-life, useful for monitoring. Elevated in renal failure (reduced clearance), must adjust cutoffs. Nesiritide (recombinant BNP): was used IV for acute decompensated HF but fell out of favor (no mortality benefit, hypotension risk). Obesity paradoxically lowers BNP (adipocytes express NPR-C clearance receptor).",
            "Guyton 14th ed, Ch 28; Boron 3rd ed, Ch 35"
        )
    }
    if name == "erythropoietin" {
        return hormone(
            "Erythropoietin (EPO)",
            "Kidney (peritubular interstitial fibroblasts, ~90%); liver (~10%, major fetal source)",
            "Bone marrow (erythroid progenitor cells: CFU-E and proerythroblasts)",
            "165-amino-acid glycoprotein (30.4 kDa). Binds EPO receptor (EpoR, JAK-STAT type, UniProt P19235). Activates JAK2-STAT5, PI3K-Akt, and MAPK pathways. Stimulates proliferation and differentiation of erythroid progenitors, inhibits apoptosis (survival factor), increases reticulocyte release from marrow. Secretion regulated by hypoxia: low pO2 stabilizes HIF-2alpha (hypoxia-inducible factor, UniProt Q99814), which dimerizes with HIF-1beta and binds hypoxia response elements (HREs) in the EPO gene enhancer. In normoxia, HIF is hydroxylated by prolyl hydroxylase (PHD) and degraded via VHL-ubiquitin-proteasome pathway.",
            "Anemia of CKD: reduced EPO production due to lost renal mass. Treated with recombinant EPO (epoetin alfa) or darbepoetin alfa (longer half-life). Target Hgb 10-11 g/dL (higher targets increase cardiovascular risk per TREAT and CHOIR trials). EPO doping in athletics: increases RBC mass and oxygen carrying capacity. Detected by isoelectric focusing (recombinant EPO differs in glycosylation). Polycythemia vera: EPO-independent erythrocytosis due to JAK2 V617F mutation (EPO receptor constitutively active). EPO is LOW (suppressed by elevated Hgb). HIF-PHD inhibitors (roxadustat, daprodustat): oral drugs that stabilize HIF, increasing endogenous EPO. Approved for CKD anemia.",
            "Guyton 14th ed, Ch 33; Boron 3rd ed, Ch 18"
        )
    }
    if name == "melatonin" {
        return hormone(
            "Melatonin (N-acetyl-5-methoxytryptamine)",
            "Pineal gland (pinealocytes)",
            "Suprachiasmatic nucleus (SCN) of hypothalamus, immune cells, gonads",
            "Indoleamine derived from serotonin. Synthesis: tryptophan -> serotonin -> N-acetylserotonin (by AANAT, arylalkylamine N-acetyltransferase, UniProt Q16613, the rate-limiting enzyme) -> melatonin (by ASMT/HIOMT, UniProt P46597). Secretion follows circadian rhythm: LOW during day, HIGH at night (darkness). Light detected by retinal melanopsin-containing ganglion cells -> retinohypothalamic tract -> SCN -> superior cervical ganglion -> sympathetic innervation of pineal -> norepinephrine activates beta-1 then alpha-1 receptors -> cAMP rise -> AANAT induction. Binds MT1 (GPCR, Gi, UniProt P48039) and MT2 (GPCR, Gi, UniProt P49286). Promotes sleep onset, modulates circadian rhythms.",
            "Jet lag and shift work: exogenous melatonin helps entrain circadian clock. Ramelteon (MT1/MT2 agonist): FDA-approved for insomnia (sleep onset). Tasimelteon: approved for non-24-hour sleep-wake disorder (common in totally blind individuals). Melatonin decreases with age (may contribute to age-related sleep disturbances). Pineal tumors can cause precocious puberty (if melatonin production decreases) or delayed puberty (if melatonin excess). Melatonin has antioxidant and immunomodulatory properties.",
            "Boron 3rd ed, Ch 48; Guyton 14th ed, Ch 76"
        )
    }
    return hormone("", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION XI: FEEDBACK AXES
// ═══════════════════════════════════════════════════════════════════
//
// Endocrine homeostasis depends on negative feedback loops. Each major
// axis has three tiers: hypothalamus -> pituitary -> target gland.
// The target gland hormone feeds back to suppress both hypothalamic
// releasing hormone and pituitary tropic hormone. Disruption at any
// level produces characteristic patterns:
//   Primary failure (target gland): high tropic hormones (loss of feedback)
//   Secondary failure (pituitary): low tropic hormones, low target hormones
//   Tertiary failure (hypothalamus): low releasing hormones, low everything

fn lookup_feedback_axis(name: String) -> FeedbackAxis {
    if name == "HPA" {
        return feedback_axis(
            "Hypothalamic-Pituitary-Adrenal (HPA) Axis",
            "Hypothalamus releases CRH (and AVP as co-secretagogue) from paraventricular nucleus into hypophyseal portal blood. Stimulated by stress (physical, psychological, inflammatory), circadian rhythm (CRH peaks early morning), and cytokines (IL-1, IL-6, TNF-alpha).",
            "CRH binds CRH-R1 on anterior pituitary corticotrophs. ACTH is cleaved from POMC and released into systemic circulation. ACTH has diurnal rhythm: highest at 6-8 AM, lowest at midnight.",
            "ACTH binds MC2R on adrenal cortex zona fasciculata. Stimulates cortisol synthesis and release via StAR protein upregulation and steroidogenic enzyme induction. Also has trophic effect (maintains adrenal cortex mass).",
            "Cortisol feeds back at TWO levels: (a) Hypothalamus: suppresses CRH gene transcription. (b) Anterior pituitary: suppresses POMC gene transcription and ACTH release. Fast feedback (minutes): non-genomic, inhibits CRH release. Slow feedback (hours-days): genomic, reduces CRH and ACTH synthesis. Exogenous glucocorticoids suppress the entire axis -- abrupt withdrawal causes adrenal crisis (atrophied adrenals cannot respond).",
            "Cushing syndrome (cortisol excess). Cushing disease: pituitary ACTH adenoma -- high ACTH, high cortisol, bilateral adrenal hyperplasia, responds to high-dose dexamethasone suppression. Ectopic ACTH (small cell lung, carcinoid): very high ACTH, does NOT suppress with high-dose dexa. Adrenal adenoma/carcinoma: high cortisol, LOW ACTH (suppressed). Differentiation: CRH stimulation test, petrosal sinus sampling.",
            "Addison disease (primary adrenal insufficiency): autoimmune (most common in developed world), TB (most common globally), adrenal hemorrhage (Waterhouse-Friderichsen in meningococcemia). Low cortisol, HIGH ACTH, hyperpigmentation. Secondary adrenal insufficiency: pituitary failure or exogenous glucocorticoid withdrawal. Low cortisol, LOW ACTH, NO hyperpigmentation.",
            "Guyton 14th ed, Ch 77-78; Boron 3rd ed, Ch 50"
        )
    }
    if name == "HPT" {
        return feedback_axis(
            "Hypothalamic-Pituitary-Thyroid (HPT) Axis",
            "Hypothalamus releases TRH from paraventricular nucleus into portal blood. TRH secretion is stimulated by cold exposure, reduced by fasting, illness (sick euthyroid), and dopamine.",
            "TRH binds TRH-R1 on anterior pituitary thyrotrophs. TSH is released (glycoprotein, alpha + beta subunits). TSH has diurnal rhythm with nocturnal surge. TSH is the most sensitive indicator of thyroid status.",
            "TSH binds TSH-R on thyroid follicular cells. Stimulates NIS expression (iodide uptake), thyroglobulin synthesis, TPO activity, colloid endocytosis, T4/T3 release, and thyroid growth. ~90% T4 output, ~10% T3 output. Peripheral deiodinases convert T4 to active T3.",
            "T3 (and T4 after intrapituitary conversion to T3 by DIO2) feeds back at BOTH levels: (a) Anterior pituitary: T3 directly suppresses TSH-beta gene transcription (dominant feedback site). (b) Hypothalamus: T3 suppresses TRH gene expression. This creates the classic inverse log-linear relationship: small changes in free T4 cause large changes in TSH. A doubling of free T4 decreases TSH ~100-fold.",
            "Graves disease: TSI (thyroid-stimulating immunoglobulin) activates TSH-R constitutively. Excess T4/T3 production. TSH suppressed (<0.01). Diffuse goiter, exophthalmos, pretibial myxedema. Toxic multinodular goiter (Plummer disease) and toxic adenoma also cause hyperthyroidism. TSH-secreting pituitary adenoma (very rare): high T4 WITH high TSH (secondary hyperthyroidism).",
            "Hashimoto thyroiditis: anti-TPO and anti-thyroglobulin antibodies cause progressive thyroid destruction. Most common cause of hypothyroidism in iodine-sufficient areas. Initially may have hashitoxicosis (hormone release from destruction), then permanent hypothyroidism. High TSH, low T4. Iodine deficiency: most common cause of hypothyroidism worldwide, causes endemic goiter. Congenital hypothyroidism: thyroid dysgenesis or dyshormonogenesis, causes cretinism if untreated (newborn screening is mandatory). Central hypothyroidism: pituitary or hypothalamic lesion, low T4 with low/normal TSH.",
            "Guyton 14th ed, Ch 77; Boron 3rd ed, Ch 49"
        )
    }
    if name == "HPG" {
        return feedback_axis(
            "Hypothalamic-Pituitary-Gonadal (HPG) Axis",
            "Hypothalamus releases GnRH in PULSATILE fashion from arcuate nucleus. Pulse frequency matters: fast pulses (~every 60 min) favor LH secretion; slow pulses (~every 120 min) favor FSH. GnRH neurons are activated at puberty (kisspeptin from KISS1 neurons is the puberty trigger). GnRH is inhibited by endogenous opioids, stress, low body weight (low leptin), and prolactin (lactational amenorrhea).",
            "GnRH binds GnRH-R on anterior pituitary gonadotrophs. Both FSH and LH are released (differential regulation by pulse frequency and inhibin/activin). In females, FSH and LH show dramatic cyclic variation across the menstrual cycle. In males, relatively constant (pulsatile but tonic). The LH surge in females is unique: a POSITIVE feedback effect of rising estradiol (>200 pg/mL sustained for >36 hours) at the pituitary, triggering massive LH release and ovulation.",
            "FSH targets: Sertoli cells (male, supports spermatogenesis) and granulosa cells (female, aromatase expression, follicular growth). LH targets: Leydig cells (male, testosterone synthesis) and theca cells/corpus luteum (female, androgen synthesis, progesterone after ovulation).",
            "Testosterone (male) feeds back on hypothalamus (reduces GnRH pulse amplitude) and pituitary (reduces LH primarily). Inhibin B (from Sertoli cells) selectively suppresses FSH. Estradiol + progesterone (female, luteal phase) suppress GnRH pulsatility and gonadotropin release. Activin stimulates FSH; follistatin binds and neutralizes activin.",
            "Precocious puberty: GnRH-dependent (central) or GnRH-independent (peripheral, e.g., adrenal tumors, McCune-Albright). Central precocious puberty treated with continuous GnRH agonists (leuprolide -- paradoxical suppression via receptor downregulation). Polycystic ovary syndrome (PCOS): increased GnRH pulse frequency favors LH over FSH, elevated LH drives theca androgen production, insufficient FSH prevents follicular maturation -- anovulation, hyperandrogenism, polycystic ovaries.",
            "Hypogonadotropic hypogonadism: Kallmann syndrome (GnRH neuron migration failure due to KAL1/ANOS1 gene mutation, anosmia + hypogonadism), hypothalamic amenorrhea (stress, low weight, excessive exercise -- functional GnRH suppression), pituitary tumors. Primary gonadal failure: premature ovarian insufficiency (elevated FSH, low estradiol, age <40), Turner syndrome (45,X, streak gonads), Klinefelter syndrome (47,XXY, small testes, azoospermia, gynecomastia, elevated FSH/LH).",
            "Guyton 14th ed, Ch 81-82; Boron 3rd ed, Ch 55-56"
        )
    }
    return feedback_axis("", "", "", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION XII: RECEPTOR TYPES
// ═══════════════════════════════════════════════════════════════════
//
// How a hormone signals determines its onset speed, duration of action,
// and whether it can be blocked by pharmacological agents. The fundamental
// distinction: lipophilic hormones (steroids, thyroid) cross the membrane
// and bind nuclear receptors (slow genomic effects), while hydrophilic
// hormones (peptides, catecholamines) bind membrane receptors (fast
// signaling cascades).

fn lookup_receptor_class(name: String) -> ReceptorClass {
    if name == "nuclear_steroid" {
        return receptor_class(
            "Nuclear receptor -- steroid subfamily",
            "Cortisol (GR, NR3C1), aldosterone (MR, NR3C2), testosterone/DHT (AR, NR3C4), estradiol (ER-alpha ESR1, ER-beta ESR2), progesterone (PR, NR3C3)",
            "Intracellular (cytoplasm for steroid receptors -- bound to HSP90 chaperones when unliganded; nucleus after ligand binding and translocation)",
            "Ligand crosses membrane (lipophilic). Binds receptor, displacing HSP90. Receptor dimerizes, translocates to nucleus (if not already there), binds hormone response elements (HREs) in DNA promoter regions. Recruits coactivators or corepressors. Modulates gene transcription. New protein synthesis takes hours. Can also have rapid non-genomic effects via membrane-associated receptors (e.g., membrane ER activates MAPK within minutes).",
            "Hours to days (requires gene transcription and protein synthesis)",
            "Hours to days (stable gene expression changes persist until proteins turn over)",
            "Guyton 14th ed, Ch 75; Boron 3rd ed, Ch 3"
        )
    }
    if name == "nuclear_thyroid" {
        return receptor_class(
            "Nuclear receptor -- thyroid/retinoid subfamily",
            "T3 (TR-alpha, TR-beta), calcitriol/vitamin D (VDR), retinoids (RAR, RXR)",
            "Intracellular (nucleus -- thyroid and vitamin D receptors are already bound to DNA response elements even without ligand, acting as transcriptional repressors when unliganded)",
            "Ligand enters cell (T3 via MCT8 transporter; calcitriol diffuses through membrane). Binds nuclear receptor already sitting on DNA as heterodimer with RXR. Without ligand: receptor recruits corepressors (NCoR, SMRT) -- active repression. With ligand: conformational change, corepressors released, coactivators recruited -- active transcription. This is a switch from repression to activation, not simply activation.",
            "Hours (requires transcription and translation; faster than steroid receptors because receptors are pre-positioned on DNA)",
            "Hours to days",
            "Guyton 14th ed, Ch 77; Boron 3rd ed, Ch 3, 49"
        )
    }
    if name == "GPCR" {
        return receptor_class(
            "G protein-coupled receptor (GPCR, seven-transmembrane receptor)",
            "ACTH (MC2R, Gs), TSH (TSHR, Gs), LH (LH/CGR, Gs), FSH (FSHR, Gs), PTH (PTH1R, Gs/Gq), ADH (V2R Gs, V1aR Gq), oxytocin (OTR, Gq), glucagon (Gs), GnRH (Gq), CRH (Gs), TRH (Gq), catecholamines (alpha/beta adrenergic), somatostatin (Gi), dopamine (D2 Gi), melatonin (MT1/MT2 Gi)",
            "Cell membrane (seven-transmembrane domain, extracellular N-terminus, intracellular C-terminus coupled to heterotrimeric G protein)",
            "Ligand binds extracellular/transmembrane pocket. Conformational change activates heterotrimeric G protein (alpha-beta-gamma subunits). G-alpha subunit exchanges GDP for GTP and dissociates. (a) Gs: activates adenylyl cyclase -> cAMP -> PKA. (b) Gi: inhibits adenylyl cyclase -> decreases cAMP. (c) Gq: activates phospholipase C (PLC) -> PIP2 hydrolysis -> IP3 (Ca2+ release from ER) + DAG (activates PKC). G-alpha GTPase activity terminates signal (intrinsic timer). Beta-gamma subunits also signal (e.g., activate GIRK K+ channels). Receptor desensitization: GRK phosphorylation -> beta-arrestin binding -> internalization.",
            "Seconds to minutes (second messenger cascades amplify signal rapidly)",
            "Minutes to hours (until second messengers degraded, kinases deactivated)",
            "Guyton 14th ed, Ch 75; Boron 3rd ed, Ch 3"
        )
    }
    if name == "RTK" {
        return receptor_class(
            "Receptor tyrosine kinase (RTK)",
            "Insulin (insulin receptor, INSR), IGF-1 (IGF-1R), EGF (EGFR), PDGF (PDGFR), FGF (FGFR), VEGF (VEGFR)",
            "Cell membrane (single-pass transmembrane, extracellular ligand-binding domain, intracellular tyrosine kinase domain)",
            "Ligand binds extracellular domain, causing receptor dimerization (or conformational change in pre-formed dimers like insulin receptor). Intracellular kinase domains cross-phosphorylate each other on tyrosine residues (autophosphorylation). Phosphotyrosines serve as docking sites for SH2/PTB domain-containing adaptor proteins (IRS, Grb2, Shc). Major pathways activated: (a) Ras-MAPK (Raf -> MEK -> ERK): cell proliferation, differentiation. (b) PI3K-Akt/PKB: glucose uptake (GLUT4 translocation), protein synthesis (mTOR), anti-apoptosis, cell survival. (c) PLC-gamma: IP3 and DAG signaling.",
            "Seconds to minutes (phosphorylation cascades)",
            "Minutes to hours (until phosphatases reverse phosphorylation, receptors internalized and degraded/recycled)",
            "Guyton 14th ed, Ch 75; Boron 3rd ed, Ch 3"
        )
    }
    if name == "JAK_STAT" {
        return receptor_class(
            "JAK-STAT cytokine receptor",
            "GH (GHR), prolactin (PRLR), erythropoietin (EpoR), leptin (ObR/LEPR), cytokines (IL-2R, IL-6R, IFN receptors)",
            "Cell membrane (single-pass transmembrane, no intrinsic kinase activity -- uses associated JAK kinases)",
            "Ligand binding causes receptor dimerization or multimerization. Associated JAK kinases (JAK1, JAK2, JAK3, TYK2) transphosphorylate each other, then phosphorylate tyrosine residues on the receptor intracellular domain. STAT proteins (STAT1-6) dock on phosphotyrosines via SH2 domains, are phosphorylated by JAKs, dimerize, and translocate to nucleus to activate gene transcription. GH uses JAK2-STAT5b. Negative regulation: SOCS proteins (suppressors of cytokine signaling) are transcribed by STATs and feedback-inhibit JAKs. Protein tyrosine phosphatases (SHP-1) also terminate signaling.",
            "Minutes to hours (requires STAT nuclear translocation and gene transcription)",
            "Hours (SOCS-mediated negative feedback, receptor internalization)",
            "Boron 3rd ed, Ch 3; Guyton 14th ed, Ch 75-76"
        )
    }
    return receptor_class("", "", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION XIII: KEY ENDOCRINE ENZYMES
// ═══════════════════════════════════════════════════════════════════

fn lookup_endocrine_enzyme(name: String) -> Enzyme {
    if name == "aromatase" {
        return enzyme(
            "Aromatase (estrogen synthase)",
            "CYP19A1",
            "P11511",
            "Converts C19 androgens to C18 estrogens: androstenedione -> estrone (E1), testosterone -> estradiol (E2). Three sequential hydroxylation reactions with loss of C19 methyl group and aromatization of the A ring. Requires NADPH and O2. Expressed in ovarian granulosa cells, placenta, adipose tissue, breast, brain, bone.",
            "Aromatase inhibitors (letrozole, anastrozole -- nonsteroidal reversible; exemestane -- steroidal irreversible) used as first-line adjuvant therapy in postmenopausal ER+ breast cancer. More effective than tamoxifen in postmenopausal women. Side effects: musculoskeletal pain, osteoporosis (estrogen deprivation). Aromatase excess syndrome: gynecomastia, precocious puberty in males. Aromatase deficiency: virilization of mother and female fetus during pregnancy (placenta cannot aromatize fetal androgens), tall stature and osteoporosis in males (no estrogen for epiphyseal closure).",
            "Boron 3rd ed, Ch 55-56; UniProt P11511"
        )
    }
    if name == "5_alpha_reductase" {
        return enzyme(
            "5-alpha-reductase (steroid 5-alpha-reductase)",
            "SRD5A2",
            "P31213",
            "Converts testosterone to dihydrotestosterone (DHT) by reduction of the delta-4,5 double bond. DHT has 2-3x higher affinity for androgen receptor than testosterone. Two main isozymes: type 1 (SRD5A1, skin, liver) and type 2 (SRD5A2, prostate, seminal vesicles, hair follicles, genital skin). Type 2 is clinically more important.",
            "5-alpha-reductase deficiency (SRD5A2 mutations): 46,XY DSD (disorder of sex development). External genitalia ambiguous at birth (female-appearing because DHT drives external virilization in utero). At puberty, testosterone rises and virilization occurs (voice deepens, muscle mass increases, phallus enlarges). No prostate enlargement, no male-pattern baldness. Pharmacological inhibition: finasteride (type 2 selective), dutasteride (type 1 and 2). Used for BPH (reduces prostate volume) and androgenetic alopecia.",
            "Boron 3rd ed, Ch 55; UniProt P31213"
        )
    }
    if name == "StAR" {
        return enzyme(
            "Steroidogenic acute regulatory protein (StAR)",
            "STAR",
            "P49675",
            "Transfers cholesterol from the outer to inner mitochondrial membrane -- the rate-limiting step in ALL steroidogenesis. Without StAR, cholesterol cannot reach CYP11A1 (side-chain cleavage enzyme) on the inner mitochondrial membrane. StAR expression is rapidly upregulated by ACTH (adrenal cortex) and LH (gonads) via cAMP-PKA pathway. StAR is a short-lived protein (rapidly synthesized, rapidly degraded).",
            "Congenital lipoid adrenal hyperplasia (lipoid CAH): StAR mutations cause inability to synthesize ANY steroid hormones. Cholesterol esters accumulate in adrenal cortex (lipoid appearance). Severely affected: salt-wasting crisis (no aldosterone), cortisol deficiency, 46,XY DSD (no androgens for virilization). 46,XX individuals appear female. Most severe form of CAH. Requires lifelong glucocorticoid and mineralocorticoid replacement.",
            "Boron 3rd ed, Ch 50; UniProt P49675"
        )
    }
    if name == "CYP11A1" {
        return enzyme(
            "Cholesterol side-chain cleavage enzyme (P450scc)",
            "CYP11A1",
            "P05108",
            "Catalyzes the first committed step of steroidogenesis: cholesterol -> pregnenolone (with release of isocaproaldehyde). Three sequential monooxygenase reactions (20-alpha-hydroxylation, 22-hydroxylation, C20-C22 bond cleavage). Located on inner mitochondrial membrane. Requires adrenodoxin and adrenodoxin reductase as electron transfer partners (NADPH). Present in all steroidogenic tissues: adrenal cortex, gonads, placenta, brain.",
            "CYP11A1 deficiency: extremely rare, similar presentation to lipoid CAH (no steroid synthesis). Some mutations cause partial deficiency with later-onset adrenal insufficiency. The enzyme is also expressed in skin (local vitamin D activation) and brain (neurosteroid synthesis -- pregnenolone and allopregnanolone have neuroactive properties).",
            "Boron 3rd ed, Ch 50; UniProt P05108"
        )
    }
    if name == "21_hydroxylase" {
        return enzyme(
            "21-hydroxylase (steroid 21-hydroxylase)",
            "CYP21A2",
            "P08686",
            "Converts 17-hydroxyprogesterone -> 11-deoxycortisol (cortisol pathway) and progesterone -> 11-deoxycorticosterone (aldosterone pathway). Located in smooth ER of adrenal cortical cells. Requires P450 oxidoreductase (POR) as electron donor. Gene located on chromosome 6p21.3 in the HLA complex, adjacent to a pseudogene (CYP21A1P) -- unequal crossing-over and gene conversion cause most mutations.",
            "21-hydroxylase deficiency is the MOST COMMON cause of CAH (>90% of cases). Incidence ~1:15,000 live births. Classic salt-wasting form: no cortisol, no aldosterone, shunting to androgens. Neonatal adrenal crisis (salt-wasting), ambiguous genitalia in 46,XX (virilization from excess androgens). Simple virilizing form: enough aldosterone to prevent salt-wasting but androgen excess. Nonclassic (late-onset): mild, presents in adolescence with hirsutism, acne, oligomenorrhea. Diagnosed by elevated 17-hydroxyprogesterone. Newborn screening (17-OHP) is standard in most countries.",
            "Boron 3rd ed, Ch 50; UniProt P08686"
        )
    }
    return enzyme("", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION XIV: KEY ENDOCRINE RECEPTORS
// ═══════════════════════════════════════════════════════════════════

fn lookup_endocrine_receptor(name: String) -> Receptor {
    if name == "insulin_receptor" {
        return receptor(
            "Insulin receptor (INSR)",
            "Receptor tyrosine kinase (RTK)",
            "P06213",
            "Insulin",
            "Pre-formed alpha2-beta2 heterotetramer (disulfide-linked). Insulin binds alpha subunits, causes conformational change in beta subunits, activating intrinsic tyrosine kinase. Autophosphorylation on multiple tyrosine residues. IRS-1/IRS-2 dock and are phosphorylated -> PI3K activation -> PIP3 -> Akt/PKB -> GLUT4 translocation, glycogen synthase activation, mTOR (protein synthesis), FOXO inhibition (reduced gluconeogenesis gene expression). Also activates Ras-MAPK for mitogenic effects.",
            "Insulin receptor mutations: type A insulin resistance (leprechaunism/Donohue syndrome in severe cases, Rabson-Mendenhall syndrome). Insulin receptor antibodies: type B insulin resistance (autoimmune, acanthosis nigricans, can paradoxically cause hypoglycemia). Metabolic syndrome: postreceptor insulin resistance at level of IRS-1 serine phosphorylation (by JNK, IKK-beta, PKC-theta) -- reduces tyrosine phosphorylation, impairs PI3K signaling.",
            "Guyton 14th ed, Ch 79; Boron 3rd ed, Ch 51"
        )
    }
    if name == "glucocorticoid_receptor" {
        return receptor(
            "Glucocorticoid receptor (GR, NR3C1)",
            "Nuclear receptor (steroid subfamily, type I)",
            "P04150",
            "Cortisol (endogenous), dexamethasone, prednisone/prednisolone (synthetic)",
            "Cytoplasmic when unliganded, bound to HSP90/HSP70 chaperone complex. Cortisol binding -> HSP90 dissociation -> GR dimerization -> nuclear translocation -> binds glucocorticoid response elements (GREs, consensus: AGAACAnnnTGTTCT). Transactivation: upregulates anti-inflammatory genes (IkB-alpha, lipocortin-1/annexin A1, IL-10). Transrepression: GR monomers interact with NF-kB and AP-1 to suppress pro-inflammatory gene transcription (IL-1, IL-6, TNF-alpha, COX-2) without direct DNA binding. Transrepression is thought to mediate most anti-inflammatory effects.",
            "Glucocorticoid resistance: rare GR mutations cause elevated cortisol with no Cushing features (compensatory ACTH rise drives adrenal androgen and mineralocorticoid excess -- hypertension, hypokalemia, hirsutism). Pharmacological: chronic glucocorticoid therapy downregulates GR and causes HPA suppression. Must taper to allow axis recovery. Selective GR modulators under development to separate anti-inflammatory from metabolic side effects.",
            "Guyton 14th ed, Ch 78; Boron 3rd ed, Ch 50"
        )
    }
    if name == "TSH_receptor" {
        return receptor(
            "TSH receptor (TSHR)",
            "GPCR (Gs-coupled primarily, also Gq at high stimulation)",
            "P16473",
            "TSH (endogenous), TSI/TRAb (thyroid-stimulating immunoglobulins in Graves disease), hCG (weak agonist, explains gestational thyrotoxicosis)",
            "Ligand binding activates Gs -> adenylyl cyclase -> cAMP -> PKA. Stimulates all aspects of thyroid hormone synthesis and secretion. At higher stimulation (Gq pathway): PLC -> IP3/DAG -> thyroid growth. Constitutive activity (ligand-independent signaling) is low but present -- gain-of-function mutations increase it.",
            "Graves disease: TSI (thyroid-stimulating immunoglobulin, a type of TRAb) binds and constitutively activates TSHR -> unregulated thyroid hormone production, thyroid growth (diffuse goiter). TSH is suppressed by excess T4/T3 but the gland does not respond to TSH suppression because TSI bypasses normal regulation. Gain-of-function TSHR mutations: toxic thyroid adenoma (somatic mutation in one cell clone), familial non-autoimmune hyperthyroidism (germline). Loss-of-function mutations: TSH resistance, congenital hypothyroidism with elevated TSH.",
            "Guyton 14th ed, Ch 77; Boron 3rd ed, Ch 49"
        )
    }
    if name == "calcium_sensing_receptor" {
        return receptor(
            "Calcium-sensing receptor (CaSR)",
            "GPCR (Gq/G11-coupled, class C family)",
            "P41180",
            "Ionized calcium (Ca2+) -- the receptor senses extracellular Ca2+ concentration directly",
            "Expressed on parathyroid chief cells and renal tubular cells. Rising Ca2+ activates CaSR -> Gq -> PLC -> IP3/DAG -> intracellular Ca2+ rise. In parathyroid: Ca2+ elevation INHIBITS PTH secretion (negative modulation -- the receptor signals that calcium is sufficient). In kidney thick ascending limb: CaSR activation inhibits ROMK and NKCC2, reducing Ca2+ reabsorption (promotes calciuria). CaSR is a homodimer, class C GPCR (large extracellular venus flytrap domain).",
            "Activating CaSR mutations (gain-of-function): autosomal dominant hypocalcemia (ADH, also called familial hypocalciuric hypercalcemia type 1 when inactivating). The receptor is too sensitive, suppresses PTH at lower Ca2+ than normal -> hypocalcemia. Inactivating CaSR mutations (loss-of-function): familial hypocalciuric hypercalcemia (FHH) -- mildly elevated Ca2+, inappropriately normal PTH, low urine Ca2+. Homozygous: neonatal severe hyperparathyroidism (NSHPT). Cinacalcet (calcimimetic): positive allosteric modulator of CaSR, makes it more sensitive to Ca2+, suppresses PTH. Used in secondary hyperparathyroidism (CKD) and parathyroid carcinoma.",
            "Guyton 14th ed, Ch 80; Boron 3rd ed, Ch 52"
        )
    }
    if name == "androgen_receptor" {
        return receptor(
            "Androgen receptor (AR, NR3C4)",
            "Nuclear receptor (steroid subfamily, type I)",
            "P10275",
            "Testosterone, dihydrotestosterone (DHT, 2-3x higher affinity)",
            "Similar to GR mechanism: cytoplasmic when unliganded (HSP90-bound) -> ligand binding -> HSP90 release -> AR dimerization -> nuclear translocation -> binds androgen response elements (AREs) in target gene promoters. Activates transcription of genes for muscle protein synthesis, bone density maintenance, spermatogenesis support, sebaceous gland activity, hair follicle growth (paradoxically, scalp hair loss in androgenetic alopecia). AR has CAG trinucleotide repeat in exon 1 -- longer repeats reduce transcriptional activity.",
            "Complete androgen insensitivity syndrome (CAIS): 46,XY individuals with non-functional AR develop female external phenotype despite normal/elevated testosterone. Testes present (intra-abdominal), no uterus (AMH still functional). Assigned female at birth, raised female. Partial AIS (PAIS): ambiguous genitalia. Mild AIS: infertility, gynecomastia. Prostate cancer: AR-dependent for growth. Androgen deprivation therapy (ADT) initially effective, then castration-resistant prostate cancer (CRPC) emerges -- often through AR amplification, AR mutations (gain-of-function, activated by other steroids), AR splice variants (AR-V7, constitutively active without ligand). Enzalutamide (AR antagonist), apalutamide, darolutamide used in CRPC. Kennedy disease (spinal and bulbar muscular atrophy): expanded CAG repeat in AR (>36 repeats), polyglutamine neurotoxicity.",
            "Boron 3rd ed, Ch 55; Guyton 14th ed, Ch 81"
        )
    }
    return receptor("", "", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION XV: UNIFIED HORMONE LOOKUP
// ═══════════════════════════════════════════════════════════════════
//
// A single entry point that searches all gland-specific lookups.

fn lookup_hormone(name: String) -> Hormone {
    // Hypothalamic
    if name == "CRH" { return lookup_hypothalamic_hormone("CRH") }
    if name == "TRH" { return lookup_hypothalamic_hormone("TRH") }
    if name == "GnRH" { return lookup_hypothalamic_hormone("GnRH") }
    if name == "GHRH" { return lookup_hypothalamic_hormone("GHRH") }
    if name == "somatostatin" { return lookup_hypothalamic_hormone("somatostatin") }
    if name == "dopamine" { return lookup_hypothalamic_hormone("dopamine") }
    // Anterior pituitary
    if name == "ACTH" { return lookup_anterior_pituitary("ACTH") }
    if name == "TSH" { return lookup_anterior_pituitary("TSH") }
    if name == "FSH" { return lookup_anterior_pituitary("FSH") }
    if name == "LH" { return lookup_anterior_pituitary("LH") }
    if name == "GH" { return lookup_anterior_pituitary("GH") }
    if name == "prolactin" { return lookup_anterior_pituitary("prolactin") }
    // Posterior pituitary
    if name == "ADH" { return lookup_posterior_pituitary("ADH") }
    if name == "vasopressin" { return lookup_posterior_pituitary("ADH") }
    if name == "oxytocin" { return lookup_posterior_pituitary("oxytocin") }
    // Thyroid
    if name == "T4" { return lookup_thyroid_hormone("T4") }
    if name == "T3" { return lookup_thyroid_hormone("T3") }
    if name == "calcitonin" { return lookup_thyroid_hormone("calcitonin") }
    // Parathyroid
    if name == "PTH" { return lookup_parathyroid("PTH") }
    if name == "calcitriol" { return lookup_parathyroid("calcitriol") }
    if name == "vitamin_D" { return lookup_parathyroid("calcitriol") }
    // Adrenal cortex
    if name == "cortisol" { return lookup_adrenal_cortex_hormone("cortisol") }
    if name == "aldosterone" { return lookup_adrenal_cortex_hormone("aldosterone") }
    if name == "DHEA" { return lookup_adrenal_cortex_hormone("DHEA") }
    // Adrenal medulla
    if name == "epinephrine" { return lookup_adrenal_medulla_hormone("epinephrine") }
    if name == "norepinephrine" { return lookup_adrenal_medulla_hormone("norepinephrine") }
    // Pancreas
    if name == "insulin" { return lookup_pancreatic_hormone("insulin") }
    if name == "glucagon" { return lookup_pancreatic_hormone("glucagon") }
    // Gonads
    if name == "testosterone" { return lookup_gonadal_hormone("testosterone") }
    if name == "estrogen" { return lookup_gonadal_hormone("estrogen") }
    if name == "estradiol" { return lookup_gonadal_hormone("estrogen") }
    if name == "progesterone" { return lookup_gonadal_hormone("progesterone") }
    // Other
    if name == "leptin" { return lookup_other_hormone("leptin") }
    if name == "ghrelin" { return lookup_other_hormone("ghrelin") }
    if name == "ANP" { return lookup_other_hormone("ANP") }
    if name == "BNP" { return lookup_other_hormone("BNP") }
    if name == "erythropoietin" { return lookup_other_hormone("erythropoietin") }
    if name == "EPO" { return lookup_other_hormone("erythropoietin") }
    if name == "melatonin" { return lookup_other_hormone("melatonin") }
    return hormone("", "", "", "", "", "")
}


// ═══════════════════════════════════════════════════════════════════
// SECTION XVI: COUNT AND HELPER FUNCTIONS
// ═══════════════════════════════════════════════════════════════════

fn hypothalamic_hormone_count() -> Int {
    return 6
}

fn anterior_pituitary_hormone_count() -> Int {
    return 6
}

fn posterior_pituitary_hormone_count() -> Int {
    return 2
}

fn thyroid_hormone_count() -> Int {
    return 3
}

fn parathyroid_hormone_count() -> Int {
    return 2
}

fn adrenal_cortex_hormone_count() -> Int {
    return 3
}

fn adrenal_medulla_hormone_count() -> Int {
    return 2
}

fn pancreatic_hormone_count() -> Int {
    return 2
}

fn gonadal_hormone_count() -> Int {
    return 3
}

fn other_hormone_count() -> Int {
    return 6
}

fn total_hormone_count() -> Int {
    return 35
}

fn catecholamine_step_count() -> Int {
    return 4
}

fn feedback_axis_count() -> Int {
    return 3
}

fn receptor_class_count() -> Int {
    return 5
}

fn adrenal_zone_count() -> Int {
    return 3
}

fn islet_cell_type_count() -> Int {
    return 3
}

fn endocrine_enzyme_count() -> Int {
    return 5
}

fn endocrine_receptor_count() -> Int {
    return 5
}

fn thyroid_enzyme_count() -> Int {
    return 3
}

fn is_steroid_hormone(name: String) -> Bool {
    if name == "cortisol" { return true }
    if name == "aldosterone" { return true }
    if name == "DHEA" { return true }
    if name == "testosterone" { return true }
    if name == "estrogen" { return true }
    if name == "estradiol" { return true }
    if name == "progesterone" { return true }
    if name == "calcitriol" { return true }
    if name == "vitamin_D" { return true }
    return false
}

fn is_peptide_hormone(name: String) -> Bool {
    if name == "CRH" { return true }
    if name == "TRH" { return true }
    if name == "GnRH" { return true }
    if name == "GHRH" { return true }
    if name == "somatostatin" { return true }
    if name == "ACTH" { return true }
    if name == "TSH" { return true }
    if name == "FSH" { return true }
    if name == "LH" { return true }
    if name == "GH" { return true }
    if name == "prolactin" { return true }
    if name == "ADH" { return true }
    if name == "oxytocin" { return true }
    if name == "calcitonin" { return true }
    if name == "PTH" { return true }
    if name == "insulin" { return true }
    if name == "glucagon" { return true }
    if name == "leptin" { return true }
    if name == "ghrelin" { return true }
    if name == "ANP" { return true }
    if name == "BNP" { return true }
    if name == "erythropoietin" { return true }
    return false
}

fn is_amine_hormone(name: String) -> Bool {
    if name == "T3" { return true }
    if name == "T4" { return true }
    if name == "epinephrine" { return true }
    if name == "norepinephrine" { return true }
    if name == "dopamine" { return true }
    if name == "melatonin" { return true }
    return false
}

fn uses_nuclear_receptor(name: String) -> Bool {
    if name == "cortisol" { return true }
    if name == "aldosterone" { return true }
    if name == "testosterone" { return true }
    if name == "estrogen" { return true }
    if name == "estradiol" { return true }
    if name == "progesterone" { return true }
    if name == "T3" { return true }
    if name == "T4" { return true }
    if name == "calcitriol" { return true }
    if name == "vitamin_D" { return true }
    if name == "DHEA" { return true }
    return false
}

fn uses_membrane_receptor(name: String) -> Bool {
    if name == "CRH" { return true }
    if name == "TRH" { return true }
    if name == "GnRH" { return true }
    if name == "GHRH" { return true }
    if name == "somatostatin" { return true }
    if name == "dopamine" { return true }
    if name == "ACTH" { return true }
    if name == "TSH" { return true }
    if name == "FSH" { return true }
    if name == "LH" { return true }
    if name == "GH" { return true }
    if name == "prolactin" { return true }
    if name == "ADH" { return true }
    if name == "oxytocin" { return true }
    if name == "calcitonin" { return true }
    if name == "PTH" { return true }
    if name == "insulin" { return true }
    if name == "glucagon" { return true }
    if name == "epinephrine" { return true }
    if name == "norepinephrine" { return true }
    if name == "leptin" { return true }
    if name == "ghrelin" { return true }
    if name == "ANP" { return true }
    if name == "BNP" { return true }
    if name == "erythropoietin" { return true }
    if name == "melatonin" { return true }
    return false
}
