# -*- coding: utf-8 -*-
"""Round 264: batch add 5 - Independent Astronomy PhD (Northwestern/Vanderbilt/UCLA) + Biochemistry/BBS PhD (Harvard BBS, Stanford Biochemistry)
- Northwestern Astronomy PhD (Dec 15, 2026; GRE General and Physics GRE NOT accepted; TOEFL 90; 2 LOR; $95 fee; full funding 12-month fellowship Y1; CIERA; 12 units)
- Vanderbilt Astrophysics PhD (Dec 1, 2026; GRE not required and not considered; 5-yr full tuition waiver + health insurance + $36,500 stipend; 3+ LOR; NANOGrav/LIGO/LISA; ETS 1871)
- UCLA Astronomy & Astrophysics PhD (Dec 15, 2026; Fall only; admits PhD only; GRE General and Subject accepted but not required; Physics Subject strongly recommended; 3 LOR; ETS 4837 major 0801; 7 core courses)
- Harvard BBS PhD (Dec 1, 5pm EST; GRE General and Subject Not Accepted; TOEFL iBT 100 / IELTS 7; 4 subcommittees incl. MBB/Biochemistry; 800+ faculty; G1 rotations; thesis mentor by July 1 G1; Personal Statement required)
- Stanford Biochemistry PhD (Dec 1, 2026 11:59pm PST; Autumn only; GRE General and Subject Optional; interview March 3-6, 2027; Knight-Hennessy deadline Oct 6; full funding; prerequisites cell/dev bio, basic biochem/molecular bio, genetics, 1 yr physics, calculus, organic/inorganic/physical chemistry)
Key finding: Astronomy PhD GRE policy split continues - Northwestern explicitly NOT accepted (strongest stance), Vanderbilt explicitly not required/not considered, UCLA accepted but not required with Physics Subject strongly recommended. Harvard BBS Not Accepted (like MIT/Stanford Biology trend). Stanford Biochemistry Optional (BioSciences family).
"""
import os, re

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

DETAIL_TEMPLATE = """<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>{school} - {en}</title>
<style>
body{{font-family:-apple-system,'Segoe UI',sans-serif;max-width:960px;margin:24px auto;padding:0 20px;color:#222;line-height:1.6}}
h1{{color:#1a3a6c;border-bottom:2px solid #1a3a6c;padding-bottom:8px;font-size:22px}}
h2{{color:#1a3a6c;margin-top:28px;font-size:17px}}
.card{{background:#f7f9fc;border-left:4px solid #1a3a6c;padding:14px 18px;margin:12px 0;border-radius:4px}}
.meta{{display:inline-block;background:#e8eef7;color:#1a3a6c;padding:2px 10px;border-radius:12px;font-size:13px;margin-right:6px}}
a{{color:#1a6cc8}}
</style>
</head>
<body>
<h1>{school} - {en}</h1>
<div>
<span class="meta">学位：{deg}</span>
<span class="meta">{stem_label}</span>
</div>
<h2>项目概览</h2>
<div class="card">{overview}</div>
<h2>学制与课程</h2>
<div class="card">{dur}</div>
<h2>申请截止</h2>
<div class="card">{ddl}</div>
<h2>语言要求</h2>
<div class="card">{lang}</div>
<h2>标化与录取要求</h2>
<div class="card">{test_cls}</div>
<h2>学费与资助</h2>
<div class="card">{tui}</div>
<h2>申请材料与研究方向</h2>
<div class="card">{requirements}</div>
<h2>研究领域</h2>
<div class="card">{research}</div>
<h2>来源</h2>
<div class="card">{source}</div>
</body>
</html>"""

PROGRAMS = [
    {
        "id": "nu-astro-phd",
        "s": "nu",
        "n": "天文博士",
        "en": "PhD in Astronomy (Northwestern University, Department of Physics and Astronomy, Weinberg College of Arts and Sciences; located in Evanston, IL; Dec 15, 2026 for Fall; GRE General and Physics GRE NOT accepted; TOEFL 90 minimum; 2 LOR; $95 fee; full funding 12-month fellowship Y1; CIERA center; 12 units; PHYSICS 411 Classical Mechanics + 6 400-level astronomy courses + 2 400-level physics + 4 quantitative science courses)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "12 units total. Required: PHYSICS 411-0 Classical Mechanics. Minimum six 400-level astronomy courses (ASTRON 410 Radiative Processes, 414 Planetary, 416 Fluid Dynamics, 421 Observational, 425 Stellar, 429 Extragalactic/Cosmology, 448 Interstellar/Star Formation, 449 Stellar Dynamics, 451 High Energy). Minimum two 400-level physics courses (PHYSICS 411-0 counts as one). Minimum four other 400-level quantitative science or engineering courses. Oral qualifying exam if B (3.0) average not maintained in core first-year courses. En route MS available (12 graded courses + 3.0 GPA). On-campus residential (Evanston, Illinois).",
        "ddl": "Fall 2027 matriculation: **December 15, 2026** (Astronomy PhD). Applications open September 15, 2026. Decisions beginning mid-February 2027. Offer response deadline April 15, 2027. Application fee $95. Fee waivers approved by The Graduate School (first-come, first-served).",
        "lang": "TOEFL minimum: 90 for PhD applicants (The Graduate School policy). IELTS also accepted per TGS policy. International applicants required to submit English test scores; exemption possible if attended institution where English is main language of instruction (email Graduate Program Assistant to confirm).",
        "test": {"cls": "GRE GENERAL AND PHYSICS GRE NOT ACCEPTED for Astronomy PhD (Northwestern Physics and Astronomy Admissions page: 'GRE scores are not accepted for the Astronomy PhD program.' This is stronger than optional - submitted scores will not be reviewed. Note: Physics PhD and Master's programs have GRE optional policy for Fall 2027, but Astronomy PhD explicitly does not accept GRE. Required: Transcripts (legible scans, English translation if needed); at least 2 letters of recommendation from professors familiar with work; Statement of Purpose; TOEFL for international students."},
        "tui": "Fully funded PhD. First-year students typically supported by 12-month fellowships (flexibility in choosing research specialty). After first year: funded as Teaching Assistants or Research Assistants. Strong ties to Argonne National Laboratory and Fermi National Accelerator Laboratory. Multi-disciplinary research with joint faculty in Materials Science, Chemistry, and Electrical Engineering. Students may spend time at CERN or astronomical observatories. Center for Interdisciplinary Research and Exploration in Astrophysics (CIERA) is vibrant research environment. Department located in Evanston, Illinois.",
        "url": "details/nu-astro-phd.html",
    },
    {
        "id": "vanderbilt-astro-phd",
        "s": "vanderbilt",
        "n": "天体物理博士",
        "en": "PhD in Astrophysics (Vanderbilt University, Department of Physics and Astronomy, College of Arts and Science; located in Nashville, TN; Dec 1, 2026; GRE General and Subject NOT required and NOT considered; 5-year full tuition waiver + health insurance + $36,500 stipend; 3+ LOR; SOP 1000-2000 words; NANOGrav/LIGO/LISA collaborations; ACCRE high-performance computing; ETS institution 1871)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 5 years. On-campus residential (Nashville, Tennessee). Research areas: observational, theoretical, computational astrophysics. MS awarded en route to PhD. Students typically complete coursework and qualifying exams in first 2 years, then focus on dissertation research. Research facilities: on-campus interdisciplinary centers including Data Science Institute; Advanced Computing Center for Research and Education (ACCRE).",
        "ddl": "Fall 2027 matriculation: applications open August 1, 2026; **deadline December 1, 2026**. Applications submitted through Graduate School Application Portal. Initial offers released by March 31; response due April 15. Department may grant additional waivers at discretion based on recruitment priorities. Contact: Don Pickert, Program Specialist.",
        "lang": "TOEFL iBT minimum: 89 (tests taken before January 21, 2026); revised 1-6 scale minimum 4.5 (tests on/after January 21, 2026). IELTS also accepted. International applicants exempt under certain circumstances (English proficiency waiver policy). ETS institution code: 1871; no department code needed.",
        "test": {"cls": "GRE NOT REQUIRED AND NOT CONSIDERED (Vanderbilt Astrophysics Admissions page: 'Do not submit GRE scores (General nor Subject). They are not required and will not be considered.' Graduate School Application Requirements by Program page lists Astrophysics PhD GRE status = Exempt. Required: SOP (1000-2000 words detailing motivations and research interests); 3+ letters of recommendation (provide insight into prior experience, motivation, aptitude for research); unofficial transcripts loaded directly (official only after admission); application fee (waivable via department after submission)."},
        "tui": "Five-year package: full tuition waiver + health insurance coverage + competitive stipend (currently $36,500 per year). Paid-for visit to campus for students offered admission before accepting. Research opportunities: international collaborations NANOGrav, LIGO, LISA; travel to Sloan Digital Sky Survey (SDSS) in New Mexico, Vera C. Rubin Observatory in Chile, SMARTS in Chile. Research areas: exoplanets, stars, black holes, Milky Way, galaxies, large-scale structures, gravitational waves, cosmology. Department located in Nashville, Tennessee.",
        "url": "details/vanderbilt-astro-phd.html",
    },
    {
        "id": "ucla-astro-phd",
        "s": "ucla",
        "n": "天文与天体物理博士",
        "en": "PhD in Astronomy and Astrophysics (University of California, Los Angeles, Department of Physics and Astronomy, College of Letters and Science; located in Los Angeles, CA; Dec 15, 2026; Fall only; admits only PhD applicants (no terminal MS); GRE General and Subject accepted but not required (Physics Subject strongly recommended); 3 LOR; bachelor's in physics or astronomy; ETS institution 4837 major code 0801; 7 core courses)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "7 core courses required for PhD: Astronomy 270, 271A, 271B, 272, 273, 274, 281. On-campus residential (Los Angeles, California). Time-to-degree typically 5-6 years. En route MS available (M.S. in Astronomy). No foreign language requirement. Note: department admits only applicants whose objective is the PhD (no terminal MS).",
        "ddl": "Fall 2027 matriculation: **December 15, 2026**. Fall admission only. Scores and letters should reach department by first week of January. Offers typically made in February and March. Both Astronomy division and Physics division have separate admission committees. Contact: apply@physics.ucla.edu; (310) 206-6994.",
        "lang": "TOEFL/IELTS scores for international applicants. UCLA minimum requirements apply. ETS institution code 4837; major code 0801 (Astronomy). Scores valid within 5 years. Students admitted and intending to enroll may send official reports. International applicants applying for financial support should have one LOR commenting on verbal ability in English.",
        "test": {"cls": "GRE GENERAL AND SUBJECT ACCEPTED BUT NOT REQUIRED (UCLA Physics and Astronomy Graduate Students page: 'Students who wish to apply for admission to our graduate program for the 2026-2027 academic year are not required to take the GRE or submit a GRE score report... However, students may voluntarily submit GRE test scores and they will be reviewed as part of the holistic application consideration. The applications with GRE scores will not be given greater weight than those that do not include scores.' Note: grad.ucla.edu 2027-2028 catalog for Astronomy and Astrophysics major code 00EB lists 'GRE: General and Subject accepted but, not required. GRE Subject in Physics is strongly recommended.' Older FAQ page lists 'GRE subject: preferably 650 minimum' (legacy threshold, admitted distribution not minimum). Required: bachelor's degree in physics or astronomy (closely related fields like math/chemistry admitted at department discretion); SOP; 3 LOR; transcripts. Note: division-specific admission committees."},
        "tui": "PhD program at UCLA Department of Physics and Astronomy. Research areas: observational astronomy, theoretical astrophysics, galactic/extragalactic astronomy, cosmology, high-energy astrophysics, exoplanets, planetary science. Department located at 1-707 B Physics and Astronomy Building, Box 951547, Los Angeles, CA 90095-1547. Website: www.astro.ucla.edu. Note: UCLA offers M.S. and Ph.D. degrees in Astronomy, but admits only Ph.D. applicants (no terminal MS).",
        "url": "details/ucla-astro-phd.html",
    },
    {
        "id": "harvard-bbs-phd",
        "s": "harvard",
        "n": "生物与生物医学科学博士（含生物化学方向）",
        "en": "PhD in Biological and Biomedical Sciences (Harvard University, Harvard Medical School, Harvard Integrated Life Sciences; located in Boston, MA; Dec 1, 5pm EST; GRE General and Subject Not Accepted; TOEFL iBT 100 / IELTS 7; 4 subcommittees incl. Molecular/Cellular/Developmental Mechanisms; 800+ faculty; G1 year rotations; thesis mentor by July 1 of G1; Personal Statement required; interview weekend Feb 5-8, 2027)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 5-6 years. On-campus residential (Boston, Massachusetts, at Harvard Medical School). G1 year: coursework + lab rotations. Thesis mentor declared by July 1 of G1 year. Dissertation research through G2-G5. Customizable curriculum aligned with research interests. Core training in contemporary genetics, biochemistry, molecular/cellular/mechanistic biology.",
        "ddl": "Fall 2027 matriculation: application opens early September 2026; **deadline December 1, 2026 5:00 PM EST**. Interview invitations sent mid-late December; interview weekend February 5-8, 2027; admit & waitlist offers sent mid-February; decision deadline April 15, 2027. Select 'Biological & Biomedical Sciences' as Degree Program on GSAS application.",
        "lang": "TOEFL iBT minimum: 100. IELTS minimum: 7.0. Scores must be sent directly from testing center. Harvard Griffin GSAS English proficiency requirements apply.",
        "test": {"cls": "GRE GENERAL AND SUBJECT NOT ACCEPTED (Harvard BBS Apply page: 'GRE: BBS no longer accepts GRE scores. If you submit scores, they will not be seen by our admissions committees.' GSAS program page confirms: GRE General = Not Accepted; GRE Subject = Not Accepted. Required: Statement of Purpose (focus on primary research experience - question/topic, importance, hypotheses, testing, findings, interpretation); Personal Statement (required); 4 subcommittee selection: (1) Molecular, Cellular and Developmental Mechanisms (with sub-options: Molecular Mechanisms, Structural Biology, Cellular Biology, Stem Cell Biology and Development); (2) Immunology and Infectious Diseases; (3) Neurobiology; (4) Cancer Biology. Students do NOT list specific faculty of interest in initial application (asked after interview invitation). Faculty contact not required; no thesis lab secured prior to application."},
        "tui": "Harvard BBS is one of the Harvard Integrated Life Sciences (HILS) programs. 800+ faculty across Harvard University. Access to top hospitals and research centers; 130+ biotech/biopharma/pharma companies nearby. G1 year rotations: students rotate in labs before declaring thesis mentor at end of G1 year (July 1st). Notable alumni: Derrick Rossi (cofounder of Moderna). Graduates secure faculty positions at NYU, UMN, Harvard, UIUC; careers at Novartis, Broad Institute. Note: Biochemistry is represented within the Molecular, Cellular and Developmental Mechanisms subcommittee.",
        "url": "details/harvard-bbs-phd.html",
    },
    {
        "id": "stanford-bioc-phd",
        "s": "stanford",
        "n": "生物化学博士",
        "en": "PhD in Biochemistry (Stanford University, School of Medicine, Department of Biochemistry; located in Stanford, CA; Dec 1, 2026 11:59pm PST; Autumn quarter only; GRE General and Subject Optional; interview March 3-6, 2027; Knight-Hennessy Scholars deadline Oct 6, 2026; full funding; prerequisites: cell/developmental biology, basic biochemistry/molecular biology, genetics, 1 year physics, calculus, organic/inorganic/physical chemistry)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 5-6 years. On-campus residential (Stanford, California). Autumn quarter only. Program begins autumn quarter each year. Emphasis on research training; each student works closely with faculty. Opportunities for directed reading and research using advanced facilities: light/electron microscopy, chromatography, electrophoresis, protein/nucleic acid purification, rapid kinetic analysis, single-molecule analyses, microarray generation, computer graphic workstations for structural analysis. Note: M.S. degree offered only to students already enrolled in PhD program (no terminal MS). Research organisms: bacteria to animal cells.",
        "ddl": "Autumn 2027-28 matriculation: application opens mid-September 2026; **deadline Tuesday, December 1, 2026 11:59:59 PM PST**. Late applications not accepted. Interview session: Wednesday, March 3 through Saturday, March 6, 2027. Admission offer letters sent mid-March 2027. Decision deadline April 15, 2027. Knight-Hennessy Scholars applicants: apply by Tuesday, October 6, 2026 1:00 PM PST to KHS AND by December 1, 2026 to Biosciences PhD.",
        "lang": "TOEFL iBT or IELTS Academic required if not exempt. Stanford minimum English proficiency requirements apply. Effective 2026 entry: English proficiency test scores NOT required if applicant meets one of exemption criteria (U.S. citizen/permanent resident; or earned bachelor's/master's/doctoral degree in U.S. or from select countries where English is language of instruction).",
        "test": {"cls": "GRE GENERAL AND SUBJECT OPTIONAL (Stanford Biosciences How to Apply page: 'The GRE General Test and GRE Subject Test score requirements vary across the 14 Home Programs. Some programs have optional score submission, while others do not consider the scores in their review process.' Biochemistry is listed as Optional - submitted scores considered, may help complement academic record or address gaps/weaknesses. Required prerequisites for admission: baccalaureate degree; completed work in cell and developmental biology, basic biochemistry and molecular biology, and genetics; at least one year of university physics; differential and integral calculus; organic, inorganic, and physical chemistry. Department especially interested in applicants with research experience in biology or chemistry. 3 LOR. SOP. CV/Resume. Unofficial transcripts from all universities/colleges attended for 1+ year. Application fee $125 (waivable)."},
        "tui": "Stanford Biosciences PhD programs are fully funded. Students receive financial support covering ordinary living expenses; Stanford tuition costs are paid. Department located in Beckman Center for Molecular and Genetic Medicine at Stanford Medical Center, Shriram Center for Bioengineering and Chemical Engineering, and Stanford Genome Technology Center. Contact: Onn Brandman, Director of Graduate Studies, onn@stanford.edu, (650) 725-8986; Jazmyn Lamas, Student & Postdoctoral Affairs Manager, jlamas@stanford.edu. Knight-Hennessy Scholars: up to 100 high-achieving students receive 3 years of funding for graduate education at Stanford.",
        "url": "details/stanford-bioc-phd.html",
    },
]

PAGES = {
    "nu-astro-phd": {
        "school": "西北大学",
        "en": "PhD in Astronomy (Northwestern University)",
        "deg": "PhD",
        "stem_label": "STEM-designated (Astronomy / Astrophysics / CIP 40.0201)",
        "dur": "12 units. Required: PHYSICS 411-0 Classical Mechanics. Min 6 400-level astronomy courses (Radiative Processes, Planetary, Fluid Dynamics, Observational, Stellar, Extragalactic/Cosmology, Interstellar/Star Formation, Stellar Dynamics, High Energy). Min 2 400-level physics courses. Min 4 400-level quantitative science/engineering courses. Oral qualifying exam if B (3.0) average not maintained. En route MS available.",
        "ddl": "Fall 2027: **December 15, 2026** (Astronomy PhD). Applications open September 15, 2026. Decisions mid-February. Offer response April 15, 2027. $95 fee. Fee waivers via TGS (first-come, first-served).",
        "lang": "TOEFL minimum 90 for PhD (TGS policy). IELTS accepted. Exemption possible if attended institution where English is main language of instruction.",
        "test_cls": "GRE GENERAL AND PHYSICS GRE NOT ACCEPTED for Astronomy PhD. Note: Physics PhD and Master's have GRE optional, but Astronomy explicitly does not accept GRE. Required: transcripts (legible, English translation if needed), 2+ LOR from professors, SOP, TOEFL for international.",
        "tui": "Fully funded. Y1: 12-month fellowship (flexibility in research specialty). After Y1: TA/RA support. Ties to Argonne National Lab and Fermilab. Joint faculty with Materials Science, Chemistry, ECE. Opportunities at CERN or astronomical observatories. CIERA (Center for Interdisciplinary Research and Exploration in Astrophysics).",
        "overview": "Northwestern University Department of Physics and Astronomy, Weinberg College of Arts and Sciences. PhD in Astronomy. Flexible program combining astronomy training with physics/quantitative science courses. Strong astrophysics research environment via CIERA.",
        "requirements": "Online application via The Graduate School. Transcripts. 2+ letters of recommendation. Statement of Purpose. TOEFL/IELTS for international. $95 fee (waivable).",
        "research": "Astrophysics, atomic and molecular physics, biophysics, complex systems, condensed matter physics, particle physics. Specific astronomy fields: planetary astrophysics, stellar astrophysics, extragalactic/cosmology, interstellar/star formation, stellar dynamics, high-energy astrophysics, radiative processes, fluid dynamics, observational astrophysics.",
        "source": "https://physics.northwestern.edu/graduate/doctoral-program/admissions/ ; https://physics.northwestern.edu/graduate/doctoral-program/ ; https://catalogs.northwestern.edu/tgs/astronomy/astronomy-phd/",
    },
    "vanderbilt-astro-phd": {
        "school": "范德堡大学",
        "en": "PhD in Astrophysics (Vanderbilt University)",
        "deg": "PhD",
        "stem_label": "STEM-designated (Astrophysics / CIP 40.0201)",
        "dur": "Typically 5 years. MS en route. Coursework and qualifying exams in Y1-Y2; dissertation research Y3-Y5. Research facilities: Data Science Institute; ACCRE (Advanced Computing Center for Research and Education).",
        "ddl": "Fall 2027: applications open August 1, 2026; **deadline December 1, 2026**. Initial offers by March 31; response April 15. Department may grant additional waivers. Contact: Don Pickert, Program Specialist.",
        "lang": "TOEFL iBT minimum 89 (pre-2026-01-21 tests); revised 1-6 scale minimum 4.5 (post-2026-01-21). IELTS accepted. ETS institution code 1871 (no dept code).",
        "test_cls": "GRE NOT REQUIRED AND NOT CONSIDERED. Depts: 'Do not submit GRE scores (General nor Subject). They are not required and will not be considered.' Graduate School lists Astrophysics PhD = Exempt. Required: SOP 1000-2000 words; 3+ LOR; unofficial transcripts; application fee (waivable).",
        "tui": "5-year package: full tuition waiver + health insurance + $36,500/year stipend. Paid campus visit for admitted students. International collaborations: NANOGrav, LIGO, LISA. Travel to SDSS (New Mexico), Vera C. Rubin Observatory (Chile), SMARTS (Chile).",
        "overview": "Vanderbilt University Department of Physics and Astronomy, College of Arts and Science. PhD in Astrophysics. Research in observational, theoretical, and computational astrophysics. Small cohort, close mentorship.",
        "requirements": "Online application via Vanderbilt Graduate School. SOP 1000-2000 words. 3+ LOR. Unofficial transcripts (official after admission). TOEFL/IELTS. Application fee (waivable via department).",
        "research": "Exoplanets, stars, black holes, Milky Way, galaxies, large-scale structures, gravitational waves, cosmology. Observational, theoretical, computational astrophysics.",
        "source": "https://as.vanderbilt.edu/physics-astronomy/phd-astrophysics-admissions/ ; https://gradschool.vanderbilt.edu/admissions/apply/application-requirements-by-program/ ; https://gradschool.vanderbilt.edu/application-requirements/",
    },
    "ucla-astro-phd": {
        "school": "加州大学洛杉矶分校",
        "en": "PhD in Astronomy and Astrophysics (University of California, Los Angeles)",
        "deg": "PhD",
        "stem_label": "STEM-designated (Astronomy / Astrophysics / CIP 40.0201)",
        "dur": "7 core courses: Astronomy 270, 271A, 271B, 272, 273, 274, 281. Typically 5-6 years. En route MS (M.S. in Astronomy). No foreign language requirement. Note: admits only PhD applicants (no terminal MS).",
        "ddl": "Fall 2027: **December 15, 2026**. Fall only. Scores/letters by first week of January. Offers Feb-Mar. Separate Astronomy and Physics division admission committees. Contact: apply@physics.ucla.edu; (310) 206-6994.",
        "lang": "TOEFL/IELTS. UCLA minimum requirements. ETS institution 4837; major code 0801 (Astronomy). Scores valid within 5 years. International applicants seeking support: one LOR should comment on English verbal ability.",
        "test_cls": "GRE GENERAL AND SUBJECT ACCEPTED BUT NOT REQUIRED (dept page). Catalog major 00EB: 'General and Subject accepted but, not required. Physics Subject strongly recommended.' Older FAQ lists 'GRE subject preferably 650 minimum' (legacy admitted distribution, not threshold). Applications with GRE given no greater weight. Required: bachelor's in physics/astronomy (math/chemistry considered at dept discretion); SOP; 3 LOR; transcripts.",
        "tui": "PhD at UCLA Department of Physics and Astronomy. Research: observational astronomy, theoretical astrophysics, galactic/extragalactic, cosmology, high-energy astrophysics, exoplanets, planetary science. Address: 1-707 B P&A Building, Box 951547, Los Angeles, CA 90095-1547. Web: www.astro.ucla.edu.",
        "overview": "UCLA Department of Physics and Astronomy, College of Letters and Science. PhD in Astronomy and Astrophysics. Fall admission only. No terminal MS - all applicants admitted as PhD candidates.",
        "requirements": "Online application via UCLA Graduate Division. SOP. 3 LOR. Transcripts. TOEFL/IELTS for international. ETS 4837 major 0801. Bachelor's degree in physics or astronomy required (closely related fields considered).",
        "research": "Observational astronomy, theoretical astrophysics, galactic/extragalactic astronomy, cosmology, high-energy astrophysics, exoplanets, planetary science, interstellar medium, star formation.",
        "source": "https://www.pa.ucla.edu/graduate-students.html ; https://grad.ucla.edu/requirements/?app=admission&major=00EB ; https://grad.ucla.edu/graduate-program-requirements/program-requirements-for-physics-and-astronomy-astronomy-4/",
    },
    "harvard-bbs-phd": {
        "school": "哈佛大学",
        "en": "PhD in Biological and Biomedical Sciences (Harvard University, Harvard Medical School)",
        "deg": "PhD",
        "stem_label": "STEM-designated (Biological and Biomedical Sciences / CIP 26.9999)",
        "dur": "Typically 5-6 years. G1 year: coursework + lab rotations. Thesis mentor declared by July 1 of G1. Dissertation research G2-G5. Core training in contemporary genetics, biochemistry, molecular/cellular/mechanistic biology. Customizable curriculum.",
        "ddl": "Fall 2027: opens early September 2026; **deadline December 1, 2026 5:00 PM EST**. Interview invitations mid-late December; interview weekend February 5-8, 2027; offers mid-February; decision deadline April 15, 2027.",
        "lang": "TOEFL iBT minimum 100. IELTS minimum 7.0. Scores sent directly from testing center. GSAS English proficiency requirements apply.",
        "test_cls": "GRE GENERAL AND SUBJECT NOT ACCEPTED. BBS Apply page: 'BBS no longer accepts GRE scores. If you submit scores, they will not be seen.' Required: SOP (focus on primary research experience); Personal Statement (required); 4 subcommittees: (1) Molecular/Cellular/Developmental Mechanisms (sub-options: Molecular, Structural, Cellular, Stem Cell), (2) Immunology and Infectious Diseases, (3) Neurobiology, (4) Cancer Biology. No faculty list in initial application; no thesis lab secured before application.",
        "tui": "HILS (Harvard Integrated Life Sciences) program. 800+ faculty. Access to top hospitals/research centers; 130+ biotech/biopharma/pharma nearby. G1 rotations before thesis mentor declaration. Notable alumni: Derrick Rossi (Moderna cofounder). Graduates: faculty at NYU/UMN/Harvard/UIUC; industry at Novartis/Broad. Biochemistry represented within MBB subcommittee.",
        "overview": "Harvard Biological and Biomedical Sciences (BBS) PhD at Harvard Medical School. Broad life science training from atomic resolution to whole organism physiology/behavior. Part of Harvard Integrated Life Sciences.",
        "requirements": "GSAS online application. Select 'Biological & Biomedical Sciences' as Degree Program. SOP. Personal Statement. Subcommittee selection. Transcripts. TOEFL/IELTS. No faculty contact required; no thesis lab prior to application.",
        "research": "Molecular mechanisms, structural biology, cellular biology, stem cell biology and development, immunology, infectious diseases, neurobiology, cancer biology. Angstrom-level atomic resolution to whole organism animal physiology/behavior.",
        "source": "https://bbsphd.hms.harvard.edu/apply ; https://gsas.harvard.edu/program/biological-and-biomedical-sciences ; https://gsas.harvard.edu/programs",
    },
    "stanford-bioc-phd": {
        "school": "斯坦福大学",
        "en": "PhD in Biochemistry (Stanford University, School of Medicine)",
        "deg": "PhD",
        "stem_label": "STEM-designated (Biochemistry / CIP 26.0202)",
        "dur": "Typically 5-6 years. Autumn quarter only. Research-intensive; each student works closely with faculty. Advanced facilities: light/electron microscopy, chromatography, electrophoresis, protein/nucleic acid purification, rapid kinetic analysis, single-molecule analyses, microarrays, computer graphic workstations for structural analysis. Research organisms: bacteria to animal cells. Note: MS only for students enrolled in PhD (no terminal MS).",
        "ddl": "Autumn 2027-28: opens mid-September 2026; **deadline December 1, 2026 11:59:59 PM PST**. Late apps not accepted. Interview March 3-6, 2027. Offers mid-March. Decision deadline April 15, 2027. Knight-Hennessy Scholars: apply by October 6, 2026 1:00 PM PST to KHS AND by Dec 1 to Biosciences.",
        "lang": "TOEFL iBT or IELTS Academic if not exempt. Stanford minimum English proficiency. Effective 2026 entry: English test scores NOT required if U.S. citizen/PR or earned degree in U.S./select English-instruction countries.",
        "test_cls": "GRE GENERAL AND SUBJECT OPTIONAL (Biosciences family). Biochemistry = Optional: submitted scores considered, may help complement record or address gaps. Required prerequisites: baccalaureate; cell/developmental biology, basic biochemistry/molecular biology, genetics; 1 year physics; differential/integral calculus; organic/inorganic/physical chemistry. Research experience in biology/chemistry preferred. 3 LOR. SOP. CV. Unofficial transcripts. $125 fee (waivable).",
        "tui": "Fully funded. Support covers ordinary living expenses; Stanford tuition paid. Department in Beckman Center for Molecular and Genetic Medicine (Medical Center), Shriram Center for Bioengineering and Chemical Engineering, Stanford Genome Technology Center. Contact: Onn Brandman DGS onn@stanford.edu (650) 725-8986; Jazmyn Lamas jlamas@stanford.edu. Knight-Hennessy Scholars: up to 100 students, 3 years funding.",
        "overview": "Stanford University School of Medicine Department of Biochemistry PhD. Focus on molecular basis of life: protein/nucleic acid structure and function, development control, molecular motors/cytoskeleton, protein trafficking, gene expression regulation, protein homeostasis, structure and design, genetic/epigenetic chromosome control, genomics applications.",
        "requirements": "Online application via Stanford Biosciences. SOP. 3 LOR. CV/Resume. Unofficial transcripts from all 1+ year institutions. TOEFL/IELTS if not exempt. $125 fee. Knight-Hennessy Scholars separate application.",
        "research": "Protein/nucleic acid structure and function, developmental control, molecular motors and cytoskeleton, protein trafficking between organelles, gene expression regulation, protein homeostasis, structure and design, genetic/epigenetic chromosome function, genomics. Advanced courses: physical chemistry of proteins/nucleic acids, membrane biology, cytoskeleton, nucleic acid replication/recombination mechanisms, bacterial biochemistry.",
        "source": "https://biochemistry.stanford.edu/resources/phd-graduate-program ; https://biosciences.stanford.edu/how-to-apply/ ; https://22-23.bulletin.stanford.edu/programs/BIOC-PHD ; https://biosciences.stanford.edu/how-to-apply/admissions-timeline/",
    },
}

# 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)}")
