# -*- coding: utf-8 -*-
"""第九十四轮：Yale 5 个硕士项目详情页重写 + PROGRAMS/VD 追加"""
import os, re

BASE = r"D:\work buddy\2026-11-05-14-15-52"
DET = os.path.join(BASE, "details")

CSS = """
:root{--navy1:#0b2447;--navy2:#19376d;--navy3:#2b5ba8;--gold:#f0a500;--bg:#f5f7fa;--card:#fff;--line:#e3e8f0;--text:#1f2937;--muted:#6b7280;--green:#1e8449;--blue:#2563eb}
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:"PingFang SC","Microsoft YaHei","Segoe UI",sans-serif;background:var(--bg);color:var(--text);font-size:14px}
a{color:var(--blue)}
.hero{background:linear-gradient(135deg,var(--navy1) 0%,var(--navy2) 55%,var(--navy3) 100%);color:#fff;padding:24px 30px 20px}
.hero h1{font-size:21px}
.hero .en{font-size:13px;opacity:.85;margin-top:4px}
.hero .school{margin-top:8px;font-size:14px;font-weight:600;color:#ffd77a}
.badges{margin-top:12px;display:flex;gap:8px;flex-wrap:wrap}
.badge{font-size:12px;border-radius:5px;padding:3px 10px;font-weight:700;background:rgba(240,165,0,.25);color:#ffe1a1}
.wrap{max-width:900px;margin:20px auto 60px;padding:0 16px}
.card{background:var(--card);border-radius:12px;box-shadow:0 2px 10px rgba(15,35,80,.08);border:1px solid var(--line);padding:20px 24px;margin-bottom:16px}
.card h2{font-size:16px;color:var(--navy2);border-left:4px solid var(--gold);padding-left:10px;margin-bottom:14px}
.pdesc{font-size:13px;line-height:1.95;color:#263244}
.links a{display:inline-block;margin:4px 8px 4px 0;padding:8px 14px;background:var(--navy2);color:#fff;border-radius:8px;font-size:13px;text-decoration:none;font-weight:600}
.links a:hover{background:var(--navy3)}
.note{font-size:12px;color:var(--muted);margin-top:10px;line-height:1.7}
.yellow{background:#fff8e1;border-left:4px solid var(--gold);border-radius:8px;padding:12px 16px;font-size:12px;line-height:1.8;margin-top:10px}
.back{display:inline-block;margin-bottom:14px;color:var(--navy2);text-decoration:none;font-size:13px;font-weight:600}
table{width:100%;border-collapse:collapse;font-size:13px;margin-top:6px}
th,td{border:1px solid var(--line);padding:7px 10px;text-align:left}
th{background:#f0f4fa;color:var(--navy2);font-weight:600}
"""

def page(title, en, school, badges, req_html, fee_html, curr_html, train_html, city_html, links, note_extra=""):
    badge_html = "".join(f'<span class="badge">{b}</span>' for b in badges)
    links_html = "".join(f'<a href="{u}" target="_blank">{t}</a>' for t,u in links)
    return f"""<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{title} · {school} · 项目详情 | 美加硕士项目查询系统</title>
<style>{CSS}</style>
</head>
<body>
<div class="hero">
  <h1>{title}</h1>
  <div class="en">{en}</div>
  <div class="school">{school}</div>
  <div class="badges">{badge_html}</div>
</div>
<div class="wrap">
  <a class="back" href="../index_main.html">← 返回项目库首页</a>

  <div class="card">
    <h2>申请要求</h2>
    <div class="pdesc">{req_html}</div>
  </div>

  <div class="card">
    <h2>费用与奖学金</h2>
    <div class="pdesc">{fee_html}</div>
  </div>

  <div class="card">
    <h2>课程设置</h2>
    <div class="pdesc">{curr_html}</div>
  </div>

  <div class="card">
    <h2>培养方案</h2>
    <div class="pdesc">{train_html}</div>
  </div>

  <div class="card">
    <h2>院校与城市速览</h2>
    <div class="pdesc">{city_html}</div>
  </div>

  <div class="card">
    <h2>官方链接</h2>
    <div class="links">{links_html}</div>
    <div class="note">数据来源：耶鲁大学研究生院（GSAS）及各系官网，核验时间 2026-11-22。{note_extra}</div>
  </div>
</div>
</body>
</html>"""

# ============ 1. Yale CBB MS ============
p1 = page(
    title="计算生物学与生物医学信息理学硕士",
    en="M.S. in Computational Biology and Biomedical Informatics (CBB MS)",
    school="耶鲁大学 · Yale University",
    badges=["STEM","全日制两年","New Haven","跨学科"],
    req_html="""
    <table>
      <tr><th>项目</th><th>要求</th></tr>
      <tr><td>截止日期</td><td>12月1日 23:59 ET（秋季入学，仅秋季）</td></tr>
      <tr><td>学位背景</td><td>本科及以上；接受 CS、数据科学、统计、数学、生物、物理化学、工程、信息学、健康相关等跨学科背景</td></tr>
      <tr><td>GPA/先修</td><td>无硬性先修课要求；需具备扎实的量化与计算基础；BBS 通用建议完成生物、化学（含有机化学）、物理、微积分</td></tr>
      <tr><td>GRE</td><td><b>不接受</b>（Not Accepted，提交也不审核）</td></tr>
      <tr><td>托福/雅思</td><td>TOEFL iBT ≥100；IELTS Academic ≥7.0（口语 ≤7.5 需参加 8 月英语课程）；本科英语授课满 3 年可豁免；机构代码 3987</td></tr>
      <tr><td>推荐信</td><td>3 封</td></tr>
      <tr><td>其他材料</td><td>个人陈述（500–1000 词）、简历、成绩单</td></tr>
    </table>
    """,
    fee_html="""
    <p>硕士项目<b>通常不提供奖学金</b>，学生基本自费。可通过 Yale Student Grants Database、校内兼职（RA/TA，数量极少且不保证）、校外贷款与外部 Fellowship 资助。PhD 路径全奖（12 个月 stipend + 学费 + 医保），但 MS 为终端专业型学位，不自动转 PhD。</p>
    <div class="yellow">💡 项目为全日制两年制在校项目，位于 New Haven，无 part-time / online 选项。</div>
    """,
    curr_html="""
    <p>跨学科项目，由生物医学信息与数据科学学部（Section of Biomedical Informatics and Data Science）主办，融合基因组学、蛋白质组学、生物建模、数据库与数据挖掘、算法开发、高性能计算、统计与数学分析。学生需在第一年末确定研究导师，第二年完成研究论文序列。</p>
    """,
    train_html="""
    <p>终端 MS 学位，两年制。毕业后两条路径：① 生物医学信息/计算生物行业就业（药厂、生物科技公司、医院信息科）；② 申请 CBB PhD（有 MS-to-PhD 通道，完成至少两学期后可申请，录取不自动）。</p>
    """,
    city_html="""
    <p>耶鲁大学位于美国康涅狄格州 New Haven，距纽约市约 90 分钟火车。校园为常春藤盟校哥特式建筑风格，研究资源密集，毗邻 Yale New Haven Hospital 与系统生物学研究所。</p>
    """,
    links=[
        ("GSAS 项目页", "https://gsas.yale.edu/programs-of-study/computational-biology-biomedical-informatics-ms-program"),
        ("CBB 系站", "https://cbb.yale.edu/masters-program/frequently-asked-qquestions"),
        ("申请日期", "https://gsas.yale.edu/admissions/phdmasters-application-process/dates-deadlines"),
    ],
    note_extra="GRE 政策为 2026-2027 申请周期最新口径。"
)
with open(os.path.join(DET, "yale-computational-biology-biomedical-informatics.html"), "w", encoding="utf-8") as f:
    f.write(p1)
print("✅ 1/5 yale-computational-biology-biomedical-informatics.html")

# ============ 2. Yale Stats DS MS ============
p2 = page(
    title="统计与数据科学理学硕士",
    en="M.S. in Statistics and Data Science (Terminal MS)",
    school="耶鲁大学 · Yale University",
    badges=["STEM","3学期","New Haven","自费为主"],
    req_html="""
    <table>
      <tr><th>项目</th><th>要求</th></tr>
      <tr><td>截止日期</td><td>12月1日 23:59 ET（秋季入学）</td></tr>
      <tr><td>学位背景</td><td>本科；量化背景（数学、统计、CS、经济、工程等）优先</td></tr>
      <tr><td>课程要求</td><td>12 门研究生课程；3 个全日制学期 residence</td></tr>
      <tr><td>GRE</td><td><b>Optional</b>（可提交，不强制；数学 Subject Test 也 optional）</td></tr>
      <tr><td>托福/雅思</td><td>TOEFL iBT / IELTS Academic；本科英语授课满 3 年可豁免；机构代码 3987</td></tr>
      <tr><td>推荐信</td><td>3 封</td></tr>
      <tr><td>录取规模</td><td>每年约 1000 申请、约 40 人录取，每届 15–20 人</td></tr>
    </table>
    """,
    fee_html="""
    <p>Terminal MA/MS 项目学生<b>几乎全部自费</b>（个人资金或外部 Fellowship）。少量 RA/TA 机会存在但不保证，仅覆盖部分费用。PhD 项目全奖（12 个月 stipend + 学费 + 医保），但 terminal MS 不自动升入 PhD，需重新申请。</p>
    """,
    curr_html="""
    <p>研究方向覆盖：统计理论（贝叶斯、决策论、非参数）、概率论（随机过程、渐近、弱收敛）、信息论、生物信息与遗传学、分类、数据挖掘与机器学习、神经网络、网络科学、优化、统计计算、图模型与方法。核心课程含 S&DS 5000（统计导论）、S&DS 5001（Data Science @Yale）、S&DS 5230（YData）等。</p>
    """,
    train_html="""
    <p>终端 MS 学位，3 个学期（约 1–1.5 年）完成。毕业后就业方向：数据科学家、量化分析师、生物统计师、机器学习工程师；也可申请 PhD（需重新提交完整申请，不自动衔接）。</p>
    """,
    city_html="""
    <p>耶鲁大学 New Haven 校区，统计与数据科学系位于 24 Hillhouse Avenue，紧邻文理研究生院。</p>
    """,
    links=[
        ("GSAS 项目页", "https://gsas.yale.edu/programs-of-study/statistics-data-science"),
        ("系站录取", "https://statistics.yale.edu/graduates/terminal-mams-programs/terminal-mams-admissions"),
        ("Catalog 学位要求", "https://catalog.yale.edu/gsas/degree-granting-departments-programs/statistics/"),
    ],
)
with open(os.path.join(DET, "yale-statistics-data-science.html"), "w", encoding="utf-8") as f:
    f.write(p2)
print("✅ 2/5 yale-statistics-data-science.html")

# ============ 3. Yale ECE MS ============
p3 = page(
    title="电气与计算机工程理学硕士",
    en="M.S. in Electrical & Computer Engineering",
    school="耶鲁大学 · Yale University",
    badges=["STEM","仅秋季","New Haven","工程"],
    req_html="""
    <table>
      <tr><th>项目</th><th>要求</th></tr>
      <tr><td>截止日期</td><td>12月15日 23:59 ET（仅秋季入学，无春季）</td></tr>
      <tr><td>学位背景</td><td>B.S. 工程或相关领域（物理、化学、CS、数学、材料）</td></tr>
      <tr><td>GRE</td><td><b>Optional</b></td></tr>
      <tr><td>托福/雅思</td><td>TOEFL iBT / IELTS Academic；本科英语授课满 3 年可豁免；机构代码 3987</td></tr>
      <tr><td>推荐信</td><td>3 封</td></tr>
    </table>
    """,
    fee_html="""
    <p>工程硕士项目通常不提供奖学金，学生自费。PhD 项目全奖（stipend + 学费 + 医保）。MS 为终端或 en route 学位，可继续 PhD。</p>
    """,
    curr_html="""
    <p>三大研究方向：① 计算机工程（计算机体系结构、硬件安全、神经形态计算、VLSI 设计）；② 电子、光子与纳米器件（生物传感系统、微纳机械/纳米机械系统、纳米电子、光电材料与器件、半导体、量子与非线性光子学、量子材料与工程）；③ 系统（通信与信号处理、神经网络、控制、无线网络、传感器网络）。</p>
    """,
    train_html="""
    <p>终端 MS 或 PhD 中途学位。MS 毕业后可就业于半导体、通信、芯片设计、硬件安全行业，或继续 PhD。</p>
    """,
    city_html="""
    <p>耶鲁工程与应用科学学院（SEAS），位于 New Haven 校区。</p>
    """,
    links=[
        ("GSAS 项目页", "https://gsas.yale.edu/programs-of-study/electrical-computer-engineering"),
        ("SEAS 系站", "https://seas.yale.edu/departments/electrical-engineering"),
        ("SEAS 申请", "https://engineering.yale.edu/apply"),
    ],
)
with open(os.path.join(DET, "yale-electrical-computer-engineering.html"), "w", encoding="utf-8") as f:
    f.write(p3)
print("✅ 3/5 yale-electrical-computer-engineering.html")

# ============ 4. Yale CS MS ============
p4 = page(
    title="计算机科学理学硕士",
    en="M.S. in Computer Science",
    school="耶鲁大学 · Yale University",
    badges=["STEM","1年8课","New Haven","GRE required"],
    req_html="""
    <table>
      <tr><th>项目</th><th>要求</th></tr>
      <tr><td>截止日期</td><td>1月2日 23:59 ET（秋季入学；PhD 截止 12月15日）</td></tr>
      <tr><td>学位背景</td><td>B.S. 或相关背景</td></tr>
      <tr><td>课程要求</td><td>1 年 8 门 approved 课程</td></tr>
      <tr><td>GRE</td><td><b>MS Required / PhD Not Accepted</b>（MS 必须提交，PhD 不接受）</td></tr>
      <tr><td>托福/雅思</td><td>TOEFL iBT / IELTS Academic；本科英语授课满 3 年可豁免；机构代码 3987</td></tr>
      <tr><td>推荐信</td><td>3 封</td></tr>
    </table>
    """,
    fee_html="""
    <p>CS MS 项目通常自费。PhD 项目全奖。MS 为终端学位，毕业后可就业或申请其他 PhD。</p>
    """,
    curr_html="""
    <p>研究方向：算法与计算复杂度、人工智能、数据网络、数据库、图形、机器学习、编程语言、机器人、科学计算、安全与隐私、系统。1 年制 8 门研究生课程，课程可跨系选修。</p>
    """,
    train_html="""
    <p>1 年硕士项目，毕业后就业方向：软件工程师、ML 工程师、研究工程师；也可申请 PhD。</p>
    """,
    city_html="""
    <p>耶鲁计算机科学系，位于 New Haven 校区。</p>
    """,
    links=[
        ("GSAS 项目页", "https://gsas.yale.edu/programs-of-study/computer-science"),
        ("Graduate Handbook", "https://engineering.yale.edu/application/files/8517/5554/2639/CS_Graduate_Handbook__25_26__Draft_.pdf"),
    ],
    note_extra="MS 截止日期晚于 PhD（1月2日 vs 12月15日），申请时需注意区分。"
)
with open(os.path.join(DET, "yale-computer-science.html"), "w", encoding="utf-8") as f:
    f.write(p4)
print("✅ 4/5 yale-computer-science.html")

# ============ 5. Yale BME MS ============
p5 = page(
    title="生物医学工程理学硕士",
    en="M.S. in Biomedical Engineering",
    school="耶鲁大学 · Yale University",
    badges=["STEM","仅秋季","New Haven","GRE required"],
    req_html="""
    <table>
      <tr><th>项目</th><th>要求</th></tr>
      <tr><td>截止日期</td><td>12月15日 23:59 ET（仅秋季入学，无春季）</td></tr>
      <tr><td>学位背景</td><td>B.S. 工程或相关领域（物理、化学、CS、数学、材料）</td></tr>
      <tr><td>GRE</td><td><b>MS Required / PhD Optional</b>（MS 必须提交，PhD 可选）</td></tr>
      <tr><td>托福/雅思</td><td>TOEFL iBT / IELTS Academic；本科英语授课满 3 年可豁免；机构代码 3987</td></tr>
      <tr><td>推荐信</td><td>3 封</td></tr>
    </table>
    """,
    fee_html="""
    <p>BME MS 项目通常自费。PhD 项目全奖（stipend + 学费 + 医保）。</p>
    """,
    curr_html="""
    <p>研究方向覆盖：生物与医疗器械、生物信号与传感器、生物材料、生物光子学、细胞生物力学、计算生物力学、计算医学、计算机视觉、数字图像处理、药物递送、能量代谢、实验生物力学、基因递送、基因治疗、图像分析、MRI/MRS、机械生物建模、分子生物力学、纳米医学、网络分析、神经受体、成像物理（MRI/光学/超声/核医学/X-ray）、生理与人因工程、PET、再生医学、信号通路、SPECT、系统生物学、系统医学、组织工程、示踪动力学建模、血管生物学。</p>
    """,
    train_html="""
    <p>终端 MS 或 PhD 中途学位。毕业后就业方向：医疗器械研发、医学影像、生物科技、制药、健康科技；也可继续 PhD。</p>
    """,
    city_html="""
    <p>耶鲁生物医学工程系，跨 SEAS 与 Yale School of Medicine，临床资源毗邻 Yale New Haven Hospital。</p>
    """,
    links=[
        ("GSAS 项目页", "https://gsas.yale.edu/programs-of-study/biomedical-engineering"),
        ("SEAS 申请", "https://engineering.yale.edu/apply"),
    ],
)
with open(os.path.join(DET, "yale-biomedical-engineering.html"), "w", encoding="utf-8") as f:
    f.write(p5)
print("✅ 5/5 yale-biomedical-engineering.html")
print("\n=== 5 个详情页全部写入完成 ===")
