/* 助念8小時 PWA — 共用樣式（前台＋後台）
   字級：全站固定放大一級（20px），不再讓使用者自己切換；長輩友善優先，但避免過大排版跑掉。 */

html {
  font-size: 20px;
}

/* 配色取自法鼓山全球資訊網 www.ddm.org.tw 實際用色（2026-09-27 量測）：
   頁面底 #E0DDD6 暖石灰、內容區 #F7F6F4 米白、按鈕 #004D47 深墨綠、標誌 #A68728 金、
   功能色塊 #588173 青綠／金、內文 #333333。四個分類的色塊顏色存在後台內容資料，後台色票已換成同一套。 */
:root {
  --bg: #e0ddd6;
  --bg-elevated: #f7f6f4;
  --text: #333333;
  --text-secondary: #545859;
  --text-muted: #5c5f60;
  --border: #cdc8bd;
  --link: #004d47;
  --gold: #a68728;
  /* 白字底色用：深淺模式都固定官網深墨綠，白字對比才夠 */
  --accent-solid: #004d47;
  --hotline-bg: #f7f6f4;
  --hotline-text: #004d47;
  --keypoint-bg: #f8f4e6;
  --keypoint-border: #a68728;
  --keypoint-text: #333333;
  --card-bg: #f7f6f4;
  --card-border: #d6d1c6;
  --quote-bg: #eeebe4;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161817;
    --bg-elevated: #212423;
    --text: #ecebe7;
    --text-secondary: #c9c7c0;
    --text-muted: #a8a69f;
    --border: #3a3d3b;
    --link: #86c7bb;
    --gold: #c9a646;
    --hotline-bg: #212423;
    --hotline-text: #86c7bb;
    --keypoint-bg: #2a2719;
    --keypoint-border: #c9a646;
    --keypoint-text: #f0e8cf;
    --card-bg: #212423;
    --card-border: #353836;
    --quote-bg: #2a2d2b;
  }
}
:root[data-theme="dark"] {
  --bg: #161817;
  --bg-elevated: #212423;
  --text: #ecebe7;
  --text-secondary: #c9c7c0;
  --text-muted: #a8a69f;
  --border: #3a3d3b;
  --link: #86c7bb;
  --gold: #c9a646;
  --hotline-bg: #212423;
  --hotline-text: #86c7bb;
  --keypoint-bg: #2a2719;
  --keypoint-border: #c9a646;
  --keypoint-text: #f0e8cf;
  --card-bg: #212423;
  --card-border: #353836;
  --quote-bg: #2a2d2b;
}

* {
  box-sizing: border-box;
}

/* overflow-x 用 clip 不用 hidden：hidden 會讓 html/body 變成捲動容器，
   害 .topbar 的 position:sticky 失效（返回列跟著捲走）。hidden 留著給不支援 clip 的舊瀏覽器當退路。 */
html,
body {
  max-width: 100vw;
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

a,
button {
  touch-action: manipulation;
}

img {
  max-width: 100%;
}

/* Service Worker 偵測到新版本時的提示條——固定在畫面底部，不會打斷使用者當下正在看的內容 */
.sw-update-banner {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 150;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  background: var(--accent-solid);
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  font-size: 0.85rem;
  text-align: center;
}
.sw-update-banner-btn {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0.3rem 0.9rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

/* 首頁頁首：米白底＋金色下緣線＋右上角淡蓮花線稿（比照法鼓山官網：米白內容區、金色標誌、墨綠主色） */
.site-header {
  position: relative;
  overflow: hidden;
  padding: 1.1rem 1rem 0.95rem;
  text-align: center;
  background: var(--bg-elevated);
  border-bottom: 3px solid var(--gold);
}
.site-header-lotus {
  position: absolute;
  right: -30px;
  top: -10px;
  width: 140px;
  color: var(--gold);
  opacity: 0.14;
  pointer-events: none;
}
.site-header-kicker {
  position: relative;
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold);
}
.site-header-title {
  position: relative;
  margin: 0.1rem 0 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.35;
  color: var(--link);
}

/* 專線卡片（首頁、主題頁底部共用）：左側墨綠邊條＋墨綠電話圓鈕。
   號碼、分機、服務時間各自不換行，之間才允許換行，避免號碼被從中間拆開。 */
.hotline-bar {
  margin: 0 1rem 1rem;
}
.hotline-bar a {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.85rem 1rem;
  border-radius: 6px;
  background: var(--hotline-bg);
  border-left: 5px solid var(--accent-solid);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  color: var(--text);
  text-decoration: none;
  min-height: 44px;
}
.hotline-bar-phone {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-solid);
  color: #fff;
}
.hotline-bar-phone svg {
  width: 22px;
  height: 22px;
}
.hotline-bar-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
}
.hotline-bar-number {
  display: block;
  margin: 0.1rem 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--hotline-text);
}
.hotline-bar-hours {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
}
.hotline-bar a:active {
  filter: brightness(0.95);
}

/* 主題色塊 grid：比照法鼓山官網首頁功能鈕——青綠／金色、置中白字白圖示、塊內一圈半透明細白框 */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  padding: 1rem;
}
.topic-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.25rem;
  min-height: 140px;
  padding: 1rem 0.7rem;
  border-radius: 6px;
  color: #ffffff;
  text-decoration: none;
  min-width: 0;
  container-type: inline-size;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
}
.topic-tile::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 3px;
  pointer-events: none;
}
.topic-tile .icon {
  width: 34px;
  height: 34px;
}
/* 標題字級跟著色塊寬度走（約六個字剛好一行），避免「其他補充資／料」這種只剩一個字掉到下一行；
   寬螢幕上限 1.12rem。不支援 container query 的舊瀏覽器退回固定字級＋平均斷行。
   金色底白字對比約 3.4:1，所以標題、副標都加粗並加一點點文字陰影，長輩比較看得清楚。 */
.topic-tile .title {
  margin-top: 0.3rem;
  font-size: 1.12rem;
  font-size: clamp(0.95rem, 15.5cqi, 1.12rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.3;
  text-wrap: balance;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.topic-tile .subtitle {
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.4;
  text-wrap: balance;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.disclaimer {
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0 1rem;
  border-top: 1px solid rgba(166, 135, 40, 0.4);
}
.updated-at {
  text-align: right;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0.6rem 1.2rem 1rem;
}

/* 第二層：返回列（固定在頂端，長頁面滑到底也隨時按得到「回主選單」） */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1rem;
  gap: 0.5rem;
}
/* 主題頁的返回列染成該分類的顏色：一眼知道自己在哪個分類，也讓首頁色塊可以「延伸」成這條頁首 */
.topbar.tinted {
  border-bottom-color: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.topbar.tinted .back-link,
.topbar.tinted .current-title {
  color: #ffffff;
}
.motion-ok [data-vt-hero] {
  view-transition-name: topic-hero;
}
.topbar .back-link {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  min-height: 48px;
  padding: 0.4rem 0.2rem;
}
.topbar .current-title {
  font-weight: 700;
  font-size: 1rem;
}

/* 內頁卡片統一跟首頁同一套：小圓角 6px、米白底；重點框跟專線卡片一樣用左側粗色條（這裡用金色） */
.keypoint-box {
  margin: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 6px;
  background: var(--keypoint-bg);
  border: 1px solid var(--card-border);
  border-left: 5px solid var(--keypoint-border);
  color: var(--keypoint-text);
}
.keypoint-box ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}
.keypoint-box li {
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

.section-heading {
  margin: 1.2rem 1rem 0.6rem;
  padding-left: 0.55rem;
  border-left: 4px solid var(--gold);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--link);
}

.item-card {
  margin: 0 1rem 1rem;
  padding: 1rem;
  border-radius: 6px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
/* 卡片標題：墨綠字＋一條細金線分隔，呼應首頁頁首的金色下緣線 */
.item-card .question {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.6rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(166, 135, 40, 0.35);
  color: var(--link);
}

/* notice：單則醒目提醒，排在主題最上方，用來強調「這件事不要做」這類警語 */
.notice-box {
  margin: 0 1rem 1rem;
  padding: 1rem;
  border-radius: 6px;
  background: var(--keypoint-bg);
  border: 1px solid var(--card-border);
  border-left: 5px solid var(--keypoint-border);
  color: var(--keypoint-text);
}
.notice-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}
.notice-body {
  font-size: 1rem;
  line-height: 1.7;
  margin: 0.5rem 0 0;
}

/* checklist：可打勾的待辦清單。觸控目標整列 ≥48px，長輩點得到 */
.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.6rem 0;
  min-height: 48px;
  font-size: 1.05rem;
  line-height: 1.6;
  cursor: pointer;
}
.check-row input[type="checkbox"] {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  margin-top: 0.1rem;
  accent-color: var(--link);
}
.check-row input:checked + span {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* steps：1→2→3 編號流程 */
.steps-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.step-row {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.5rem 0;
}
.step-num {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-solid);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}
.step-text {
  display: block;
  font-size: 1.05rem;
  line-height: 1.7;
  padding-top: 0.2rem;
  text-wrap: pretty;
}
.step-image {
  display: block;
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--card-border);
}

/* 可點開放大的照片：右下角直接寫「點圖放大」，長輩不會自己猜到照片可以點 */
.zoomable {
  position: relative;
  display: block;
  margin-top: 0.5rem;
  max-width: 240px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  border-radius: 4px;
}
.zoom-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.6;
  pointer-events: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4.5rem 0.5rem 1.5rem;
  background: rgba(0, 0, 0, 0.96);
}
.lightbox[hidden] {
  display: none;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  touch-action: pinch-zoom;
}
.lightbox-close {
  position: absolute;
  top: calc(0.75rem + env(safe-area-inset-top));
  right: 0.75rem;
  min-height: 52px;
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.lightbox-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(0.5rem + env(safe-area-inset-bottom));
  text-align: center;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.75rem;
  margin: 0;
}

/* 內文裡的電話號碼：可直接點撥；號碼本身不換行，避免「2897-」和「5700」被拆到兩行抄錯 */
.tel-link {
  color: var(--link);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0.15rem 0.1rem;
  border-radius: 6px;
}
.nowrap {
  white-space: nowrap;
}
.tel-icon {
  width: 0.9em;
  height: 0.9em;
  margin-right: 0.2em;
  vertical-align: -0.1em;
}
.step-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.5rem;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  border: 1px solid var(--card-border);
  background: var(--bg-elevated);
  color: var(--link);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
}

/* 摺疊列（Q&A／文章共用）：一開始只看到標題＋箭頭，點了才展開內容，
   避免第一眼就把所有題目的完整文字灑滿整頁。 */
.qa-row {
  margin: 0 1rem 0.6rem;
  border-radius: 6px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  overflow: hidden;
}
.qa-row-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  min-height: 48px;
}
.qa-row-summary::-webkit-details-marker {
  display: none;
}
.qa-row-summary::after {
  content: "›";
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.15s;
}
.qa-row[open] .qa-row-summary::after {
  transform: rotate(90deg);
}
.qa-row-body {
  padding: 0 1rem 1rem;
}

.sub-heading {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0.8rem 0 0.3rem;
  color: var(--text);
}
.sub-heading:first-child {
  margin-top: 0;
}

.item-card .summary,
.qa-row-body .summary {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 0.6rem;
}
.item-card .quote,
.qa-row-body .quote {
  background: var(--quote-bg);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  margin: 0.6rem 0 0.5rem;
  font-size: 0.92rem;
}
.item-card .quote-note,
.qa-row-body .quote-note {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.item-card .sources,
.qa-row-body .sources {
  font-size: 0.78rem;
}
.item-card .sources a,
.qa-row-body .sources a {
  color: var(--link);
  display: inline-block;
  min-height: 44px;
  line-height: 44px;
}

/* 引文＋出處預設收合，只留白話重點摘要一律可見，避免頁面被逐字長引文拉得過長。
   一鍵展開仍可看到完整引文，資訊沒有被拿掉，只是不預設攤開。 */
.quote-details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--link);
  min-height: 44px;
  display: flex;
  align-items: center;
  list-style: none;
}
.quote-details summary::-webkit-details-marker {
  display: none;
}
.quote-details summary::before {
  content: "▸";
  margin-right: 0.4rem;
}
.quote-details[open] summary::before {
  content: "▾";
}

/* type: links——資料連結清單 */
.links-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.link-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--card-border);
  background: var(--bg-elevated);
  text-decoration: none;
  min-height: 48px;
  justify-content: center;
}
.link-label {
  color: var(--link);
  font-weight: 700;
  font-size: 0.95rem;
}
.link-note {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.link-item-image {
  width: 100%;
  max-width: 260px;
  border-radius: 4px;
  border: 1px solid var(--card-border);
  margin-bottom: 0.3rem;
}

/* 影片 lite embed——手機上一排一支大卡片（2 欄縮圖對長輩太小、標題被切斷、播放鈕不好按）；
   寬螢幕才並排兩欄。點了才載入 iframe。 */
.video-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
  margin: 0 1rem 1rem;
}
@media (min-width: 720px) {
  .video-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.video-tile {
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  min-width: 0;
}
.video-tile.playing {
  grid-column: 1 / -1;
}
.thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  /* 縮圖還沒載入前的底色——原本純黑，看起來像影片壞掉 */
  background: var(--quote-bg);
  cursor: pointer;
}
.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-wrap .play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
  border: 2px solid rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb-wrap .play-btn svg {
  width: 30px;
  height: 30px;
  fill: #fff;
  margin-left: 4px;
}
.video-tile iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  display: block;
}
.tile-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0.7rem 0.9rem 0.2rem;
  line-height: 1.45;
  text-wrap: pretty;
}
.tile-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0.9rem 0.7rem;
}
.video-tile .tile-title:last-child {
  margin-bottom: 0.8rem;
}

/* 底部再放一次撥打專線 */
.bottom-hotline {
  margin: 1.5rem 1rem;
  display: block;
  text-align: center;
  background: var(--hotline-bg);
  color: var(--hotline-text);
  text-decoration: none;
  font-weight: 700;
  padding: 1rem;
  border-radius: 12px;
  min-height: 48px;
}

/* 主題頁「本頁內容」快速跳轉——換行排列不用橫向捲動（長輩不會發現可以左右滑） */
.toc {
  margin: 0 1rem 1rem;
}
.toc-label {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}
.toc-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.toc-chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.35rem 0.9rem;
  border-radius: 6px;
  border: 1.5px solid var(--card-border);
  background: var(--card-bg);
  color: var(--link);
  font-size: 0.88rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
/* 跳轉後標題不要被固定在頂端的返回列擋住 */
.item-card,
.section-heading,
.qa-row,
.notice-box {
  scroll-margin-top: 88px;
}

.back-to-top {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 60;
  min-height: 52px;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  border: 0;
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.has-sw-banner .back-to-top {
  bottom: calc(6rem + env(safe-area-inset-bottom));
}
.page-bottom-space {
  height: 5rem;
}

/* ===== 動態效果：只回應使用者的操作，不自動輪播、不持續閃爍；
   手機開了「減少動態效果」的人一律不播（最下面的 reduce 區塊）。 ===== */

/* 效果1：按下回饋——按到的東西微微縮小變深，長輩一看就知道「有按到」 */
.topic-tile,
.thumb-wrap,
.link-item,
.step-link,
.toc-chip,
.back-to-top,
.back-link,
.zoomable,
.hotline-bar a,
.sw-update-banner-btn,
.lightbox-close {
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}
.topic-tile:active,
.thumb-wrap:active,
.link-item:active,
.step-link:active,
.toc-chip:active,
.back-to-top:active,
.zoomable:active,
.sw-update-banner-btn:active,
.lightbox-close:active {
  transform: scale(0.96);
  filter: brightness(0.9);
}
.topic-tile:active {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.back-link:active {
  opacity: 0.7;
}

/* 效果2、3 只在 html.motion-ok 時才有（由 js/motion-gate.js 判斷），LINE 等 App 內建瀏覽器不開。
   @view-transition 本身也是 motion-gate.js 動態加上的，這裡刻意不寫——寫在這裡就沒辦法針對 LINE 關掉。 */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  /* 效果2：換頁轉場——首頁色塊平滑延伸成主題頁頂端的色條（支援的瀏覽器才有，不支援的照常換頁） */
  ::view-transition-group(topic-hero) {
    animation-duration: 0.38s;
    animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.25s;
  }

  /* 效果3：主題頁內容一張接一張輕輕浮上來，只在進頁面時播一次 */
  .motion-ok .reveal {
    animation: reveal-rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    animation-delay: calc(var(--i, 0) * 70ms);
  }
  @keyframes reveal-rise {
    from {
      opacity: 0;
      transform: translateY(14px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
  .motion-ok .lightbox {
    animation: lightbox-in 0.2s ease both;
  }
  @keyframes lightbox-in {
    from {
      opacity: 0;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .topic-tile:active,
  .thumb-wrap:active,
  .link-item:active,
  .step-link:active,
  .toc-chip:active,
  .back-to-top:active,
  .zoomable:active,
  .sw-update-banner-btn:active,
    .lightbox-close:active {
    transform: none;
  }
}

/* 後台共用 */
.admin-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: 5.5rem; /* 留給下面固定的存檔列，不然最後一張卡片會被擋住 */
}
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.admin-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.admin-logout-link {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0.4rem;
}
.admin-list-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  margin-bottom: 0.6rem;
  background: var(--card-bg);
  cursor: grab;
}
.admin-list-row.dragging {
  opacity: 0.4;
}
.admin-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
}
.form-row {
  margin-bottom: 0.9rem;
}
.form-row label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.25rem;
  font-size: 1rem;
}
.field-hint {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-muted);
  margin: 0 0 0.4rem;
}
.form-row input[type="text"],
.form-row input[type="url"],
.form-row input[type="password"],
.form-row textarea,
.form-row select {
  width: 100%;
  min-width: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.05rem;
}
.char-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.char-count.over {
  color: #a32d2d;
  font-weight: 700;
}
.field-error {
  color: #a32d2d;
  font-size: 0.95rem;
  margin-top: 0.3rem;
}
.btn {
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
}
.btn.primary {
  background: var(--accent-solid);
  border-color: var(--link);
  color: #fff;
}
/* 真正不可逆、後果較大的操作（例如備份還原）才用滿版紅底，維持視覺警示。 */
.btn.danger {
  background: #a32d2d;
  border-color: #a32d2d;
  color: #fff;
}
/* 卡片內「刪除這一則」「移除這一行」用外框紅字——同一個畫面上到處都是滿版紅按鈕，
   反而讓真正該小心的操作被稀釋掉，長輩也容易手滑點到。 */
.btn.danger-outline {
  background: transparent;
  border-color: #a32d2d;
  color: #a32d2d;
}
.btn.small {
  min-height: 36px;
  padding: 0.3rem 0.7rem;
  font-size: 0.9rem;
}
.btn.icon-square {
  min-height: 40px;
  min-width: 40px;
  padding: 0.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}
.btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1c1a17;
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 100;
}

.hidden {
  display: none !important;
}

/* 常駐存檔列——固定在畫面底部，改完最後一則不用捲回頂端找存檔鈕，
   也能一眼看到「尚未儲存／已儲存」狀態，不用自己猜有沒有存到。 */
.admin-savebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.7rem 1rem;
  background: var(--card-bg);
  border-top: 1px solid var(--card-border);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
}
.admin-savebar-status {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.admin-savebar-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.admin-savebar-status.dirty .dot {
  background: #c98a1a;
}
.admin-savebar-status.dirty {
  color: #8a5c0f;
}
.admin-savebar-status.saved .dot {
  background: #1f7a4d;
}
.admin-savebar-status.saved {
  color: #1f7a4d;
}

/* 主題內容題目：預設收合，只留一行摘要——一次展開所有題目是這個畫面最陽春的地方，
   長輩要改第3則得先滑過前面兩則沒摺起來的完整表單。 */
.item-row-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  width: 100%;
}
.item-row-header .drag-handle {
  cursor: grab;
  color: var(--text-muted);
  flex-shrink: 0;
}
.item-type-badge {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  flex-shrink: 0;
  white-space: nowrap;
}
.item-summary-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-toggle-chevron {
  flex-shrink: 0;
  transition: transform 0.15s ease;
  color: var(--text-muted);
}
.admin-list-row.expanded .item-toggle-chevron {
  transform: rotate(90deg);
}
.item-body {
  display: none;
  margin-top: 0.6rem;
}
.admin-list-row.expanded .item-body {
  display: grid;
  gap: 0.6rem;
}
.item-row-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}
.reorder-btns {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* 圖示選擇：改成看圖點選，不要顯示 bed/wind 這種英文代碼。 */
.icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.icon-picker button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  font-size: 0.75rem;
  min-width: 52px;
}
.icon-picker button svg {
  width: 22px;
  height: 22px;
}
.icon-picker button.selected {
  border-color: var(--link);
  background: var(--bg);
}

/* 登入畫面——取代舊版 window.prompt()，避免 LINE/FB 內建瀏覽器直接擋掉整段登入流程。 */
.admin-login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 200;
}
.admin-login-box {
  width: 100%;
  max-width: 360px;
  display: grid;
  gap: 0.7rem;
}
.admin-login-box h1 {
  font-size: 1.3rem;
  margin: 0;
}
.password-field {
  display: flex;
  gap: 0.4rem;
}
.password-field input {
  flex: 1;
}
