/* ===== 基礎 ===== */
:root {
  --ink:        #1f2933;
  --ink-soft:   #55606b;
  --ink-faint:  #8a949e;
  --line:       #e6e0d6;
  --paper:      #ffffff;
  --bg:         #faf7f1;
  --primary:    #1e3a5f;
  --primary-2:  #2d5580;
  --accent:     #c2703d;
  --accent-2:   #a85c2e;
  --ok:         #1f7a5a;
  --danger:     #b3352c;
  --radius:     14px;
  --shadow:     0 1px 2px rgba(31,41,51,.05), 0 8px 24px rgba(31,41,51,.06);
}

* { box-sizing: border-box; }

/* 讓 hidden 屬性永遠贏過元件自己的 display 設定 */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Heiti TC", "Microsoft JhengHei",
               -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: .01em;
}

.wrap { width: 100%; max-width: 880px; margin: 0 auto; padding: 0 20px; }

a { color: var(--primary-2); }

/* ===== 頁首 ===== */
.site-header {
  background: linear-gradient(160deg, #1e3a5f 0%, #2d5580 55%, #37648f 100%);
  color: #fff;
  padding: 34px 0 30px;
  position: relative;
  overflow: hidden;
}
.site-header::after {
  content: "";
  position: absolute;
  right: -60px; top: -70px;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.eyebrow {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: .22em;
  color: rgba(255,255,255,.72);
}
.site-header h1 {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: .02em;
}
.subtitle {
  margin: 0;
  color: rgba(255,255,255,.82);
  font-size: 15px;
}
.countdown {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 16px;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  font-size: 14px;
}
.countdown strong { font-size: 21px; font-weight: 700; }

/* ===== 導覽 ===== */
.nav {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav .wrap { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav .wrap::-webkit-scrollbar { display: none; }
.nav a { white-space: nowrap; }
.nav a {
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 3px solid transparent;
}
.nav a:hover { color: var(--primary); }
.nav a[aria-current="page"] {
  color: var(--primary);
  border-bottom-color: var(--accent);
  font-weight: 700;
}

/* ===== 版面 ===== */
main { padding: 28px 0 64px; }
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card > h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
}
.card > .hint { margin: 0 0 20px; color: var(--ink-faint); font-size: 14px; }

/* ===== 表單 ===== */
.field { margin-bottom: 20px; }
.field > label,
.field > .label {
  display: block;
  margin-bottom: 7px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.req { color: var(--accent); margin-left: 2px; }
.field .note { font-size: 13px; color: var(--ink-faint); font-weight: 400; margin-left: 6px; }

input[type="text"], select, textarea {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d8d2c7;
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px rgba(45,85,128,.14);
}
textarea { min-height: 78px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' fill='none' stroke='%2355606b' stroke-width='1.8' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }

/* 分段選擇（邀約類別） */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  display: block;
  text-align: center;
  padding: 13px 10px;
  border: 1.5px solid #d8d2c7;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 500;
  background: #fff;
  transition: all .15s;
}
.segmented label small { display: block; font-size: 12px; color: var(--ink-faint); font-weight: 400; }
.segmented input:checked + label {
  border-color: var(--primary);
  background: #eef3f9;
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 0 0 3px rgba(45,85,128,.12);
}
.segmented input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 福音朋友欄位 */
.friend-row { display: flex; gap: 8px; margin-bottom: 9px; align-items: center; }
.friend-row .idx {
  flex: 0 0 26px; height: 26px; line-height: 26px;
  text-align: center; font-size: 13px; font-weight: 700;
  color: var(--accent-2); background: #f8ede4; border-radius: 50%;
}
.friend-row { flex-wrap: wrap; }
.friend-row .friend-input { flex: 1 1 140px; min-width: 0; }
/* 「答應前來」核取方塊 */
.coming-check {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px 6px 9px;
  border: 1px solid var(--line); border-radius: 999px;
  background: #fff; cursor: pointer;
  font-size: 13px; color: var(--ink-soft);
  user-select: none;
}
.coming-check input { flex: 0 0 auto; width: 15px; height: 15px; margin: 0; accent-color: var(--ok); cursor: pointer; }
.coming-check:hover { border-color: #b8d5c9; color: var(--ok); }
.coming-check:has(input:checked) {
  background: #eef7f3; border-color: #b8d5c9; color: var(--ok); font-weight: 700;
}
.icon-btn {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  color: var(--ink-faint);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { color: var(--danger); border-color: #e8c4c0; background: #fdf5f4; }

/* 按鈕 */
.btn {
  display: inline-block;
  padding: 12px 22px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:disabled { background: #d8c6b8; cursor: not-allowed; }
.btn-ghost { background: #fff; border-color: #d8d2c7; color: var(--ink-soft); }
.btn-ghost:hover { border-color: var(--primary-2); color: var(--primary); }
.btn-sm { padding: 7px 13px; font-size: 14px; }
.btn-block { display: block; width: 100%; }

/* 訊息 */
.msg { padding: 12px 15px; border-radius: 10px; font-size: 14.5px; margin-bottom: 18px; }
.msg-error { background: #fdf1f0; border: 1px solid #f0cfcb; color: var(--danger); }
.msg-info  { background: #f2f6fb; border: 1px solid #d6e2f0; color: var(--primary); }
.msg-warn  { background: #fdf6e9; border: 1px solid #f0e0bd; color: #8a6216; }

/* 送出成功 */
.done { text-align: center; padding: 18px 0 8px; }
.done .tick {
  width: 58px; height: 58px; margin: 0 auto 14px;
  border-radius: 50%; background: #e8f4ef; color: var(--ok);
  font-size: 30px; line-height: 58px;
}
.done h2 { margin: 0 0 6px; font-size: 20px; }
.done p { margin: 0 0 22px; color: var(--ink-soft); }
.done .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ===== 統計看板 ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat .num { font-size: 27px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat .lbl { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }

/* ===== 篩選列 ===== */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 18px; }
.filters select[hidden] { display: none; }

/* ===== 代禱牆 ===== */
.section-title {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin: 30px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
}
.section-title h2 { margin: 0; font-size: 19px; }
.section-title .count { font-size: 13px; color: var(--ink-faint); }

.group-block {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.group-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  background: #f4f1ea;
  border-bottom: 1px solid var(--line);
}
.group-head h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--primary); }
.group-head .meta { font-size: 13px; color: var(--ink-faint); white-space: nowrap; }

.entry { padding: 14px 18px; border-top: 1px solid #f0ece4; }
.entry:first-child { border-top: none; }
.entry-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.entry-name { font-weight: 700; font-size: 15.5px; }
.entry-name::before { content: "🙏"; margin-right: 6px; font-size: 14px; }
.entry-time { font-size: 12px; color: var(--ink-faint); margin-left: auto; }
.friends { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.friend-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px;
  background: #f8ede4;
  color: var(--accent-2);
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.friend-tag:hover { border-color: #e0c3a8; }
.friend-tag:disabled { opacity: .55; cursor: progress; }
.friend-tag.is-coming {
  background: #e6f4ee; color: var(--ok); border-color: #b8d5c9; font-weight: 700;
}
.friend-tag .tick-sm { font-size: 12px; }
.friends-hint { margin: -6px 0 14px; font-size: 13px; color: var(--ink-faint); }
.friends-hint kbd {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: #f8ede4; color: var(--accent-2); font: inherit; font-size: 12.5px;
}
.entry-note { margin-top: 8px; font-size: 13.5px; color: var(--ink-soft); }
.entry-note::before { content: "備註："; color: var(--ink-faint); }
.entry-actions {
  margin-top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
/* 管理模式：指定小區 */
.dist-set {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--ink-faint);
  white-space: nowrap;          /* 「小區」兩個字不要被擠成兩行 */
}
.dist-set select {
  padding: 6px 28px 6px 10px; font-size: 13.5px;
  background-position: right 8px center;
}

.empty { text-align: center; padding: 46px 20px; color: var(--ink-faint); }
.empty .big { font-size: 34px; display: block; margin-bottom: 10px; }

/* 管理列 */
.admin-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.admin-bar .grow { flex: 1 1 auto; }
.admin-bar input { max-width: 200px; }

footer.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 0 34px;
  color: var(--ink-faint);
  font-size: 13px;
  text-align: center;
}

/* ===== 手機 ===== */
@media (max-width: 640px) {
  .site-header { padding: 26px 0 24px; }
  .site-header h1 { font-size: 24px; }
  .wrap { padding: 0 15px; }
  .card { padding: 18px 16px; border-radius: 12px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat { padding: 13px 10px; }
  .stat .num { font-size: 23px; }
  .filters { grid-template-columns: 1fr; }
  .segmented { grid-template-columns: 1fr; }
  .entry-time { margin-left: 0; width: 100%; }
  .nav a { padding: 12px 10px; font-size: 13.5px; }
  /* 窄螢幕排成兩行：第一行 [序號][姓名][×]，第二行才是「答應前來」，
     否則 × 會被擠到下一行變成孤零零一顆按鈕。 */
  .friend-row .icon-btn { order: 3; }
  .friend-row .coming-check { order: 4; margin-left: 34px; }
}

/* ===== 確定前來頁 ===== */
.stat-hero { background: linear-gradient(160deg, #1a3355, #2d5580); border-color: transparent; }
.stat-hero .num { color: #fff; }
.stat-hero .lbl { color: rgba(255,255,255,.78); }
.friend-tag .by {
  font-size: 11.5px; font-weight: 400; opacity: .72;
  padding-left: 6px; margin-left: 5px; border-left: 1px solid currentColor;
}

/* ===== 校園排資訊頁 ===== */
.pending-notice {
  display: flex; gap: 12px; align-items: flex-start;
  background: #fffaf2; border: 1px dashed #e0c3a8;
  border-radius: var(--radius); padding: 18px 18px;
  color: var(--ink-soft); font-size: 14.5px; line-height: 1.7;
  margin-bottom: 20px;
}
.pending-notice .ico { font-size: 22px; line-height: 1; }
.pending-notice strong { color: var(--accent-2); }

#map {
  height: 460px; width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #eee9e0; margin-bottom: 20px;
  z-index: 1;
}
#map.is-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-faint); font-size: 14.5px; text-align: center; padding: 20px;
}
.leaflet-popup-content { margin: 12px 14px; font-size: 14px; line-height: 1.65; }
.leaflet-popup-content h4 { margin: 0 0 6px; font-size: 15.5px; color: var(--primary); }
.leaflet-popup-content dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.leaflet-popup-content dt { color: var(--ink-faint); font-size: 13px; }
.leaflet-popup-content dd { margin: 0; }

.cm-card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.cm-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cm-head h3 { margin: 0; font-size: 16.5px; color: var(--primary); }
.cm-head .when {
  font-size: 13px; font-weight: 700; color: var(--accent-2);
  background: #f8ede4; padding: 3px 11px; border-radius: 999px;
}
.cm-body { margin-top: 10px; display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 14px; }
.cm-body dt { color: var(--ink-faint); }
.cm-body dd { margin: 0; }
.cm-body a { color: var(--primary); }
.cm-locate {
  margin-top: 10px; font-size: 13px; background: none; border: 0;
  color: var(--primary); cursor: pointer; padding: 0; text-decoration: underline;
}

@media (max-width: 620px) {
  #map { height: 340px; }
}

/* ===== 填寫頁：學制與學校搜尋 ===== */
.filter-row {
  display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: 9px;
}
.filter-row select, .filter-row input { min-width: 0; }
#school-count {
  margin: 7px 0 0; font-size: 12.5px; color: var(--ink-faint);
}
@media (max-width: 620px) {
  .filter-row { grid-template-columns: 1fr; }
}

/* 小區檢視：標出這筆是從哪個校園／小區登記的 */
.entry-via {
  font-size: 11.5px; color: var(--ink-faint);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 1px 9px; white-space: nowrap;
}

/* 區塊標題在窄螢幕不要被擠到斷字，讓後面的計數換行就好 */
.section-title h2 { white-space: nowrap; }

/* ===== 隱私加固相關（2026-09） ===== */

/* 狀態標籤：取代原本可自由填寫的備註 */
.tagpick { display: flex; flex-wrap: wrap; gap: 8px; }
.tagpick-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px 8px 11px;
  border: 1px solid var(--line); border-radius: 999px;
  background: #fff; cursor: pointer; user-select: none;
  font-size: 14px; color: var(--ink-soft);
}
.tagpick-item input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.tagpick-item:hover { border-color: #e0c3a8; }
.tagpick-item:has(input:checked) {
  background: #f8ede4; border-color: #e0c3a8; color: var(--accent-2); font-weight: 700;
}

.privacy-warn {
  margin-top: 8px; padding: 9px 12px;
  background: #fdf6f4; border: 1px solid #eccfc8; border-radius: 8px;
  color: var(--danger); line-height: 1.7;
}
.privacy-warn strong { color: var(--danger); }

/* 代禱牆上已答應的標記：公開檢視不可點 */
.friend-tag.is-static { cursor: default; }
.friend-tag.is-static:hover { border-color: transparent; }

.status-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.status-chip {
  font-size: 12px; padding: 2px 10px; border-radius: 999px;
  background: #eef1f5; color: var(--ink-soft);
}

/* 送出後顯示的專屬修改連結 */
.editlink {
  text-align: left; margin: 22px 0 4px; padding: 16px 18px;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fbfaf7;
}
.editlink h3 { margin: 0 0 6px; font-size: 15.5px; color: var(--primary); }
.linkrow { display: flex; gap: 8px; margin-top: 10px; }
.linkrow input {
  flex: 1 1 auto; min-width: 0; font-size: 12.5px;
  font-family: "SF Mono", Menlo, monospace; background: #fff;
}
.linkrow .btn { flex: 0 0 auto; }

/* 本人修改頁的福音朋友勾選列 */
.friend-check {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; cursor: pointer;
}
.friend-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--ok); cursor: pointer; }
.friend-check .fname { font-weight: 500; font-size: 15.5px; }
.friend-check .fstate { margin-left: auto; font-size: 12.5px; color: var(--ink-faint); }
.friend-check:has(input:checked) { border-color: #b8d5c9; background: #f2f9f6; }
.friend-check:has(input:checked) .fstate { color: var(--ok); font-weight: 700; }

.msg-ok { background: #eef7f3; border: 1px solid #b8d5c9; color: var(--ok); }

@media (max-width: 620px) {
  .linkrow { flex-direction: column; }
  .linkrow .btn { width: 100%; }
}
