/* 雙和分會 大事關懷共修 資料站 — 共用樣式（前台＋後台）
   配色與字體規範見 HANDOFF.md §4.5。設計定位：安靜的資料集錦，不是宣傳頁。 */

:root {
  --paper: #F6F2EA;
  --card: #FFFDF8;
  --ink: #2E2A25;
  --ink-soft: #6E665C;
  --ink-faint: #9A9186;
  --main: #7B5230;
  --main-soft: #B08B5E;
  --line: #E2DACD;
  --danger: #B3261E;
  --danger-bg: #FBEAE9;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 16.5px;
  line-height: 1.75;
}

a { color: inherit; }

img { max-width: 100%; display: block; }

.serif { font-family: "Noto Serif TC", serif; }

.wrap { max-width: 560px; margin: 0 auto; min-height: 100vh; background: var(--paper); }

/* ---------- LINE/FB App 內建瀏覽器提示條 ---------- */
.inapp-warning {
  background: #FDF3E3; color: #6B4A1E; padding: 10px 16px; font-size: 13.5px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid #ECD9B0;
}
.inapp-warning-copy {
  flex: none; background: #fff; border: 1px solid #D8C08E; color: #6B4A1E;
  border-radius: 8px; padding: 6px 10px; font-size: 13px;
}

/* ---------- Service Worker 更新提示條 ---------- */
.sw-update-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 500;
  background: var(--main); color: #fff; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 14.5px; box-shadow: 0 -4px 14px rgba(0,0,0,.15);
}
.sw-update-banner-btn {
  flex: none; background: #fff; color: var(--main); border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 14px; font-weight: 600;
}

/* ---------- 站台頁首（首頁專用） ---------- */
.sitehead { padding: 26px 20px 18px; background: var(--paper); border-bottom: 1px solid var(--line); }
.sitehead .term {
  display: inline-block; font-size: 12.5px; letter-spacing: .12em; color: var(--main-soft);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; margin-bottom: 12px;
}
.sitehead h1 {
  font-family: "Noto Serif TC", serif; font-weight: 600; font-size: 24px;
  line-height: 1.45; margin: 0 0 10px; letter-spacing: .03em;
}
.sitehead .rule { width: 40px; height: 2px; background: var(--main); margin: 0 0 12px; border-radius: 2px; }
.sitehead p { margin: 0; font-size: 15px; color: var(--ink-soft); line-height: 1.75; }

/* ---------- 內頁返回列 ---------- */
.navbar {
  display: flex; align-items: center; gap: 10px; padding: 16px 20px;
  border-bottom: 1px solid var(--line); background: var(--paper);
  position: sticky; top: 0; z-index: 10;
}
.navbar .back { color: var(--main); font-size: 15.5px; text-decoration: none; font-weight: 500; flex: none; }
.navbar .title {
  font-family: "Noto Serif TC", serif; font-size: 17.5px; font-weight: 600; margin-left: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- 首頁：入口卡片 ---------- */
.entries { padding: 18px 20px 0; display: flex; flex-direction: column; gap: 14px; }
.entry {
  display: block; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 18px 16px; position: relative; overflow: hidden;
}
.entry::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--main); opacity: .85; }
.entry .et {
  font-family: "Noto Serif TC", serif; font-size: 19.5px; font-weight: 600; margin: 0 0 5px;
  display: flex; align-items: center; gap: 9px;
}
.entry .et svg { flex: none; }
.entry .ed { margin: 0; font-size: 14.5px; color: var(--ink-soft); line-height: 1.7; }
.entry .latest {
  margin-top: 13px; padding-top: 12px; border-top: 1px dashed var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 14.5px; color: var(--main); font-weight: 500;
}
.entry .latest.has-thumb { align-items: flex-start; }
.entry .latest .lt-text { flex: 1; min-width: 0; }
.entry .latest .lt-line { font-size: 14.5px; color: var(--main); font-weight: 500; line-height: 1.5; }
.entry .latest .lt-sub { font-size: 12.5px; color: var(--ink-faint); font-weight: 400; margin-top: 3px; }
.entry .latest .n { color: var(--ink-faint); font-size: 13px; font-weight: 400; }
.entry .empty-hint { margin-top: 13px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 14px; color: var(--ink-faint); }
.thumb {
  flex: none; width: 60px; height: 60px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); background: var(--main-soft);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }

/* ---------- 首頁：相關連結區塊 ---------- */
.rel { margin: 16px 20px 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.rel .relhead { padding: 10px 18px 6px; font-size: 12.5px; color: var(--ink-faint); letter-spacing: .06em; }
.rel-row {
  padding: 13px 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  color: var(--ink-soft); font-size: 15px; text-decoration: none;
}
.rel-row + .rel-row { border-top: 1px solid var(--line); }
.rel-row .rt { flex: 1; min-width: 0; }
.rel-row b { color: var(--ink); font-weight: 500; display: block; }
.rel-row .rs { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; font-weight: 400; }
.rel-row .arrow { flex: none; color: var(--main-soft); }

.site-footer { margin-top: auto; padding: 22px 20px 30px; text-align: center; font-size: 12px; color: var(--ink-faint); line-height: 1.8; }

/* ---------- 簡報清單 ---------- */
.listnote { padding: 14px 20px 4px; font-size: 13.5px; color: var(--ink-faint); }
.slide-row {
  display: flex; gap: 14px; align-items: center; padding: 16px 20px;
  border-bottom: 1px solid var(--line); background: var(--card); text-decoration: none; color: inherit;
  min-height: 48px;
}
.slide-row .date { flex: none; width: 54px; text-align: center; }
.slide-row .date .md { font-family: "Noto Serif TC", serif; font-size: 18px; font-weight: 600; color: var(--main); line-height: 1.2; }
.slide-row .date .wd { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.slide-row .meta { flex: 1; min-width: 0; }
.slide-row .no { font-size: 12.5px; color: var(--main-soft); letter-spacing: .06em; }
.slide-row .tt { font-size: 16.5px; font-weight: 500; margin: 2px 0 3px; line-height: 1.45; }
.slide-row .sub { font-size: 13px; color: var(--ink-faint); }
.slide-row .arrow { flex: none; color: var(--main-soft); font-size: 19px; }
.slide-row.pending { opacity: .5; pointer-events: none; }
.slide-row.pending .tt { font-weight: 400; }
.empty-state { padding: 40px 20px; text-align: center; color: var(--ink-faint); font-size: 14.5px; }

/* ---------- 簡報瀏覽 ---------- */
.viewer-head { padding: 16px 20px 16px; border-bottom: 1px solid var(--line); background: var(--paper); }
.viewer-head .no { font-size: 12.5px; color: var(--main-soft); letter-spacing: .06em; }
.viewer-head h1 { font-family: "Noto Serif TC", serif; font-size: 19.5px; font-weight: 600; margin: 3px 0 4px; line-height: 1.45; }
.viewer-head .sub { font-size: 13.5px; color: var(--ink-faint); }
.dl-btn {
  margin-top: 14px; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid var(--main); color: var(--main); border-radius: 10px;
  padding: 12px; font-size: 15px; font-weight: 500; background: #fff; text-decoration: none; min-height: 48px;
}
.pageimgs { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.pageimgs .pg {
  position: relative; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  box-shadow: 0 2px 8px rgba(60,45,25,.07);
}
.pageimgs .pg img { width: 100%; height: auto; }
.pageimgs .pg .pn {
  position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: #fff;
  background: rgba(46,42,37,.55); padding: 1px 7px; border-radius: 999px;
}

/* ---------- 活動訊息 ---------- */
.news-list { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.news-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.news-item .d { font-size: 12.5px; color: var(--main-soft); letter-spacing: .06em; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.tag { background: #F0E6D5; color: var(--main); border-radius: 4px; padding: 1px 8px; font-size: 11.5px; letter-spacing: 0; }
.news-item h2 { font-size: 17px; margin: 0 0 8px; font-weight: 500; line-height: 1.5; }
.news-item .body-text { margin: 10px 0 0; font-size: 14.5px; color: var(--ink-soft); line-height: 1.8; white-space: pre-wrap; }

.poster { margin: 4px 0 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.poster + .poster { margin-top: 10px; }
.poster img { width: 100%; height: auto; cursor: zoom-in; }
.poster-tools { display: flex; border-top: 1px solid var(--line); }
.poster-tools button {
  flex: 1; text-align: center; padding: 11px 6px; font-size: 14px; color: var(--main); font-weight: 500;
  background: none; border: none; min-height: 44px;
}
.poster-tools button + button { border-left: 1px solid var(--line); }

.linkrow { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.linkbtn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1.5px solid var(--main); color: var(--main); background: #fff;
  border-radius: 10px; padding: 12px 14px; font-size: 15px; font-weight: 500; text-decoration: none; min-height: 48px;
}
.linkbtn.secondary { border: 1px solid var(--line); color: var(--ink-soft); font-weight: 400; }
.linkbtn .note { font-size: 12px; color: var(--ink-faint); font-weight: 400; }

/* 全螢幕海報放大 lightbox */
.lightbox {
  position: fixed; inset: 0; background: rgba(20,16,12,.92); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.lightbox-close {
  position: absolute; top: 16px; right: 16px; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.15); color: #fff; border: none; font-size: 22px;
}

/* ---------- 公告彈窗 ---------- */
.announce-overlay {
  position: fixed; inset: 0; background: rgba(20,16,12,.55); z-index: 1500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.announce-box {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 24px 22px; position: relative;
}
.announce-box h2 { font-family: "Noto Serif TC", serif; font-size: 19px; margin: 0 12px 10px 0; }
.announce-box .body-text { font-size: 14.5px; line-height: 1.8; white-space: pre-wrap; margin: 0 0 18px; }
.announce-close {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 50%;
  background: transparent; border: 1px solid var(--line); color: var(--ink-faint); font-size: 16px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.announce-dismiss { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-faint); }

/* ---------- install 頁 ---------- */
.install-steps { padding: 20px; }
.install-steps ol { padding-left: 20px; }
.install-steps li { margin-bottom: 16px; font-size: 15px; line-height: 1.8; }

/* ---------- 通用空狀態／載入 ---------- */
.loading-hint { padding: 40px 20px; text-align: center; color: var(--ink-faint); font-size: 14.5px; }

/* ==================== 後台共用 ==================== */
.admin-shell { max-width: 720px; margin: 0 auto; padding: 20px 18px 96px; }
.admin-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-header h1 { font-family: "Noto Serif TC", serif; font-size: 21px; margin: 0; }
.admin-header-actions { display: flex; gap: 14px; font-size: 14px; }
.admin-header-actions a { color: var(--main); text-decoration: none; }
.admin-logout-link { color: var(--ink-faint); text-decoration: none; font-size: 14px; }
.admin-tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-tabs a {
  padding: 8px 14px; border-radius: 999px; font-size: 14px; text-decoration: none; color: var(--ink-soft);
  border: 1px solid var(--line); background: #fff;
}
.admin-tabs a.active { background: var(--main); color: #fff; border-color: var(--main); }

.admin-list-row { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.item-row-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; cursor: pointer; min-height: 48px; }
.item-row-header .item-type-badge { flex: none; font-size: 12px; color: var(--main-soft); }
.item-row-header .item-summary-label { flex: 1; min-width: 0; font-size: 15.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row-header .item-summary-sub { font-size: 12.5px; color: var(--ink-faint); font-weight: 400; }
.item-toggle-chevron { flex: none; transition: transform .15s; color: var(--ink-faint); }
.admin-list-row.expanded .item-toggle-chevron { transform: rotate(180deg); }
.item-body { display: none; padding: 4px 16px 18px; border-top: 1px solid var(--line); }
.admin-list-row.expanded .item-body { display: block; }
.admin-list-row.dragging { opacity: .4; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14.5px; font-weight: 500; margin-bottom: 5px; }
.field input[type=text], .field input[type=date], .field input[type=password], .field textarea, .field select {
  width: 100%; padding: 10px 12px; font-size: 15px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font-family: inherit;
}
.field textarea { min-height: 80px; resize: vertical; }
.field-hint { font-size: 12.5px; color: var(--ink-faint); margin: 4px 0 0; }
.field-error { font-size: 13px; color: var(--danger); margin: 4px 0 0; }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row .field { flex: 1 1 140px; min-width: 120px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; font-size: 14.5px; margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; font-size: 14.5px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; min-height: 44px; font-family: inherit;
  white-space: nowrap; flex-shrink: 0;
}
.btn.primary { background: var(--main); border-color: var(--main); color: #fff; font-weight: 600; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-outline { border-color: var(--danger); color: var(--danger); background: #fff; }
.btn.small { padding: 6px 10px; font-size: 13px; min-height: 36px; }
.btn.icon-square { padding: 6px; width: 36px; height: 36px; min-height: 36px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.reorder-btns { display: flex; gap: 6px; }

.upload-progress { font-size: 13.5px; color: var(--main); margin-top: 8px; }
.upload-progress-bar { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.upload-progress-bar > div { height: 100%; background: var(--main); transition: width .2s; }
.file-preview-thumb { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.file-chip-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 8px 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.file-chip-row .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 900;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px;
}

.admin-savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 400;
  background: #fff; border-top: 1px solid var(--line); padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 -4px 14px rgba(0,0,0,.06);
}
.admin-savebar-status { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--ink-faint); }
.admin-savebar-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.admin-savebar-status.dirty .dot { background: #C9862A; }
.admin-savebar-status.dirty { color: #8A5A16; }
.admin-savebar-status.saved .dot { background: #3E8E5B; }
.admin-savebar-status.saved { color: #2C6B42; }

.admin-login-overlay {
  position: fixed; inset: 0; background: var(--paper); z-index: 2000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.admin-login-box { width: 100%; max-width: 340px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 26px 24px; }
.admin-login-box h1 { font-family: "Noto Serif TC", serif; font-size: 20px; margin: 0 0 8px; }
.password-field { display: flex; gap: 8px; margin: 14px 0 6px; }
.password-field input { flex: 1; padding: 10px 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; }
.admin-login-submit { width: 100%; margin-top: 12px; }

.backup-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.backup-row:first-child { border-radius: 12px 12px 0 0; }
.backup-row:last-child { border-radius: 0 0 12px 12px; border-bottom: none; }
.backup-row .meta { font-size: 14px; }
.backup-row .meta .t { font-weight: 500; }
.backup-row .meta .s { font-size: 12.5px; color: var(--ink-faint); }
