import openpyxl
from openpyxl.styles import Font, Alignment, PatternFill, Border, Side

wb = openpyxl.Workbook()
ws = wb.active
ws.title = "U23_L2_合"

for col, w in zip('ABCD', [12, 48, 12, 42]):
    ws.column_dimensions[col].width = w

hfont = Font(bold=True, size=11)
hfill = PatternFill(start_color="D9D9D9", end_color="D9D9D9", fill_type="solid")
align = Alignment(vertical="top", wrap_text=True)
halign = Alignment(horizontal="center", vertical="center", wrap_text=True)
b = Border(left=Side(style="thin"), right=Side(style="thin"), top=Side(style="thin"), bottom=Side(style="thin"))

for col, h in enumerate(["类型", "剧情描述", "角色名", "编剧台词"], 1):
    c = ws.cell(row=1, column=col, value=h)
    c.font = hfont; c.fill = hfill; c.alignment = halign; c.border = b

tl = PatternFill(start_color="E8F0FE", end_color="E8F0FE", fill_type="solid")
it = PatternFill(start_color="FFF2CC", end_color="FFF2CC", fill_type="solid")
ci = PatternFill(start_color="F4CCCC", end_color="F4CCCC", fill_type="solid")

rows = [
    ["TL","【场景】会场 — 评审桌前\n【角色】User、May、Sam、Jack、Kalab、Tom、Smith、Fiona","",""],
    ["","接转段结尾：众人回到评审桌前。Kalab、Sam 都就位。Tom 的座位空着","",""],
    ["","","Smith","Where is Tom?"],
    ["","Fiona 往厕所方向望了一眼","",""],
    ["","","Fiona","He went to the toilet."],
    ["","","Fiona","He was not feeling well."],
    ["","Smith 站起来","",""],
    ["","","Smith","I will bring him back."],
    ["","【转场】Smith 扶着满脸通红的 Tom 走回来。全场安静","",""],
    ["","Tom 坐下，揉着脸","",""],
    ["","","Tom","I am fine. Let's do this."],
    ["中互动","","User","What fruit does he like? Pineapple or Kiwi?"],
    ["","【emoji】Tom😰","",""],
    ["","Tom 张嘴想说什么——又闭上。Smith 清了清嗓子","",""],
    ["","","Smith","Let's just try the fruit."],
    ["TL","Sam 把 Pineapple 端上评审桌。果肉金黄，香气四溢","",""],
    ["","","Fiona","Wow. It looks good!"],
    ["","","Smith","Let's try."],
    ["","Fiona 尝了一片，眼睛亮了。Smith 尝了一片，满意地点头","",""],
    ["","轮到 Tom。所有人看着他。Tom 盯着面前的 Pineapple，手没动","",""],
    ["","Tom 拿起一片——送到鼻子前——闻了一下——放回盘子。没吃","",""],
    ["","【emoji】May😟 Jack🤔","",""],
    ["","Tom 突然站起来","",""],
    ["","","Tom","Sam wins."],
    ["","","Tom","His pineapple is the best."],
    ["","【emoji】Sam😲 May🎉 Kalab😐","",""],
    ["","","May","You won, Sam!"],
    ["","","Sam","I... I did it?"],
    ["中互动","","User","Sam's pineapple is the winner!"],
    ["TL","欢呼声中，Tom 悄悄从椅子上起身——往厕所方向溜去","",""],
    ["","May 转头，座位又空了","",""],
    ["","","May","Tom went to the toilet again?"],
    ["","","Jack","He did not even try the pineapple."],
    ["","","Jack","Was the game fair?"],
    ["","User 和 Sam 也在想同样的事","",""],
    ["","【emoji】User🤨 May🤨","",""],
    ["","这时 Fiona 走过来，表情温和","",""],
    ["","","Fiona","Kids. I want to tell you something."],
    ["","","Fiona","Tom is not okay."],
    ["核心互动-听力选择","第1题 — 【插入图】三张选项图（图A: apple + banana / 图B: kiwi + pineapple / 图C: grapes + watermelon），正确答案：图B","",""],
    ["","","May","Why is his face so red?"],
    ["","","Fiona","He ate some fruit."],
    ["","","Fiona","His face turns red from kiwi or pineapple."],
    ["","第2题 — 【插入图】三张选项图（图A: 笑脸Tom / 图B: 脸红眼肿的Tom / 图C: 睡觉的Tom），正确答案：图B","",""],
    ["","","May","What happens to him?"],
    ["","","Fiona","His face turns red."],
    ["","","Fiona","His eyes get puffy too."],
    ["","第3题 — 【插入图】三张选项图（图A: Tom很饿 / 图B: Tom很累 / 图C: Tom对食物过敏），正确答案：图C","",""],
    ["","","May","So he cannot eat kiwi or pineapple?"],
    ["","","Fiona","Yes. That is a food allergy."],
    ["","","Fiona","Some fruit can make people sick."],
    ["TL","Fiona 微笑，拍拍 User 和 May","",""],
    ["","","Fiona","You got it."],
    ["","","Fiona","Look after Tom for me, okay?"],
    ["","Fiona 转身离开","",""],
    ["","May 看着 User，眼神里全是问号","",""],
    ["","","May","Wait. That is strange."],
    ["","","May","Jack said Tom loves pineapple..."],
    ["","","May","Jack said Tom loves kiwi too."],
    ["","","May","Why does he love them?"],
    ["","","May","They can make him sick!"],
    ["","⚡收束钩子：User 看着 Tom 消失的方向。一个对 Kiwi 和 Pineapple 过敏的人，为什么全镇都以为他爱吃这两种水果？","",""],
]

for i, row in enumerate(rows, 2):
    for col, val in enumerate(row, 1):
        c = ws.cell(row=i, column=col, value=val)
        c.alignment = align; c.border = b
        t = row[0]
        if t == "TL": c.fill = tl
        elif t == "中互动": c.fill = it
        elif t.startswith("核心互动"): c.fill = ci

ws.freeze_panes = "A2"
wb.save("/root/.openclaw/workspace-xiaobian/output/U23_L2_合_剧本V1.xlsx")
print("OK")
