# -*- coding: utf-8 -*-
"""Round 235: batch add 5 more Biology PhD (UChicago CEB / UMich MCDB / Duke MCB / Brown MCBGP / Columbia BioSci).
Key finding: Top-tier Biology PhD programs continue to be GRE-free. UChicago BSD 'optional for all PhD programs';
UMich MCDB 'we do NOT require the GRE'; Duke MCB 'GRE General optional'; Brown MCBGP 'not required / not considered';
Columbia BioSci 'no longer required'. Deadlines: Dec 1 (UChicago/UMich/Duke/Brown); Dec 2 (Columbia - one day later).
All five admit fall-only, full-time, and provide full funding.
"""
import os, re

BASE = os.path.dirname(os.path.abspath(__file__))
DET = os.path.join(BASE, "details")
os.makedirs(DET, exist_ok=True)

PROGRAMS = [
    {
        "id": "uchicago-ceb-phd",
        "s": "uchicago",
        "n": "进化生物学博士",
        "en": "PhD in Evolutionary Biology (University of Chicago Committee on Evolutionary Biology, CEB; part of Darwinian Sciences cluster with E&E and OBA)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5-6 years full-time residential; Autumn Quarter entry only; ~25-30 PhD students at a time; ~60 faculty across 4 graduate divisions + Argonne/Brookfield Zoo/Field Museum/Lincoln Park Zoo",
        "ddl": "Autumn 2027: December 1, 2026. Faculty review January/February; interviews by invitation; April 15 response deadline.",
        "lang": "TOEFL iBT or IELTS Academic required for non-native English speakers; ETS UChicago institution code 1832 (no dept code); English-medium undergraduate exempts.",
        "test": {"cls": 'GRE OPTIONAL FOR ALL PHD PROGRAMS (UChicago BSD FAQ: "The GRE test is optional for all PhD programs. However, if you have taken the GRE test within the last 5 years and wish to submit your scores, you may do so."); subject tests optional. 3 LOR; holistic review.'},
        "tui": "Full funding for admitted PhD students through UChicago Biological Sciences Division (tuition + stipend + health insurance) for 5+ years; support via RA/TA and external fellowships (NSF GRFP encouraged).",
        "url": "details/uchicago-ceb-phd.html",
    },
    {
        "id": "umich-mcdb-phd",
        "s": "umich",
        "n": "分子细胞与发育生物学博士",
        "en": "PhD in Molecular, Cellular, and Developmental Biology (University of Michigan LSA; two pathways: direct MCDB or PIBS umbrella)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5 to 5.5 years full-time residential; fall-only admission; fully supported in good standing; two core courses (Molecular Biology fall, Cell Biology winter) + rotations; thesis mentor by start of G2",
        "ddl": "Fall 2027: December 1, 2026 (application opens September 2026). PhD fall-only; MS deadline March 1 (separate).",
        "lang": "TOEFL iBT required for international applicants from non-English-speaking undergraduate programs; ETS UMich code 1839, dept code 35; IELTS also accepted.",
        "test": {"cls": "GRE NOT REQUIRED (UMich MCDB: 'Note: we do NOT require the GRE.'). No minimum GPA; expected background: biology, physics, organic chemistry, calculus, advanced biology. 3 LOR; Academic SOP + Personal Statement; CV."},
        "tui": "Full support for PhD students in good standing through Rackham Graduate School and MCDB (tuition + stipend + health insurance) for 5-5.5 years.",
        "url": "details/umich-mcdb-phd.html",
    },
    {
        "id": "duke-mcb-phd",
        "s": "duke",
        "n": "分子癌症生物学博士",
        "en": "PhD in Molecular Cancer Biology (Duke University Department of Pharmacology and Cancer Biology, PCB; part of Duke Cancer Institute)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5-6 years full-time residential; fall-only admission; no part-time; 41 faculty / 34 students; interdisciplinary across Duke School of Medicine",
        "ddl": "Fall 2027: December 1, 2026, 11:59:59 PM EST. Interviews mid-January; on-site recruitment weekends February; decisions March.",
        "lang": "TOEFL iBT / IELTS Academic / Duolingo English Test required for non-native English speakers; waiver available under some criteria; ETS Duke institution code 5156.",
        "test": {"cls": "GRE GENERAL OPTIONAL (Duke Graduate School: 'This program does not require applicants to provide GRE scores, but does allow you to upload scores if you feel they enhance your application.'); self-reported scores require official verification. 3 LOR; SOP; resume; undergrad GPA on 4.0 scale."},
        "tui": "Full funding for admitted PhD students through Duke Graduate School and PCB (tuition + stipend + health insurance) via research/teaching assistantships and fellowships.",
        "url": "details/duke-mcb-phd.html",
    },
    {
        "id": "brown-mcbgp-phd",
        "s": "brown",
        "n": "分子细胞与生物化学博士",
        "en": "PhD in Molecular Biology, Cell Biology, and Biochemistry (Brown University MCBGP; interdisciplinary interdepartmental Program in Biology)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "~5.5 years full-time residential; fall-only admission; interdisciplinary across 5 departments in Program in Biology (EEB/MCB/MMI/MPPB/Neuroscience); 3 short essays required",
        "ddl": "Fall 2027: December 1, 2026. Interviews February; decisions March; April 15 reply.",
        "lang": "TOEFL iBT required for international students; Brown Graduate School language requirements apply; MCBGP has no additional language requirement; waiver available per Brown policy.",
        "test": {"cls": "GRE NOT REQUIRED (Brown MCBGP: 'The MCBGP does not require the GRE for admission and does not consider GRE scores in evaluating applications.' Both General and Subject tests not required. 3 short essays; 3 LOR (up to 5 accepted); transcript(s)."},
        "tui": "Full financial support for admitted PhD students (stipend + tuition + health insurance) while research and academic studies progress satisfactorily.",
        "url": "details/brown-mcbgp-phd.html",
    },
    {
        "id": "col-biosci-phd",
        "s": "col",
        "n": "生物科学博士",
        "en": "PhD in Biological Sciences (Columbia University Department of Biological Sciences, Graduate School of Arts and Sciences; Morningside campus)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "5-6 years full-time residential; fall-only admission; full-time degree; must list at least 3 faculty potential advisors on application; two open-house weekends in February",
        "ddl": "Fall 2027: December 2, 2026 (application opens September 2026). Open House/Interviews February 5-6 and February 26-27, 2027; April 15 response deadline.",
        "lang": "TOEFL iBT minimum 100 (paper 600) or IELTS Academic minimum 7.5; ETS Columbia GSAS code 2162; no dept code; English-medium undergraduate degree exempts.",
        "test": {"cls": "GRE NO LONGER REQUIRED (Columbia BioSci: 'No GREs are required for the Biological Sciences PhD program.') 3 LOR (at least 2 academic; up to 4 accepted); resume required; no writing sample; must list 3+ potential faculty advisors."},
        "tui": "Full funding for admitted PhD students (annually adjusted stipend + full tuition exemption + health insurance + fees) through Columbia GSAS and Department of Biological Sciences; discounted Morningside housing.",
        "url": "details/col-biosci-phd.html",
    },
]

DETAIL_TEMPLATE = """<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{school} - {en}</title>
<style>
body{{font-family:-apple-system,'Segoe UI',Roboto,sans-serif;max-width:960px;margin:24px auto;padding:0 20px;color:#222;line-height:1.6}}
h1{{font-size:24px;border-bottom:2px solid #1a73e8;padding-bottom:8px}}
h2{{font-size:18px;color:#1a73e8;margin-top:24px}}
.card{{background:#f8f9fa;border-left:4px solid #1a73e8;padding:12px 16px;margin:12px 0;border-radius:4px}}
.meta{{display:grid;grid-template-columns:120px 1fr;gap:6px 12px;font-size:14px}}
.meta b{{color:#555}}
ul{{margin:6px 0;padding-left:20px}}
.note{{background:#fff3cd;border-left-color:#ffc107;padding:10px 14px;margin-top:16px;font-size:13px}}
a{{color:#1a73e8}}
</style>
</head>
<body>
<h1>{school} - {en}</h1>
<div class="card">
<div class="meta">
<b>Degree</b><span>{deg}</span>
<b>Level</b><span>Research Doctorate (PhD)</span>
<b>STEM</b><span>{stem_label}</span>
<b>Duration</b><span>{dur}</span>
<b>Deadline</b><span>{ddl}</span>
<b>Language</b><span>{lang}</span>
<b>Standardized</b><span>{test_cls}</span>
<b>Funding</b><span>{tui}</span>
</div>
</div>

<h2>Program Overview</h2>
<div class="card">
{overview}
</div>

<h2>Admissions Requirements</h2>
<div class="card">
{requirements}
</div>

<h2>Research Areas</h2>
<div class="card">
{research}
</div>

<h2>Official Source</h2>
<div class="card">
{source}
</div>

<div class="note">
<strong>Note:</strong> This is a research-oriented PhD in biological sciences / molecular &amp; cell biology at a top-30 U.S. university. Admitted PhD students receive full financial support (tuition + stipend + insurance). Admission statistics shown are distribution ranges, not minimum thresholds. Course/credit details pending department bulletin verification. All five programs are STEM-designated per NSF GRFP field of study (Life Sciences) / CIP codes.
</div>
</body>
</html>
"""

PAGES = {
    "uchicago-ceb-phd": {
        "school": "UChicago Committee on Evolutionary Biology",
        "en": "PhD in Evolutionary Biology (CEB)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5-6 years full-time residential; Autumn Quarter entry; ~25-30 PhD students; ~60 faculty across 4 divisions + external institutions",
        "ddl": "Autumn 2027: December 1, 2026. Faculty review Jan/Feb; interviews by invitation; April 15 reply.",
        "lang": "TOEFL iBT / IELTS Academic for non-native English; ETS 1832; English-medium undergraduate exempts.",
        "test_cls": "GRE OPTIONAL FOR ALL BSD PHD PROGRAMS (if submitted within 5 years, considered; subject tests optional). 3 LOR; holistic review. Apply to single cluster, up to 4 units.",
        "tui": "Full funding through UChicago BSD (tuition + stipend + insurance) via RA/TA; NSF GRFP encouraged.",
        "overview": "The Committee on Evolutionary Biology (CEB) at the University of Chicago is an interdisciplinary PhD program within the Division of the Biological Sciences. CEB is one of three programs in the Darwinian Sciences cluster (along with Ecology and Evolution, and Organismal Biology and Anatomy). CEB faculty come from all four UChicago graduate divisions (Biological Sciences, Physical Sciences, Social Sciences, Humanities) plus external institutions: Argonne National Laboratory, Brookfield Zoo, Chicago Botanic Garden, The Field Museum, Lincoln Park Zoo, and Morton Arboretum. The program typically enrolls 25-30 PhD students at a time and has produced over 100 graduates.",
        "requirements": "<ul><li>Bachelor's degree or equivalent</li><li>GRE OPTIONAL (BSD-wide policy; scores considered only if taken within 5 years of Dec 1, 2026)</li><li>TOEFL iBT / IELTS Academic (non-native English); ETS code 1832; English-medium undergraduate exempts</li><li>UChicago BSD online application</li><li>Statement of Purpose</li><li>3 letters of recommendation</li><li>Transcripts</li><li>CV/resume</li><li>December 1, 2026 deadline (all materials including LORs)</li><li>Autumn Quarter entry only; full-time</li><li>Apply to single cluster (Darwinian Sciences) and up to 4 units, ranked by preference</li></ul>",
        "research": "<ul><li>Behavior and neurobiology</li><li>Biomechanics and functional morphology</li><li>Conservation biology</li><li>Developmental biology and evo-devo</li><li>Ecology and population biology</li><li>Genetics and genomics</li><li>Paleobiology and systematics</li><li>Cross-disciplinary work with Argonne, Field Museum, Brookfield Zoo, Lincoln Park Zoo, and Morton Arboretum</li></ul>",
        "source": '<a href="https://evbio.uchicago.edu/page/admissions-info" target="_blank">UChicago CEB Admissions Info (Dec 1 deadline; Autumn start; TOEFL/IELTS required)</a> | <a href="https://biosciences.uchicago.edu/admissions/how-to-apply/faq" target="_blank">UChicago BSD FAQ (Dec 1, 2026; GRE optional for all PhD; ETS 1832; scores within 5 years)</a> | <a href="https://apply-bsd.uchicago.edu/apply/ndv/" target="_blank">UChicago BSD Application (Autumn 2027: Dec 1 for all PhD; Darwinian Sciences cluster: E&E, CEB, OBA)</a>',
    },
    "umich-mcdb-phd": {
        "school": "University of Michigan LSA Molecular, Cellular, and Developmental Biology",
        "en": "PhD in Molecular, Cellular, and Developmental Biology (MCDB)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5 to 5.5 years full-time residential; fall-only; fully supported in good standing; two core courses + rotations; thesis mentor by start of G2",
        "ddl": "Fall 2027: December 1, 2026 (opens September 2026). PhD fall-only; MS deadline March 1 (separate).",
        "lang": "TOEFL iBT for international non-English undergrad; ETS UMich 1839 dept 35; IELTS accepted.",
        "test_cls": "GRE NOT REQUIRED (MCDB: 'Note: we do NOT require the GRE.'). Expected background: biology, physics, organic chemistry, calculus, advanced biology. 3 LOR; Academic SOP + Personal Statement; CV.",
        "tui": "Full support through Rackham Graduate School and MCDB (tuition + stipend + insurance) for 5-5.5 years.",
        "overview": "The University of Michigan PhD in Molecular, Cellular, and Developmental Biology (MCDB) is offered through the College of Literature, Science, and the Arts (LSA). The program offers two application pathways: (1) direct admission to MCDB through Rackham, or (2) admission through the Program in Biomedical Sciences (PIBS) umbrella at the U-M Medical School. Students complete two core courses in first year (Molecular Biology fall, Cell Biology winter) plus research rotations. Degree completion time is 5 to 5.5 years. Students in good standing are fully supported until they finish.",
        "requirements": "<ul><li>Bachelor's degree or equivalent (prior master's not required)</li><li>Expected background: biology, physics, organic chemistry, calculus, advanced biology</li><li>GRE NOT required (no scores reviewed)</li><li>TOEFL iBT (international non-English undergrad); ETS code 1839, dept 35; IELTS accepted</li><li>Rackham Graduate School online application</li><li>Academic Statement of Purpose (background, career goals, prior research)</li><li>Personal Statement (experiences shaping career choice)</li><li>3 letters of recommendation</li><li>Transcripts from all post-secondary institutions</li><li>CV/resume</li><li>December 1, 2026 deadline</li><li>Fall term only; full-time</li><li>Pathway: direct MCDB or PIBS umbrella (choose at application)</li></ul>",
        "research": "<ul><li>Molecular biology and biochemistry</li><li>Cell biology and signal transduction</li><li>Developmental biology and stem cells</li><li>Neurobiology and behavior</li><li>Microbiology and immunology</li><li>Plant molecular biology</li><li>Genetics and genomics</li><li>16 research themes spanning MCDB</li></ul>",
        "source": '<a href="https://lsa.umich.edu/mcdb/prospective-students/phd-program/how-to-apply.html" target="_blank">UMich MCDB How to Apply (Dec 1; Rackham; GRE not required; 3 LOR; ETS 1839/35; SOP + Personal Statement)</a> | <a href="https://lsa.umich.edu/mcdb/prospective-students/phd-program.html" target="_blank">UMich MCDB PhD Overview (5-5.5 years; fully supported; fall-only; two core courses; rotations)</a> | <a href="https://rackham.umich.edu/programs-of-study/" target="_blank">UMich Rackham Programs of Study (MCDB PhD code 01726; Dec 1 PhD; March 1 MS)</a>',
    },
    "duke-mcb-phd": {
        "school": "Duke University Department of Pharmacology and Cancer Biology",
        "en": "PhD in Molecular Cancer Biology (MCB)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5-6 years full-time residential; fall-only; no part-time; 41 faculty / 34 students; interdisciplinary across Duke School of Medicine",
        "ddl": "Fall 2027: December 1, 2026, 11:59:59 PM EST. Interviews mid-Jan; on-site recruitment weekends February; decisions March.",
        "lang": "TOEFL iBT / IELTS Academic / Duolingo English Test; ETS Duke 5156; waiver available under some criteria.",
        "test_cls": "GRE GENERAL OPTIONAL (Duke: 'does not require GRE, but does allow upload if scores enhance application; self-reported scores require official verification'). 3 LOR; SOP; resume; undergrad GPA 4.0 scale.",
        "tui": "Full funding through Duke Graduate School and PCB (tuition + stipend + insurance) via RA/TA/fellowships.",
        "overview": "The Duke PhD in Molecular Cancer Biology (MCB) is offered through the Department of Pharmacology and Cancer Biology (PCB) at Duke School of Medicine. The program is designed to generate independent scholars who study the basic mechanisms underlying cell growth, differentiation, and development, and how these processes are perturbed in cancer cells, with the goal of identifying novel therapeutic targets. The MCB program consists of faculty from multiple departments and centers across Duke University and the School of Medicine. Approaches include genomics, genetics, cell biology, molecular biology, and protein biochemistry.",
        "requirements": "<ul><li>Bachelor's degree or equivalent</li><li>GRE General OPTIONAL (self-reported requires official verification if submitted)</li><li>TOEFL iBT / IELTS Academic / Duolingo English Test (non-native English); ETS 5156; waiver available</li><li>Duke Graduate School online application</li><li>Statement of Purpose</li><li>3 letters of recommendation</li><li>Resume/CV</li><li>Transcripts (unofficial at application; official upon admission)</li><li>Undergraduate GPA on 4.0 scale</li><li>December 1, 2026, 11:59:59 PM EST deadline</li><li>Fall term only; no part-time study</li></ul>",
        "research": "<ul><li>Cancer cell biology and signal transduction</li><li>Genomics and genetics of oncogenesis</li><li>Cell growth, differentiation, and development</li><li>Protein biochemistry and structural biology</li><li>Therapeutic discovery and targeted therapy</li><li>Tumor microenvironment and immunology</li><li>Cross-disciplinary work with Duke Cancer Institute, Duke Center for Genomic and Computational Biology, and Duke Institute for Brain Sciences</li></ul>",
        "source": '<a href="https://gradschool.duke.edu/academics/programs-degrees/molecular-cancer-biology/" target="_blank">Duke Graduate School: Molecular Cancer Biology (Dec 1; Fall-only; 41 faculty/34 students; GRE optional; TOEFL/IELTS/Duolingo)</a> | <a href="https://gradschool.duke.edu/admissions/application-deadlines/" target="_blank">Duke Application Deadlines (Fall 2027: MCB, MGM, Pathobiology all 12/01/2026 11:59pm EST)</a> | <a href="https://pcb.duke.edu/education-training/molecular-cancer-biology-phd-program" target="_blank">Duke PCB: MCB PhD Program (interdisciplinary across Duke; genomics/genetics/cell/molecular/biochemistry approaches)</a>',
    },
    "brown-mcbgp-phd": {
        "school": "Brown University MCB Graduate Program",
        "en": "PhD in Molecular Biology, Cell Biology, and Biochemistry (MCBGP)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "~5.5 years full-time residential; fall-only; interdisciplinary across 5 departments in Program in Biology; 3 short essays required",
        "ddl": "Fall 2027: December 1, 2026. Interviews February; decisions March; April 15 reply.",
        "lang": "TOEFL iBT for international students; Brown Graduate School language requirements; no additional MCBGP language requirement; waiver available.",
        "test_cls": "GRE NOT REQUIRED / NOT CONSIDERED (Brown MCBGP: 'does not require the GRE for admission and does not consider GRE scores in evaluating applications.' Both General and Subject. 3 short essays; 3 LOR (up to 5); transcript(s).",
        "tui": "Full support (stipend + tuition + health insurance) while research/academic progress satisfactory.",
        "overview": "The Brown PhD in Molecular Biology, Cell Biology, and Biochemistry (MCBGP) is an interdisciplinary, interdepartmental program within Brown's Program in Biology. MCBGP draws faculty from five departments: Ecology and Evolutionary Biology; Molecular Biology, Cell Biology and Biochemistry; Molecular Microbiology and Immunology; Molecular Pharmacology, Physiology and Biotechnology; and Neuroscience. The program's mission is to build an equitable and inclusive training environment where diverse PhD students gain quantitative, conceptual, technical, and professional skills for rigorous interdisciplinary life science research. Average time to degree is approximately 5.5 years.",
        "requirements": "<ul><li>Bachelor's degree or equivalent</li><li>GRE NOT required and NOT considered (both General and Subject)</li><li>TOEFL iBT (international students); Brown Graduate School language requirements; no additional MCBGP requirement</li><li>Brown Graduate School online application</li><li>3 short essays (program-specific prompts)</li><li>3 letters of recommendation (up to 5 accepted)</li><li>Transcript(s) from all institutions attended</li><li>December 1, 2026 deadline</li><li>Fall term only (no spring admission)</li><li>Full-time residential</li></ul>",
        "research": "<ul><li>Molecular biology and genomics</li><li>Cell biology and organ function</li><li>Biochemistry and structural biology</li><li>Developmental biology and stem cells</li><li>Molecular microbiology and immunology</li><li>Pharmacology, physiology, and biotechnology</li><li>Neuroscience (interdepartmental)</li><li>Disease mechanisms and biotechnology applications</li></ul>",
        "source": '<a href="https://graduateprograms.brown.edu/graduate-program/biomed-molecular-biology-cell-biology-and-biochemistry-phd" target="_blank">Brown Graduate Programs: BioMed MCBGP (Dec 1, 2026; GRE General & Subject not required)</a> | <a href="https://mcbgrad.brown.edu/prospective-students" target="_blank">Brown MCBGP Prospective Students (Dec 1, 2026; 3 short essays; 3 LOR; TOEFL; full support)</a> | <a href="https://mcbgrad.brown.edu/prospective-students/frequently-asked-questions" target="_blank">Brown MCBGP FAQ (GRE not required/not considered; 5.5 years; 3-5 LOR; no spring admission)</a>',
    },
    "col-biosci-phd": {
        "school": "Columbia University Department of Biological Sciences",
        "en": "PhD in Biological Sciences (GSAS, Morningside campus)",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Life Sciences / CIP 26.xx)",
        "dur": "5-6 years full-time residential; fall-only; full-time; must list 3+ potential faculty advisors; two open-house weekends in February",
        "ddl": "Fall 2027: December 2, 2026 (opens September 2026). Open House Feb 5-6 and Feb 26-27, 2027; April 15 reply.",
        "lang": "TOEFL iBT 100 (paper 600) or IELTS 7.5; ETS Columbia GSAS 2162; no dept code; English-medium undergraduate exempts.",
        "test_cls": "GRE NO LONGER REQUIRED (Columbia BioSci: 'No GREs are required for the Biological Sciences PhD program.') 3 LOR (at least 2 academic; up to 4); resume required; no writing sample; must list 3+ potential faculty advisors.",
        "tui": "Full funding (annually adjusted stipend + full tuition + health insurance + fees) through Columbia GSAS; discounted Morningside housing.",
        "overview": "The Columbia University PhD in Biological Sciences is offered through the Department of Biological Sciences in the Graduate School of Arts and Sciences (GSAS) on the Morningside campus. The program is a birthplace of model organism research, evolutionary genetics, and revolutionary advances in imaging. Students must list at least three potential faculty advisors on the GSAS application, along with their primary program subfield selection. All admitted students receive annually adjusted stipends, full tuition exemption, health insurance, fees, and access to discounted housing within walking distance of Morningside campus. Note: this is distinct from the Vagelos College of Physicians and Surgeons biomedical PhD programs (P&S).",
        "requirements": "<ul><li>Bachelor's degree or equivalent (natural/physical science background recommended)</li><li>Expected: calculus, organic and physical chemistry, physics, genetics, biochemistry, cell biology</li><li>GRE NOT required (no longer reviewed)</li><li>TOEFL iBT 100 (paper 600) or IELTS Academic 7.5; ETS code 2162; English-medium undergraduate exempts</li><li>Columbia GSAS online application</li><li>Statement of Purpose (must identify 3+ potential faculty advisors and primary subfield)</li><li>3 letters of recommendation (at least 2 academic; up to 4 accepted)</li><li>Resume/CV (required)</li><li>No writing sample required</li><li>Transcripts from all institutions attended</li><li>December 2, 2026 deadline</li><li>Fall entry only; full-time residential</li><li>Open House/Interviews February 5-6 and February 26-27, 2027</li></ul>",
        "research": "<ul><li>Molecular and cellular biology</li><li>Genetics, genomics, and developmental biology</li><li>Evolutionary biology and model organism research</li><li>Neurobiology and behavior</li><li>Biophysics and imaging</li><li>Computational and quantitative biology</li><li>Ecology and environmental biology</li><li>Cross-disciplinary work with Columbia Medical Center, Zuckerman Institute, and Earth Institute</li></ul>",
        "source": '<a href="https://biology.columbia.edu/content/apply-now" target="_blank">Columbia BioSci Apply Now (Dec 2, 2026; Open House Feb 5-6/26-27; must list 3 faculty advisors; no GRE; TOEFL 100/IELTS 7.5)</a> | <a href="https://biology.columbia.edu/content/phd-program-faq" target="_blank">Columbia BioSci PhD FAQ (Dec 2; ETS 2162; GRE no longer required; no dept code)</a> | <a href="https://www.gsas.columbia.edu/content/biological-sciences" target="_blank">Columbia GSAS: Biological Sciences (Dec 2, 2026; resume required; no writing sample; GRE General No; 3 LOR with at least 2 academic; up to 4 accepted)</a>',
    },
}

# Write detail pages
for p in PROGRAMS:
    key = p["id"]
    d = PAGES[key]
    html = DETAIL_TEMPLATE.format(
        school=d["school"], en=d["en"], deg=d["deg"], stem_label=d["stem_label"],
        dur=d["dur"], ddl=d["ddl"], lang=d["lang"], test_cls=d["test_cls"], tui=d["tui"],
        overview=d["overview"], requirements=d["requirements"],
        research=d["research"], source=d["source"],
    )
    path = os.path.join(DET, key + ".html")
    with open(path, "w", encoding="utf-8") as f:
        f.write(html)
    print(f"Wrote: {key}.html")

# Append PROGRAMS
idx_path = os.path.join(BASE, "index_main.html")
with open(idx_path, "r", encoding="utf-8") as f:
    html = f.read()

def build_entry(p):
    return ('{{id:"{id}",s:"{s}",n:"{n}",en:"{en}",deg:"{deg}",lvl:"{lvl}",stem:{stem},'
            'dur:"{dur}",ddl:"{ddl}",lang:"{lang}",test:{{cls:"{test_cls}"}},'
            'tui:"{tui}",url:"{url}"}}').format(
        id=p["id"], s=p["s"], n=p["n"], en=p["en"], deg=p["deg"], lvl=p["lvl"],
        stem=p["stem"], dur=p["dur"], ddl=p["ddl"], lang=p["lang"],
        test_cls=p["test"]["cls"].replace('"', "'"),
        tui=p["tui"].replace('"', "'"), url=p["url"],
    )

new_entries = ",\n".join(build_entry(p) for p in PROGRAMS)

m = re.search(r'const\s+PROGRAMS\s*=\s*\[', html)
start = m.end()
depth = 1
i = start
while i < len(html) and depth > 0:
    c = html[i]
    if c == '[': depth += 1
    elif c == ']': depth -= 1
    i += 1
insert_pos = i - 1
prefix = html[:insert_pos].rstrip()
suffix = html[insert_pos:]
if prefix.endswith('{'):
    new_block = prefix + "\n" + new_entries + "\n" + suffix
else:
    new_block = prefix + ",\n" + new_entries + "\n" + suffix

# Append VD on new_block (re-locate to avoid offset)
vd_entries = ",\n".join(f'"{p["url"]}"' for p in PROGRAMS)
m2 = re.search(r'VERIFIED_DETAILS\s*=\s*new\s+Set\s*\(\s*\[', new_block)
vstart = m2.end()
vdepth = 1
j = vstart
while j < len(new_block) and vdepth > 0:
    c = new_block[j]
    if c == '[': vdepth += 1
    elif c == ']': vdepth -= 1
    j += 1
vinsert_pos = j - 1
vprefix = new_block[:vinsert_pos].rstrip()
vsuffix = new_block[vinsert_pos:]
if vprefix.endswith(','):
    new_block = vprefix + "\n" + vd_entries + "\n" + vsuffix
elif vprefix.endswith('['):
    new_block = vprefix + "\n" + vd_entries + "\n" + vsuffix
else:
    new_block = vprefix + ",\n" + vd_entries + "\n" + vsuffix

with open(idx_path, "w", encoding="utf-8") as f:
    f.write(new_block)

print(f"Appended {len(PROGRAMS)} PROGRAMS entries and {len(PROGRAMS)} VD entries")
print(f"Done. File size: {os.path.getsize(idx_path)}")
