/* 報告 —— 新聞報導式長捲：報頭、入場照片、影片連結，一段段左圖右文 */
:root {
  --ink: #15171c; --text: #1d2026; --dim: #8b909b; --line: #e6e8ec;
  --paper: #fff; --bg: #f3f4f6; --fresh: #e5484d;
  --serif: "Noto Serif TC", Georgia, "Times New Roman", serif;
  --sans: "Noto Sans TC", -apple-system, "PingFang TC", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; } /* 修：class 的 display 會蓋過 hidden 屬性，強制讓 hidden 永遠生效 */
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); -webkit-font-smoothing: antialiased; }

.loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--dim); background: var(--bg); z-index: 50; }
.loading.hide { display: none; }

.paper { max-width: 1000px; margin: 0 auto; background: var(--paper); min-height: 100vh; padding: 0 clamp(18px, 5vw, 64px) 120px; box-shadow: 0 0 60px rgba(20,24,33,.06); }

/* 報頭 */
.masthead { padding: 26px 0 22px; border-bottom: 3px double var(--ink); margin-bottom: 34px; }
.mast-top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.kicker { font-size: 12px; letter-spacing: .26em; font-weight: 700; color: var(--dim); }
.mast-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.tool { border: 1px solid var(--line); background: var(--paper); color: var(--text); border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.tool:hover { border-color: #c7ccd4; background: var(--bg); }
.headline { font-family: var(--serif); font-weight: 900; font-size: clamp(30px, 5vw, 52px); line-height: 1.12; letter-spacing: -.01em; margin: 0 0 14px; color: var(--ink); }
.byline { font-size: 14px; color: var(--dim); }

/* 區塊小標：刊物式分節 —— 置中襯線、兩側細線，不像編輯標籤 */
.sec-h { font-family: var(--serif); font-weight: 700; font-size: 14px; letter-spacing: .22em; color: var(--dim); margin: 0 0 22px; display: flex; align-items: center; gap: 18px; text-align: center; }
.sec-h::before, .sec-h::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* 入場照片 */
.intro { margin-bottom: 42px; }
/* 結尾花絮：和段落列拉開距離，避免壓到最後的「在這裡新增段落」插入鈕 */
.intro.outro { margin-top: 64px; }
/* 瀑布流拼貼：每張依自己的長寬比呈現、不裁切，自然錯落 */
.intro-grid { columns: 3 240px; column-gap: 10px; }
.intro-grid figure { margin: 0 0 10px; position: relative; break-inside: avoid; border-radius: 10px; overflow: hidden; background: #0d1119; }
.intro-grid img, .intro-grid video { width: 100%; height: auto; display: block; }
.intro-grid .rm { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; display: none; font-size: 13px; }
body.editable .intro-grid figure:hover .rm { display: block; }
.add-intro { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; cursor: pointer; color: var(--dim); font-size: 13px; font-weight: 600; border: 1px dashed var(--line); border-radius: 8px; padding: 9px 14px; }
.add-intro:hover { border-color: #c7ccd4; color: var(--text); }

/* 活動影片：嵌入播放器（16:9） */
.videolink { margin-bottom: 46px; }
.vlink-player { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; margin-bottom: 10px; }
.vlink-player video, .vlink-player iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border: 0; display: block; }
.vlink { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; color: var(--ink); text-decoration: none; border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; }
.vlink:hover { border-color: #c7ccd4; background: var(--bg); }
.vlink::before { content: "▶"; color: var(--fresh); font-size: 13px; }
.vlink-edit { display: flex; gap: 8px; margin-top: 10px; }
.vlink-edit input { flex: 1; height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.vlink-edit input:focus { outline: none; border-color: var(--ink); }
.vlink-edit button { padding: 0 18px; border: 1px solid var(--ink); background: var(--ink); color: #fff; border-radius: 8px; font-weight: 600; cursor: pointer; }

/* 段落：媒體在上（依張數自動排版）、逐字稿在下 —— 像新聞報導 */
.stories { display: flex; flex-direction: column; gap: 64px; }
.story { transition: opacity .35s; }
.figwrap { position: relative; margin-bottom: 18px; }

/* 版面：side = 左圖右文、side-rev = 右圖左文、wide = 滿版大圖＋置中文字 */
.story.side, .story.side-rev { display: grid; grid-template-columns: 1.1fr 1fr; gap: 30px; align-items: start; }
.story.side .figwrap, .story.side-rev .figwrap { margin-bottom: 0; }
.story.side .story-tools, .story.side-rev .story-tools { grid-column: 1 / -1; }
.story.side-rev { grid-template-columns: 1fr 1.1fr; }
.story.side-rev .figwrap { order: 2; }
.story.side-rev .prose { order: 1; }
.story.wide .prose { max-width: 800px; }
/* 版面：text-top = 文字在前、圖片/影片在後 */
.story.text-top { display: flex; flex-direction: column; }
.story.text-top .story-tools { order: 0; }
.story.text-top .prose { order: 1; margin-bottom: 18px; }
.story.text-top .figwrap { order: 2; margin-bottom: 0; }

/* 段落工具列（編輯時）：上移/下移/版面 */
.story-tools { display: flex; gap: 8px; margin-bottom: 10px; }
.stool { border: 1px solid var(--line); background: var(--paper); color: var(--text); border-radius: 7px; padding: 5px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.stool:hover { border-color: #c7ccd4; background: var(--bg); }
.stool.del:hover { border-color: var(--fresh); color: var(--fresh); }

/* 版面下拉（圖示＋名稱） */
.lay-pick { position: relative; padding: 0 !important; border: 0 !important; background: transparent !important; }
.lay-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--paper); color: var(--text); border-radius: 7px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
.lay-btn:hover { border-color: #c7ccd4; background: var(--bg); }
.lay-btn b { color: var(--dim); font-weight: 400; }
.lay-menu { top: 32px; left: 0; min-width: 172px; }
.lay-opt.on { background: var(--bg); }
.ly { width: 24px; height: 15px; flex: 0 0 auto; }
.ly rect { fill: #15171c; }
.ly rect.t { fill: #aab2bf; }

/* 合併後的「＋ 加圖片/影片/連結」選單 */
.media-add { position: relative; display: inline-block; }
.madd-menu { top: 44px; left: 0; min-width: 182px; }
.madd-btn b { color: var(--dim); }

@media (max-width: 720px) { .story.side { grid-template-columns: 1fr; gap: 14px; } }

.gallery { display: grid; gap: 10px; }
.gallery[data-n="0"], .gallery[data-n="1"] { grid-template-columns: 1fr; }
.gallery[data-n="2"] { grid-template-columns: 1fr 1fr; }
.gallery[data-n="3"] { grid-template-columns: 1fr 1fr 1fr; }
.gallery[data-n="4"] { grid-template-columns: 1fr 1fr; }
.gallery[data-n="many"] { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.cell { margin: 0; position: relative; background: #0d1119; border-radius: 12px; overflow: hidden; transition: box-shadow .3s; }
.cell:has(img) { background: transparent; }                       /* 圖片用自己的長寬比，滿版不留黑邊 */
.cell:has(video), .cell:has(iframe), .cell.ph-cell { aspect-ratio: 16 / 9; }
.cell img { width: 100%; height: auto; display: block; }
.cell video, .cell iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; border: 0; }
.cell.ph-cell { background: #f6f7f9; border: 1px dashed #d4d8df; }
.cell .ph { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #aab0bb; font-size: 13px; }
/* 每格的「⋯」選單（替換 / 移除 合併成一顆） */
.cell-tools { position: absolute; top: 8px; right: 8px; z-index: 3; display: none; }
body.editable .cell:hover .cell-tools { display: block; }
.cell-menu-btn { border: 0; border-radius: 7px; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 16px; font-weight: 700; line-height: 1; padding: 3px 9px 6px; }
.cell-menu-btn:hover { background: rgba(0,0,0,.82); }
.cell-menu { top: 34px; right: 0; }
.cell-menu .cell-rm { color: var(--fresh); }

/* 彈出選單共用 */
.pop { display: none; position: absolute; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(20,24,33,.18); padding: 5px; min-width: 150px; }
.pop.on { display: block; }
.pop button, .pop label { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; border: 0; background: transparent; border-radius: 7px; padding: 9px 11px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; }
.pop button:hover, .pop label:hover { background: var(--bg); }
.share-menu { top: 42px; right: 0; min-width: 230px; }
/* 多語簡報生成進度（非阻塞，左下角） */
.gen-pill { position: fixed; left: 18px; bottom: 18px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 22px; font-size: 13px; font-weight: 600; box-shadow: 0 8px 24px rgba(20,24,33,.3); z-index: 45; }
.story.on .cell { box-shadow: 0 0 0 2px var(--ink); }

.fig-tools { display: none; gap: 8px; margin-top: 10px; }
body.editable .fig-tools { display: flex; flex-wrap: wrap; }
.ftool { display: inline-flex; align-items: center; gap: 5px; background: var(--paper); color: var(--text); border: 1px dashed var(--line); border-radius: 8px; padding: 9px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.ftool:hover { border-color: #c7ccd4; color: var(--ink); }

.prose { }
.transcript { font-size: 18px; line-height: 1.95; color: #2a2e37; margin: 0; white-space: pre-wrap; }
.transcript .nocap { color: var(--dim); font-style: italic; }
/* 統一文字框（整段一個框，編輯時才有邊框與 placeholder） */
.note-edit { min-height: 2.6em; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; transition: background .15s, border-color .15s; }
.note-edit:hover { background: #fffdf3; border-color: #d8c98a; cursor: text; }
.note-edit:focus { outline: none; border-color: var(--ink); background: #fff; }
.note-edit:empty::before { content: attr(data-ph); color: #aab0bb; }

/* 段落之間的插入鈕：細線＋置中「＋」，落在 64px 間距裡 */
.insert-section { display: flex; align-items: center; justify-content: center; width: 100%; margin: -24px 0; padding: 0; border: 0; background: transparent; color: var(--dim); font-size: 12px; font-weight: 600; cursor: pointer; opacity: .35; transition: opacity .15s, color .15s; }
.insert-section::before, .insert-section::after { content: ""; flex: 1; height: 1px; background: var(--line); margin: 0 12px; }
.insert-section:hover { opacity: 1; color: var(--ink); }

.add-section { display: block; width: 100%; margin-top: 40px; padding: 16px; border: 1px dashed var(--line); border-radius: 12px; background: var(--paper); color: var(--dim); font-size: 14px; font-weight: 600; cursor: pointer; }
.add-section:hover { border-color: #c7ccd4; color: var(--ink); background: var(--bg); }

.colophon { margin-top: 72px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--dim); font-size: 13px; text-align: center; }

/* 懸浮控制列：語言切換＋播放，固定右下，切語言不用捲到最上面 */
.dock { position: fixed; right: 20px; bottom: 20px; display: flex; align-items: center; gap: 10px; z-index: 40; }
.dock .dd-btn { background: var(--paper); box-shadow: 0 6px 20px rgba(20,24,33,.22); border-radius: 24px; height: 48px; padding: 0 16px; border-color: transparent; }
.dock .dd-btn:hover { background: var(--bg); }
.fab { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; cursor: pointer; display: grid; place-items: center; box-shadow: 0 8px 24px rgba(20,24,33,.3); }
.fab svg { width: 24px; height: 24px; }
/* 上傳進度動畫 */
.upload-overlay { position: fixed; inset: 0; background: rgba(15,17,22,.5); display: none; align-items: center; justify-content: center; z-index: 60; backdrop-filter: blur(2px); }
.upload-overlay.on { display: flex; }
.upload-card { background: #fff; border-radius: 16px; padding: 26px 32px; display: flex; flex-direction: column; align-items: center; gap: 14px; min-width: 240px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.upload-spin { width: 40px; height: 40px; border: 3px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: upspin .8s linear infinite; }
@keyframes upspin { to { transform: rotate(360deg); } }
.upload-pct { font-size: 15px; font-weight: 700; color: var(--ink); }
.upload-bar { width: 100%; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.upload-bar i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 3px; transition: width .2s; }

/* 來賓密碼頁 —— 吃背景圖(/lock-bg.jpg)，有就用、沒有就漸層；手機電腦都置中 */
.lock-screen {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background-color: #0b1733;
  background-image: linear-gradient(rgba(7,11,24,.55), rgba(7,11,24,.7)), url('/lock-bg.jpg');
  background-size: cover; background-position: center;
  z-index: 100; padding: 24px;
}
.lock-card {
  position: relative; background: rgba(255,255,255,.96); backdrop-filter: blur(6px);
  border-radius: 20px; padding: 40px 32px; width: 100%; max-width: 380px; text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.lock-icon { width: 58px; height: 58px; margin: 0 auto 18px; border-radius: 50%; background: linear-gradient(135deg, #1a2850, #0b1733); display: grid; place-items: center; color: #e9c87a; }
.lock-title { font-family: var(--serif); font-weight: 900; font-size: 24px; color: var(--ink); margin-bottom: 8px; line-height: 1.2; }
.lock-sub { font-size: 14px; color: var(--dim); margin-bottom: 24px; }
.lock-card input { width: 100%; height: 50px; border: 1px solid var(--line); border-radius: 11px; padding: 0 14px; font-size: 16px; text-align: center; margin-bottom: 12px; background: #fff; }
.lock-card input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(21,23,28,.08); }
.lock-card button { width: 100%; height: 50px; border: 0; border-radius: 11px; background: linear-gradient(135deg, #1a2850, #0b1733); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; letter-spacing: .04em; }
.lock-card button:hover { filter: brightness(1.15); }
.lock-err { color: var(--fresh); font-size: 13px; margin-top: 12px; min-height: 18px; }
@media (max-width: 480px) { .lock-card { padding: 34px 24px; border-radius: 18px; } .lock-title { font-size: 21px; } }

/* 分享設定面板 */
.ss-modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(15,17,22,.5); z-index: 70; padding: 20px; }
.ss-modal.on { display: flex; }
.ss-card { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.ss-h { font-weight: 800; font-size: 18px; color: var(--ink); margin-bottom: 18px; }
.ss-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; font-size: 14px; font-weight: 600; color: var(--text); }
.ss-row.col { flex-direction: column; align-items: stretch; gap: 7px; }
.ss-row input[type=text] { height: 42px; border: 1px solid var(--line); border-radius: 9px; padding: 0 12px; font-size: 15px; }
.ss-row input[type=text]:focus { outline: none; border-color: var(--ink); }
.ss-row input[type=checkbox] { width: 20px; height: 20px; }
.ss-hint { font-size: 12px; color: var(--dim); line-height: 1.6; margin-bottom: 18px; }
.ss-btns { display: flex; gap: 10px; justify-content: flex-end; }
.ss-btns button { height: 40px; padding: 0 18px; border-radius: 9px; border: 1px solid var(--line); background: var(--paper); font-weight: 600; cursor: pointer; }
.ss-btns button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 40; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 720px) {
  .story { grid-template-columns: 1fr; gap: 15px; }
  .transcript { font-size: 17px; line-height: 1.9; }
  .dock { right: 14px; bottom: 14px; }
}
