/* 梵唄＆代說佛法研習課程資料站 — 共用樣式（前台＋後台）
   手機優先、長輩友善：字級 20px 起跳、單欄、按鈕 ≥ 56px 高。
   配色沿用法鼓山官網量測色（見 zhunian8h）：深墨綠 #004D47、金 #A68728、米白底。 */

html {
  font-size: 20px;
  -webkit-text-size-adjust: 100%;
}
:root {
  --bg: #f4f1ea;
  --bg-top: #faf9f6;
  --text: #2f3332;
  --text-secondary: #4f5554;
  --border: #d9d3c4;
  --green: #004d47;
  --gold: #8f7220; /* 官網金 #A68728 在白底當字太淡，文字用加深版 */
  --gold-solid: #a68728;
  --green-tint: #e7efec;
  --gold-tint: #f8f1df;
  --card-bg: #ffffff;
  --link: #004d47;
  --danger: #8a3b12;
}
* {
  box-sizing: border-box;
}
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;
}
a {
  color: var(--link);
}
img {
  max-width: 100%;
  height: auto;
}
.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- 首頁頁首 ---------- */
.hero {
  background: var(--bg-top);
  border-bottom: 3px solid var(--gold-solid);
  text-align: center;
  padding: 1.6rem 0 1.3rem;
  position: relative;
  overflow: hidden;
}
.hero-lotus {
  position: absolute;
  right: -30px;
  top: -10px;
  width: 170px;
  opacity: 0.18;
  pointer-events: none;
}
.hero-kicker {
  color: var(--gold);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.15em;
  margin: 0;
}
.hero h1 {
  margin: 0;
  color: var(--green);
  font-size: 2.2rem;
  line-height: 1.25;
  font-weight: 900;
}
.hero h1 .amp {
  font-size: 0.7em;
  margin: 0 0.05em;
}
.hero-sub {
  margin: 0.45rem 0 0;
  color: var(--green);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.hero-rule {
  width: 9rem;
  height: 4px;
  border-radius: 2px;
  background: var(--gold-solid);
  margin: 0.9rem auto;
  border: 0;
}
.hero-desc {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1rem;
}

/* ---------- 首頁四張卡片 ---------- */
.menu {
  list-style: none;
  margin: 1.1rem 0;
  padding: 0;
  display: grid;
  gap: 0.8rem;
}
.menu a {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem;
  border-radius: 14px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid transparent;
  min-height: 108px;
}
.menu .is-green a {
  background: var(--green-tint);
  border-color: #cfe0da;
}
.menu .is-gold a {
  background: var(--gold-tint);
  border-color: #eadfbe;
}
.menu-icon {
  flex: none;
  width: 72px;
  height: 72px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
}
.is-green .menu-icon {
  background: var(--green);
}
.is-gold .menu-icon {
  background: var(--gold-solid);
}
.menu-icon svg {
  width: 44px;
  height: 44px;
}
.menu-text {
  flex: 1;
  min-width: 0;
}
.menu-text b {
  display: block;
  color: var(--green);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.3;
}
.menu-text span {
  display: block;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.45;
  margin-top: 0.15rem;
}
.menu-arrow {
  flex: none;
  width: 26px;
  height: 26px;
}
.is-green .menu-arrow {
  color: var(--green);
}
.is-gold .menu-arrow {
  color: var(--gold-solid);
}
.foot {
  border-top: 1px solid var(--border);
  margin: 1.2rem 0 0;
  padding: 0.9rem 0 1.6rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ---------- 內頁 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--green);
  color: #fff;
}
.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 60px;
}
.back {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.4rem 0.7rem 0.4rem 0.3rem;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  min-height: 46px;
}
.back svg {
  width: 22px;
  height: 22px;
}
.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  flex: 1;
  min-width: 0;
}
.page {
  padding-top: 1rem;
  padding-bottom: 2rem;
}
.lead {
  color: var(--text-secondary);
  font-size: 1rem;
  margin: 0 0 1rem;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.card-body {
  padding: 0.9rem 1rem;
}
.card h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--green);
  line-height: 1.4;
}
.card .meta {
  margin: 0.2rem 0 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.notice {
  background: var(--gold-tint);
  border: 1px solid #eadfbe;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin: 0 0 1rem;
  font-size: 1rem;
}
.loading,
.empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem 0;
}

/* 影片縮圖（按下才載入播放器） */
.vthumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  padding: 0;
  background: #1b1f1e center / cover no-repeat;
  cursor: pointer;
}
.vthumb .playdot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
  display: grid;
  place-items: center;
  color: #fff;
}
.vthumb .playdot svg {
  width: 46px;
  height: 46px;
  fill: currentColor;
}
.vthumb .playlabel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.4rem;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
}
/* 未開放：縮圖蓋一層，說明什麼時候會開 */
.vlocked {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #2a2f2e center / cover no-repeat;
}
.vlocked-cover {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 23, 0.82);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  gap: 0.3rem;
}
.vlocked-cover svg {
  width: 40px;
  height: 40px;
}
.vlocked-cover b {
  font-size: 1.25rem;
}
.vlocked-cover span {
  font-size: 0.95rem;
  opacity: 0.92;
}
.badge {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  vertical-align: 0.1em;
  margin-left: 0.3rem;
}
.badge-open {
  background: var(--green-tint);
  color: var(--green);
  border: 1px solid var(--green);
}
.badge-closed {
  background: #eeeae2;
  color: #555;
  border: 1px solid #aaa;
}

/* 一般按鈕 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 56px;
  padding: 0.5rem 1.2rem;
  border-radius: 10px;
  border: 2px solid var(--green);
  background: var(--green);
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  text-decoration: none;
  cursor: pointer;
}
.btn-ghost {
  background: #fff;
  color: var(--green);
}
.btn-block {
  display: flex;
  width: 100%;
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.btn svg {
  width: 24px;
  height: 24px;
  flex: none;
}

/* 文件／連結清單 */
.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.8rem;
}
.rows a {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  min-height: 80px;
}
.rows .ricon {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--gold-solid);
}
.rows.is-links .ricon {
  background: var(--green);
}
.rows .ricon svg {
  width: 28px;
  height: 28px;
}
.rows .rtext {
  flex: 1;
  min-width: 0;
}
.rows b {
  display: block;
  color: var(--green);
  font-size: 1.1rem;
  line-height: 1.4;
}
.rows small {
  display: block;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
}
.rows .rgo {
  flex: none;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
}

/* ---------- 問卷 ---------- */
.q {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.q.has-error {
  border: 2px solid var(--danger);
}
.q-title {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--green);
  line-height: 1.45;
}
.req {
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 700;
  margin-left: 0.3rem;
  white-space: nowrap;
}
.opt {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 400;
  margin-left: 0.3rem;
}
.stmt {
  border: 0;
  margin: 0 0 1rem;
  padding: 0;
}
.stmt:last-child {
  margin-bottom: 0;
}
.stmt legend {
  font-weight: 700;
  font-size: 1.02rem;
  padding: 0;
  margin-bottom: 0.45rem;
  line-height: 1.5;
}
/* 五個選項：手機上一個一行的大按鈕（比橫排小圓圈好按） */
.scale {
  display: grid;
  gap: 0.4rem;
}
.choice {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 52px;
  padding: 0.3rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
}
.choice input {
  width: 26px;
  height: 26px;
  margin: 0;
  accent-color: var(--green);
  flex: none;
}
.choice:has(input:checked) {
  border-color: var(--green);
  background: var(--green-tint);
  font-weight: 800;
}
.q textarea,
.q input[type="text"],
.field input,
.field textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 0.7rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
.q textarea {
  min-height: 7.5rem;
  resize: vertical;
}
.err-msg {
  color: var(--danger);
  font-weight: 700;
  margin: 0.5rem 0 0;
}
.privacy {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0 0 0.7rem;
}
.thanks {
  text-align: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.6rem 1rem;
}
.thanks b {
  display: block;
  font-size: 1.35rem;
  color: var(--green);
  margin-bottom: 0.4rem;
}

/* ---------- 後台 ---------- */
.admin-sec {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.2rem;
}
.admin-sec > h2 {
  margin: 0 0 0.3rem;
  font-size: 1.25rem;
  color: var(--green);
}
.admin-sec > p {
  margin: 0 0 0.8rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
}
.switch-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--border);
}
.switch-row:first-of-type {
  border-top: 0;
}
.switch-row .sw-name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  line-height: 1.4;
}
.switch-row .sw-state {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
}
.sw-state.on {
  color: var(--green);
}
.sw-state.off {
  color: #666;
}
.switch-row .btn {
  flex: none;
  min-width: 6.2rem;
}
.btn-off {
  background: #fff;
  color: #555;
  border-color: #888;
}
.field {
  margin-bottom: 0.6rem;
}
.field label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.edit-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem;
  margin-bottom: 0.7rem;
  background: #fbfaf7;
}
.edit-tools {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.edit-tools button {
  font: inherit;
  font-size: 0.9rem;
  min-height: 44px;
  padding: 0.2rem 0.8rem;
  border-radius: 8px;
  border: 1px solid #999;
  background: #fff;
  cursor: pointer;
}
.edit-tools .del {
  color: var(--danger);
  border-color: var(--danger);
  margin-left: auto;
}
.status-line {
  min-height: 1.6em;
  font-weight: 700;
  margin: 0.5rem 0 0;
}
.status-line.ok {
  color: var(--green);
}
.status-line.bad {
  color: var(--danger);
}
.resp {
  border-top: 1px solid var(--border);
  padding: 0.8rem 0;
  font-size: 0.95rem;
}
.resp.is-hidden {
  opacity: 0.6;
}
.resp-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.8rem;
  font-weight: 700;
}
.resp p {
  margin: 0.3rem 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.scores {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.9rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.avg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.avg-table td,
.avg-table th {
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.2rem;
  text-align: left;
}
.avg-table td.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
[hidden] {
  display: none !important;
}

@media (max-width: 360px) {
  html {
    font-size: 18px;
  }
  .hero h1 {
    font-size: 1.9rem;
  }
}

/* 片語不拆行：整段放不下時才在片語之間換行（手機沒有中文斷詞，不包起來會在詞中間斷） */
.nb {
  display: inline-block;
  font-style: normal;
}
/* 捲到沒填的題目時，不要被上方固定的標題列蓋住 */
.q {
  scroll-margin-top: 76px;
}

/* 延伸資源頁的分類標題與 YouTube 內嵌 */
.group-h {
  margin: 1.6rem 0 0.7rem;
  padding-left: 0.6rem;
  border-left: 5px solid var(--gold-solid);
  color: var(--green);
  font-size: 1.25rem;
  line-height: 1.4;
}
.yt-frame {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  background: #000;
}

/* 尚未開放的文件：灰色、不能按；說明什麼時候會開 */
.rowlocked {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  background: #eeeae2;
  border: 1px dashed #aaa;
  border-radius: 12px;
  color: #555;
  min-height: 80px;
}
.rowlocked .ricon {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #8a8a8a;
}
.rowlocked .ricon svg {
  width: 26px;
  height: 26px;
}
.rowlocked .rtext {
  flex: 1;
  min-width: 0;
}
.rowlocked b {
  display: block;
  font-size: 1.1rem;
  line-height: 1.4;
}
.rowlocked small {
  display: block;
  font-size: 0.9rem;
  line-height: 1.45;
}
.rowlocked .rgo {
  flex: none;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}
.locknote {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
  color: #555;
}

/* 首頁頁首第三行「相關資料」 */
.hero-third {
  margin: 0.2rem 0 0;
  color: var(--gold);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
}
