/* ====================================================================
 * 四湖參天宮 · 分靈寶圖
 * 設計：「墨・硃・金」宮廟編輯風
 *   墨黑為地、硃砂為主、古金為輔、宣紙米白為內容面
 *   明體大字 × 對聯直書 × 印章 × 回紋金線
 * ==================================================================== */

:root {
  --ink:        #16100d;   /* 墨黑（暖） */
  --ink-2:      #1f1712;
  --ink-3:      #2a201a;
  --cinnabar:   #c4261d;   /* 硃砂 */
  --cinnabar-2: #d7392b;
  --cinnabar-dp:#8f160f;
  --gold:       #c4a052;   /* 古金 */
  --gold-lt:    #e6cd83;
  --gold-dk:    #9c7d36;
  --paper:      #f4ecdb;   /* 宣紙 */
  --paper-2:    #ebdcc2;
  --paper-3:    #e0cda9;
  --paper-line: #d2bd96;
  --ink-on-paper:#2c2118;
  --muted:      #6b563a;   /* 加深以達 WCAG AA：宣紙底 5.9:1、深米底 5.2:1（原 #8a7355 僅 3.8/3.3） */
  --ok:         #3f7d4e;

  --serif: "Noto Serif TC", "Songti TC", "STSong", serif;
  --sans:  "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
  --latin: "Cormorant Garamond", "Noto Serif TC", serif;

  --shadow:  0 18px 50px -18px rgba(10,4,2,.6);
  --shadow-s: 0 8px 24px -12px rgba(10,4,2,.5);
  --radius: 4px;       /* 偏方正，匾額感 */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; background: var(--paper); }
body {
  font-family: var(--sans);
  color: var(--ink-on-paper);
  background: transparent;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* 全頁背景畫：關聖帝君山水宣紙圖。固定不捲動，內容浮於其上。
   手機用直幅、平板／電腦用橫幅；未放圖時自動回退為純宣紙底（html 背景）。 */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--paper) center top / cover no-repeat;
  background-image: url("../assets/bg-tall.jpg");   /* 手機：直幅 */
}
@media (min-width: 768px) {
  body::before { background-image: url("../assets/bg-wide.jpg"); }  /* 平板／電腦：橫幅 */
}
.only-pc { display: inline; }
img { display: block; max-width: 100%; }

/* 顆粒 / 宣紙質感疊層 */
.grain {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none; opacity: .045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- 共用：印章序號標題 ---------- */
.sec-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.8rem; }
.sec-ord {
  flex: none; width: 56px; height: 56px; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 900; font-size: 1.7rem; color: #fff;
  background: var(--cinnabar);
  box-shadow: inset 0 0 0 2px var(--cinnabar), inset 0 0 0 4px #fff3, 0 4px 14px -4px var(--cinnabar-dp);
  border-radius: 6px; letter-spacing: 0;
}
.sec-titles h2 {
  font-family: var(--serif); font-weight: 900; font-size: clamp(1.4rem, 3.5vw, 2rem);
  color: var(--ink); letter-spacing: 4px; line-height: 1.2;
}
.sec-titles p { color: var(--muted); font-size: .9rem; margin-top: .2rem; }

/* ---------- 按鈕 ---------- */
.btn {
  font-family: var(--sans); font-size: .95rem; font-weight: 700; cursor: pointer;
  padding: .8rem 1.7rem; border: none; letter-spacing: 2px;
  transition: transform .18s, box-shadow .25s, background .25s, color .2s;
  position: relative;
}
.btn:active { transform: translateY(1px); }
/* 硃漆描金：硃砂直向漆色＋金線邊框＋上緣描金（廟宇匾額／漆牌質感，非平塗 web 紅） */
.btn-primary {
  color: #fff; background: linear-gradient(180deg, var(--cinnabar), var(--cinnabar-dp));
  box-shadow: inset 0 0 0 1.5px var(--gold-dk), inset 0 1px 0 rgba(255,244,230,.28), 0 10px 26px -12px var(--cinnabar-dp);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--cinnabar-2), var(--cinnabar)); box-shadow: inset 0 0 0 1.5px var(--gold-lt), inset 0 1px 0 rgba(255,244,230,.4), 0 14px 30px -10px var(--cinnabar-dp); }
.btn-ghost {
  color: var(--gold-lt); background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--gold-dk);
}
.btn-ghost:hover { color: var(--ink); background: var(--gold-lt); box-shadow: inset 0 0 0 1.5px var(--gold-lt); }
.btn-block { width: 100%; }
.btn-sm { padding: .5rem 1.1rem; font-size: .85rem; letter-spacing: 1px; }

/* on-paper sections use darker ghost button（淺宣紙底上：硃砂字＋金框，hover 反白硃底） */
.feature-section .btn-ghost,
.almanac-control .btn-ghost,
.panel .btn-ghost,
.admin-shell .btn-ghost { color: var(--cinnabar); box-shadow: inset 0 0 0 1.5px var(--gold-dk); }
.feature-section .btn-ghost:hover,
.panel .btn-ghost:hover,
.admin-shell .btn-ghost:hover { color: #fff; background: var(--cinnabar); box-shadow: inset 0 0 0 1.5px var(--cinnabar); }

/* ====================================================================
 * 頁首
 * ==================================================================== */
.site-header {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 1rem;
  padding: .55rem 1.4rem;
  background: linear-gradient(180deg, var(--ink-2), var(--ink));
  border-bottom: 1px solid #00000055;
  box-shadow: 0 1px 0 rgba(196,160,82,.4), 0 6px 24px -10px #000;
}
.brand { display: flex; align-items: center; gap: .8rem; margin-right: auto; text-decoration: none; }
.emblem { width: 46px; height: 46px; border-radius: 50%; box-shadow: 0 0 0 1px #0006, 0 3px 10px -3px #000; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-family: var(--serif); font-weight: 900; font-size: 1.18rem; color: var(--paper); letter-spacing: 4px; }
.brand-text em { font-style: normal; font-size: .68rem; color: var(--gold); letter-spacing: 2px; }

.top-nav { display: flex; gap: .15rem; }
.nav-link {
  position: relative; color: #d8c7a8; text-decoration: none;
  padding: .5rem .85rem; font-size: .92rem; letter-spacing: 2px; transition: color .2s;
}
.nav-link::after {
  content: ""; position: absolute; left: .85rem; right: .85rem; bottom: .35rem; height: 1.5px;
  background: var(--gold-lt); transform: scaleX(0); transform-origin: left; transition: transform .25s;
}
.nav-link:hover { color: #fff; }
.nav-link:hover::after, .nav-link.active::after { transform: scaleX(1); }
.nav-link.active { color: var(--gold-lt); }

.nav-toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 6px; }
.nav-toggle span { width: 24px; height: 2px; background: var(--gold-lt); transition: .25s; }

/* ====================================================================
 * 主視覺
 * ==================================================================== */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% -10%, #2a1d15 0%, var(--ink) 55%, #0d0907 100%);
  color: var(--paper);
  padding: clamp(3rem, 8vw, 6rem) 1.4rem clamp(3rem, 7vw, 5.5rem);
  border-bottom: 2px solid var(--gold-dk);
}
.hero-glow {
  position: absolute; left: 50%; top: 36%; width: 760px; height: 760px; transform: translate(-50%,-50%);
  background: radial-gradient(circle, rgba(196,38,29,.34), rgba(196,38,29,0) 62%);
  pointer-events: none;
}
.hero::after { /* 回紋上緣裝飾 */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 8px;
  background:
    repeating-linear-gradient(90deg, var(--gold-dk) 0 14px, transparent 14px 28px);
  opacity: .5;
}
.hero-inner { position: relative; z-index: 2; max-width: 760px; margin: 0 auto; text-align: center; }
.hero-emblem {
  width: clamp(96px, 16vw, 138px); height: auto; margin: 0 auto 1.6rem;
  animation: emblemIn 1s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes emblemIn { from { opacity: 0; transform: scale(.8) rotate(-12deg); } }

.hero-kicker {
  font-size: .82rem; letter-spacing: 6px; color: var(--gold); text-transform: none;
  margin-bottom: .6rem; animation: rise .8s .1s both;
}
.hero-title {
  font-family: var(--serif); font-weight: 900;
  font-size: clamp(3.2rem, 12vw, 6rem); line-height: 1; letter-spacing: 10px;
  color: var(--paper); text-indent: 10px;
  text-shadow: 0 2px 0 var(--cinnabar-dp), 0 0 30px rgba(196,38,29,.3);
  animation: rise .9s .2s both;
}
.hero-lead { margin: 1.4rem auto 2rem; color: #e3d3b6; font-size: 1.02rem; max-width: 30em; animation: rise .9s .35s both; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; animation: rise .9s .5s both; }

.hero-stats {
  display: flex; align-items: center; justify-content: center; gap: 1.8rem;
  margin-top: 3rem; animation: rise .9s .65s both;
}
.hero-stats i { width: 1px; height: 42px; background: linear-gradient(var(--gold-dk), transparent); display: block; }
.hero-stats div { display: flex; flex-direction: column; align-items: center; min-width: 84px; }
.hero-stats strong { font-family: var(--latin); font-weight: 600; font-size: 2.8rem; color: var(--gold-lt); line-height: 1; }
.hero-stats span { font-size: .76rem; color: #cbb893; letter-spacing: 2px; margin-top: .35rem; }

@keyframes rise { from { opacity: 0; transform: translateY(18px); } }

/* 側邊對聯直書 */
.couplet {
  position: absolute; top: 50%; transform: translateY(-50%);
  writing-mode: vertical-rl; text-orientation: upright;
  font-family: var(--serif); font-weight: 700; font-size: 1.3rem; letter-spacing: 8px;
  color: var(--gold); opacity: .5; z-index: 2;
  padding: 1rem .5rem; border: 1px solid var(--gold-dk); border-radius: 2px;
  background: linear-gradient(180deg, rgba(143,22,15,.25), rgba(143,22,15,.05));
}
.couplet-l { left: 3.5%; }
.couplet-r { right: 3.5%; }

/* ====================================================================
 * 分靈地圖
 * ==================================================================== */
.map-section {
  display: grid; grid-template-columns: 410px 1fr; min-height: 74vh;
  background: var(--ink);
}
.panel {
  background: linear-gradient(180deg, var(--paper), var(--paper-2));
  display: flex; flex-direction: column; max-height: calc(100vh - 64px);
  border-right: 3px solid var(--gold-dk);
}
.sec-head-inset { margin: 0; padding: 1.3rem 1.3rem 1rem; align-items: center; }
.sec-head-inset .sec-ord { width: 46px; height: 46px; font-size: 1.4rem; }
.sec-head-inset h2 { font-size: 1.4rem; letter-spacing: 3px; }
.result-count { color: var(--muted); font-size: .82rem; margin-top: .2rem; }

.filters { padding: .3rem 1.3rem 1rem; border-bottom: 1px solid var(--paper-line); }
#searchInput {
  width: 100%; padding: .7rem .9rem; font-family: var(--sans); font-size: .95rem;
  border: 1px solid var(--paper-line); background: #fffdf8; color: var(--ink);
  border-radius: var(--radius);
}
#searchInput:focus { outline: none; border-color: var(--cinnabar); box-shadow: 0 0 0 3px rgba(196,38,29,.12); }

.chip-group { display: flex; gap: .4rem; margin-top: .7rem; flex-wrap: wrap; }
.chip {
  font-family: var(--sans); font-size: .82rem; cursor: pointer; letter-spacing: 1px;
  padding: .35rem .9rem; border-radius: 2px;
  border: 1px solid var(--paper-line); background: #fffdf8; color: var(--ink-on-paper); transition: all .18s;
}
.chip:hover { border-color: var(--gold-dk); }
/* 作用態加內緣印泥細線，與印章 .seal 同語彙（讀作「蓋章的牌」） */
.chip.active { background: var(--cinnabar); color: #fff; border-color: var(--cinnabar); box-shadow: 0 4px 12px -6px var(--cinnabar-dp), inset 0 0 0 1.5px rgba(255,244,230,.35); }

.branch-list { list-style: none; overflow-y: auto; flex: 1; padding: .6rem; }
.branch-item {
  position: relative; padding: .85rem 1rem; cursor: pointer; border-radius: var(--radius);
  border: 1px solid transparent; transition: background .15s, border-color .15s; margin-bottom: .2rem;
}
.branch-item::before {
  content: ""; position: absolute; left: 0; top: 12%; bottom: 12%; width: 3px; background: transparent; transition: background .15s;
}
.branch-item:hover { background: #fffdf8; }
.branch-item.active { background: #fffdf8; border-color: var(--paper-line); box-shadow: var(--shadow-s); }
.branch-item.active::before { background: var(--cinnabar); }
.bi-top { display: flex; align-items: center; gap: .5rem; }
.bi-name { font-family: var(--serif); font-weight: 700; color: var(--ink); font-size: 1.02rem; }
/* 場所類別以圖示牌印呈現（廟＝硃印白圖、民宅＝墨印金圖），與地圖標記同語彙；文字保留於 aria-label */
.bi-badge { width: 24px; height: 24px; padding: 0; border-radius: 3px; flex: none; display: inline-grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(255,244,230,.3); }
.bi-badge-ic { width: 15px; height: 15px; }
.badge-temple { background: var(--cinnabar); } .badge-temple .bi-badge-ic { color: #fff; }
.badge-hall   { background: var(--cinnabar); } .badge-hall .bi-badge-ic { color: #fff; }
.badge-home   { background: var(--ink-3); }    .badge-home .bi-badge-ic { color: var(--gold-lt); }
.badge-org    { background: var(--gold-dk); }   .badge-org .bi-badge-ic { color: #fff; }
.bi-verified { font-size: .68rem; color: var(--gold-dk); margin-left: auto; flex: none; letter-spacing: 1px; }
.bi-verified.pending { color: #b07b2a; }
.bi-addr { font-size: .82rem; color: #6f5d44; margin-top: .3rem; }
/* 地址定位小圖（取代 📍）：描邊、與文字基線對齊 */
.addr-ic { width: .92em; height: .92em; vertical-align: -.14em; margin-right: .28em; color: var(--gold-dk); flex: none; }
.pop-addr .addr-ic { color: var(--cinnabar); }
.bi-meta { font-size: .76rem; color: var(--muted); margin-top: .1rem; }

/* 神龕／匾額式宗教外框（DESIGN.md §6.4）：硃砂漆框帶＋金線雙框＋匾額四角＋頂匾 */
.map-wrap { position: relative; padding: 13px; background: linear-gradient(180deg, var(--cinnabar), var(--cinnabar-dp)); }
#map { width: 100%; height: 100%; min-height: 62vh; background: var(--ink); border: 1.5px solid var(--gold); border-radius: 2px; }
.map-frame { position: absolute; inset: 6px; border: 1.5px solid var(--gold-lt); border-radius: 3px; pointer-events: none; z-index: 450; }
.map-corner { position: absolute; width: 15px; height: 15px; border: 2px solid var(--gold-lt); }
.map-corner.tl { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.map-corner.tr { top: -1px; right: -1px; border-left: none; border-bottom: none; }
.map-corner.bl { bottom: -1px; left: -1px; border-right: none; border-top: none; }
.map-corner.br { bottom: -1px; right: -1px; border-left: none; border-top: none; }
/* 頂匾：直接掛在 .map-wrap 上緣中央，z-index 高於地圖層；置中以避開左上縮放鈕 */
.map-plaque {
  position: absolute; top: 4px; left: 50%; transform: translateX(-50%); z-index: 800;
  font-family: var(--serif); font-weight: 900; font-size: .82rem; letter-spacing: 4px;
  color: var(--gold-lt); background: linear-gradient(180deg, var(--cinnabar-dp), var(--ink-3));
  padding: .26rem .9rem .3rem; border: 1.5px solid var(--gold); border-top: none;
  border-radius: 0 0 5px 5px; box-shadow: 0 4px 9px rgba(0,0,0,.4); white-space: nowrap; pointer-events: none;
}

/* 地圖標記：廟方自製圖檔（完整水滴形＋圖示，尖端朝下對齊點位）（DESIGN.md §6.3） */
.pin-img-wrap { position: relative; }
.pin-img { display: block; filter: drop-shadow(0 3px 5px rgba(0,0,0,.4)); }
/* 廟名名牌：掛於牌印下方，宣紙底＋墨字明體，金細邊，居中對齊點位 */
.pin-label {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 5px;
  white-space: nowrap; font-family: var(--serif); font-weight: 700; font-size: .72rem;
  line-height: 1; letter-spacing: .5px; color: var(--ink-on-paper);
  background: linear-gradient(180deg, #fdf7e6, #f3e7cb);
  padding: .2rem .42rem; border-radius: 3px; border: 1px solid var(--gold-dk);
  box-shadow: 0 2px 5px rgba(0,0,0,.32); pointer-events: none;
}
.pin-label.is-origin { font-size: .78rem; color: var(--cinnabar-dp); border-color: var(--gold-dk); background: linear-gradient(180deg, #fff7e6, #f1e2c0); }
.leaflet-popup-content-wrapper { border-radius: var(--radius); border-top: 3px solid var(--gold); }
.leaflet-popup-content { font-family: var(--sans); }

/* Leaflet 控制項改宮廟語彙（去除預設白底模板感）：宣紙金框＋明體硃砂 ＋／－ */
.leaflet-control-zoom.leaflet-bar {
  border: 1px solid var(--gold-dk); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 4px 12px -4px rgba(60,40,16,.45);
}
.map-wrap .leaflet-control-zoom a {
  width: 36px; height: 36px; line-height: 36px;
  background: linear-gradient(180deg, #fffdf8, #f3e9d2); color: var(--cinnabar);
  font-family: var(--serif); font-weight: 900; font-size: 1.2rem;
  border-bottom: 1px solid var(--gold-dk); transition: background .15s, color .15s;
}
.leaflet-control-zoom a:last-child { border-bottom: none; }
.leaflet-control-zoom a:hover { background: var(--cinnabar); color: #fff; }
.leaflet-control-zoom a:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: -2px; }
.leaflet-control-zoom a.leaflet-disabled { color: var(--muted); opacity: .5; background: #f3e9d2; }
.leaflet-control-attribution {
  background: rgba(244,236,219,.82) !important; color: var(--muted) !important;
  font-family: var(--sans); font-size: .68rem; border-top-left-radius: var(--radius);
}
.leaflet-control-attribution a { color: var(--cinnabar-dp) !important; }
/* 圖釘 hover 微浮（MOTION_INTENSITY 3）；清單列點按回饋 */
.pin-img { transition: transform .15s ease, filter .15s ease; }
.pin-img-wrap:hover .pin-img { transform: translateY(-2px) scale(1.04); filter: drop-shadow(0 6px 9px rgba(0,0,0,.5)); }
.branch-item:active { transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) {
  .pin-img, .branch-item { transition: none; }
  .pin-img-wrap:hover .pin-img { transform: none; }
  .branch-item:active { transform: none; }
}
.pop-name { font-family: var(--serif); font-weight: 900; color: var(--cinnabar); font-size: 1.05rem; }
.pop-deity { color: var(--gold-dk); font-size: .82rem; margin: .15rem 0; }
.pop-addr { font-size: .82rem; color: #5a4a36; }
.pop-note { font-size: .8rem; color: #6a5942; margin-top: .35rem; }

/* 叢集標記（金朱主題） */
.cluster {
  width: 100%; height: 100%; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 900; color: #fff;
  border: 2px solid var(--paper); box-shadow: 0 4px 12px rgba(0,0,0,.45);
}
.cluster span { line-height: 1; }
.cluster.c-sm { background: radial-gradient(circle at 35% 30%, #d7392b, var(--cinnabar)); font-size: .85rem; }
.cluster.c-md { background: radial-gradient(circle at 35% 30%, #b8923f, var(--gold-dk)); font-size: .95rem; }
.cluster.c-lg { background: radial-gradient(circle at 35% 30%, #3a2a1e, var(--ink)); color: var(--gold-lt); font-size: 1rem; box-shadow: 0 0 0 4px rgba(196,160,82,.35), 0 6px 16px rgba(0,0,0,.5); }

/* 地區下拉 */
.region-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .7rem; }
.region-row select {
  width: 100%; padding: .55rem .6rem; font-family: var(--sans); font-size: .88rem;
  border: 1px solid var(--paper-line); background: #fffdf8; color: var(--ink); border-radius: var(--radius);
  appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--gold-dk) 50%), linear-gradient(135deg, var(--gold-dk) 50%, transparent 50%);
  background-position: calc(100% - 15px) center, calc(100% - 10px) center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.region-row select:focus { outline: none; border-color: var(--cinnabar); }
.region-row select:disabled { opacity: .5; cursor: not-allowed; }

.vp-toggle { display: flex; align-items: center; gap: .45rem; margin-top: .7rem; font-size: .8rem; color: var(--muted); cursor: pointer; }
.vp-toggle input { accent-color: var(--cinnabar); width: 15px; height: 15px; }

/* ── 分布概覽：依範圍列出國家／縣市＋等比長條，點列縮放＋篩選（DESIGN.md §6.2）── */
.dist-overview { padding: .3rem 1.3rem .6rem; border-bottom: 1px solid var(--paper-line); }
.dist-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding-bottom: .4rem; margin-bottom: .15rem; border-bottom: 1.5px solid var(--paper-line);
}
.dist-title { font-family: var(--serif); font-weight: 900; font-size: 1.02rem; color: var(--ink); letter-spacing: 2px; }
.dist-sub { font-size: .78rem; color: var(--muted); }
.dist-list { list-style: none; }
.dist-row {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name count" "bar bar";
  gap: .15rem .6rem; align-items: center; min-height: 44px; padding: .45rem .5rem;
  border-bottom: 1px solid var(--paper-line); border-radius: var(--radius);
  cursor: pointer; transition: background .12s ease, transform .12s ease;
}
/* hover/focus：背景僅淡化至 --paper-2（--muted 仍 5.2:1 過 AA），硃砂左緣作為主要可點提示 */
.dist-row:hover, .dist-row:focus-visible { background: var(--paper-2); box-shadow: inset 3px 0 0 var(--cinnabar); outline: 2px solid transparent; }
.dist-row:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: -2px; }
.dist-row:hover .dist-rname { color: var(--cinnabar-dp); }
.dist-row:active { transform: translateX(1px); }
.dist-name { grid-area: name; display: flex; align-items: center; gap: .5rem; font-weight: 500; font-size: .95rem; color: var(--ink-on-paper); }
/* 排名「朱印」：方印＋印泥內線，重用 .seal 印章語彙；首位金印標主導（DESIGN.md §6.2） */
.dist-rank {
  display: inline-grid; place-items: center; flex: none;
  width: 1.55em; height: 1.55em; font-family: var(--serif); font-weight: 900;
  font-size: .82rem; line-height: 1; color: #fff; background: var(--cinnabar);
  border-radius: 2px; box-shadow: inset 0 0 0 1.5px rgba(255,244,230,.4);
  font-variant-numeric: tabular-nums;
}
.dist-row.is-top .dist-rank { background: var(--gold); color: var(--ink); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.45); }
.dist-row.is-unclassified .dist-rank { background: transparent; color: var(--muted); box-shadow: none; }
.dist-rname { font-weight: 500; }
.unclassified-tag { font-size: .7rem; color: var(--muted); font-weight: 400; }
.dist-count { grid-area: count; font-family: var(--serif); font-weight: 900; font-size: 1.05rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.dist-count small { font-family: var(--sans); font-size: .7rem; font-weight: 400; color: var(--muted); }
/* 長條：共用零基線、長度線性正比於筆數；實心硃砂填色於紙線軌道（去漸層，全段過 AA 非文字 3:1） */
.dist-bar { grid-area: bar; height: 7px; margin-top: .15rem; background: var(--paper-line); border-radius: 2px; overflow: hidden; }
.dist-bar > span { display: block; height: 100%; background: var(--cinnabar); border-radius: 2px; box-shadow: inset 0 1px 0 rgba(255,255,255,.22); }
/* 未分類桶：實心硃砂深（5:1 vs 軌道）＋（無縣市資料）文字標，色彩非唯一表意（§10） */
.dist-row.is-unclassified .dist-bar > span { background: var(--cinnabar-dp); }
.tap-hint { margin-left: auto; color: var(--muted); opacity: .55; align-self: center; }
.dist-row:hover .tap-hint, .dist-row:focus-visible .tap-hint { color: var(--cinnabar); opacity: 1; }
.dist-more {
  width: 100%; min-height: 44px; margin: .4rem 0 .2rem; background: transparent;
  border: 1px solid var(--gold-dk); border-radius: var(--radius); cursor: pointer;
  font-family: var(--sans); font-size: .88rem; color: var(--cinnabar-dp); letter-spacing: 1px;
}
.dist-more:hover { background: var(--paper); }
@media (prefers-reduced-motion: reduce) { .dist-row { transition: none; } }
/* 手機加大，照顧長輩可讀性 */
@media (max-width: 900px) {
  .dist-title { font-size: 1.2rem; }
  .dist-sub { font-size: .92rem; }
  .dist-name { font-size: 1.12rem; }
  .dist-rank { font-size: .9rem; }
  .dist-count { font-size: 1.25rem; }
  .dist-count small { font-size: .85rem; }
  .dist-row { min-height: 50px; }
  .dist-more { font-size: 1rem; }
}

/* 分頁器 */
.pager {
  display: flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .6rem; border-top: 1px solid var(--paper-line); flex-wrap: wrap;
}
.pager:empty { display: none; }
.pg-btn {
  min-width: 32px; height: 32px; padding: 0 .4rem; cursor: pointer;
  border: 1px solid var(--paper-line); background: #fffdf8; color: var(--cinnabar);
  font-family: var(--serif); font-size: 1rem; border-radius: 2px; transition: .15s;
}
.pg-btn:hover:not(:disabled) { background: var(--cinnabar); color: #fff; border-color: var(--cinnabar); }
.pg-btn:disabled { opacity: .35; cursor: default; }
.pg-info { font-size: .76rem; color: var(--muted); margin: 0 .5rem; letter-spacing: .5px; }

/* ====================================================================
 * 功能區塊（點燈／農民曆／關於）
 * ==================================================================== */
.feature-section, .about { padding: clamp(3rem, 7vw, 5rem) 1.4rem; position: relative; }
/* 半透明宣紙紗：讓底圖透出，又保留標題／內文對比。
   全部內容頁統一此treatment（求籤／訂單比照農民曆），整站背景一致透出。 */
.feature-section, .feature-section.alt, .about { background: linear-gradient(180deg, rgba(235,220,194,.66), rgba(244,236,219,.5)); }
.feature-inner { max-width: 820px; margin: 0 auto; }

/* 查詢卡片（匾額感＋四角飾） */
.query-card {
  position: relative; max-width: 480px; margin: 0 auto;
  background: linear-gradient(180deg, #fffdf8, var(--paper));
  border: 1px solid var(--paper-line); border-top: 4px solid var(--cinnabar);
  padding: 2rem 1.8rem; box-shadow: var(--shadow);
}
.card-corner { position: absolute; width: 16px; height: 16px; border: 2px solid var(--gold-dk); }
.card-corner.tl { top: 8px; left: 8px; border-right: none; border-bottom: none; }
.card-corner.tr { top: 8px; right: 8px; border-left: none; border-bottom: none; }
.card-corner.bl { bottom: 8px; left: 8px; border-right: none; border-top: none; }
.card-corner.br { bottom: 8px; right: 8px; border-left: none; border-top: none; }

.seg-control { display: flex; background: var(--paper-2); padding: 4px; border-radius: 2px; margin-bottom: 1.3rem; border: 1px solid var(--paper-line); }
.seg {
  flex: 1; border: none; background: none; font-family: var(--sans); cursor: pointer;
  padding: .6rem; border-radius: 2px; font-size: .9rem; color: var(--muted); font-weight: 700; letter-spacing: 2px; transition: all .2s;
}
.seg.active { background: var(--cinnabar); color: #fff; box-shadow: 0 4px 12px -6px var(--cinnabar-dp); }

.field { display: block; margin-bottom: 1.1rem; font-size: .82rem; color: var(--muted); font-weight: 700; letter-spacing: 1px; }
.field > span { display: block; margin-bottom: .4rem; }
.field input {
  width: 100%; padding: .7rem .85rem; font-family: var(--sans); font-size: .95rem; font-weight: 400;
  border: 1px solid var(--paper-line); background: #fffdf8; color: var(--ink); border-radius: var(--radius);
}
.field input:focus { outline: none; border-color: var(--cinnabar); box-shadow: 0 0 0 3px rgba(196,38,29,.12); }

.captcha-row { display: grid; grid-template-columns: 170px auto; gap: .55rem .8rem; align-items: center; }
.captcha-row canvas { border: 1px solid var(--paper-line); border-radius: 2px; cursor: pointer; background: var(--paper); }
.link-btn { background: none; border: none; color: var(--cinnabar); cursor: pointer; font-size: .8rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; padding: 0; justify-self: start; }
.captcha-row input { grid-column: 1 / -1; }

.form-error { color: var(--cinnabar); font-size: .85rem; min-height: 1.2em; margin-bottom: .7rem; font-weight: 700; }

/* 訂單結果 */
.order-results { margin-top: 2rem; }
.results-head { font-family: var(--serif); font-size: .95rem; color: var(--muted); margin-bottom: 1rem; letter-spacing: 1px; }
.order-card {
  position: relative; background: linear-gradient(180deg, #fffdf8, var(--paper));
  border: 1px solid var(--paper-line); border-left: 4px solid var(--gold);
  padding: 1.5rem; margin-bottom: 1.2rem; box-shadow: var(--shadow-s);
}
.oc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.oc-id { font-family: var(--latin); font-weight: 600; color: var(--cinnabar); font-size: 1.25rem; letter-spacing: 1px; }
.oc-name { font-family: var(--serif); font-size: .92rem; color: var(--ink); margin-top: .2rem; }
.status-badge { flex: none; font-size: .74rem; font-weight: 700; padding: .3rem .8rem; border-radius: 2px; color: #fff; letter-spacing: 1px; }
.status-badge.ok   { background: var(--ok); }
.status-badge.paid { background: var(--gold-dk); }
.status-badge.due  { background: #b15a25; }
.oc-meta { display: flex; flex-wrap: wrap; gap: .35rem 1.4rem; font-size: .82rem; color: var(--muted); margin: .9rem 0; }
.lamp-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.lamp-table th, .lamp-table td { text-align: left; padding: .55rem .4rem; border-bottom: 1px solid var(--paper-line); }
.lamp-table th { color: var(--gold-dk); font-size: .78rem; font-weight: 700; letter-spacing: 1px; }
.lamp-table td { color: var(--ink-on-paper); }
.lamp-table .center { text-align: center; }
.oc-foot { display: flex; justify-content: space-between; align-items: baseline; margin-top: 1rem; padding-top: .9rem; border-top: 2px solid var(--paper-2); }
.oc-foot span { color: var(--muted); font-size: .85rem; }
.oc-foot strong { font-family: var(--latin); font-weight: 600; color: var(--cinnabar); font-size: 1.45rem; }
.oc-tip { margin-top: .9rem; font-size: .82rem; color: #9a4a1c; background: #f6e3d2; padding: .6rem .8rem; border-left: 3px solid #b15a25; border-radius: 2px; }

/* ====================================================================
 * 農民曆（通書頁感）
 * ==================================================================== */
/* 月份導覽列 */
.cal-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .7rem; max-width: 560px; margin-left: auto; margin-right: auto; }
.cal-nav-btn {
  min-width: 44px; min-height: 44px; border-radius: 50%; border: 1px solid var(--gold-dk);
  background: linear-gradient(180deg, #fffdf8, var(--paper)); color: var(--cinnabar);
  font-size: 1.5rem; line-height: 1; cursor: pointer; display: grid; place-items: center;
  font-family: var(--serif); transition: .18s;
}
.cal-nav-btn:hover { background: var(--cinnabar); color: #fff; border-color: var(--cinnabar); }
.cal-nav-btn:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 2px; }
.cal-title-wrap { display: flex; align-items: center; gap: .6rem; }
.cal-title { font-family: var(--serif); font-weight: 900; font-size: 1.28rem; color: var(--ink); letter-spacing: 3px; }
.cal-today-btn {
  min-height: 44px; padding: 0 .95rem; border-radius: var(--radius); border: 1px solid var(--gold-dk);
  background: linear-gradient(180deg, #fffdf8, var(--paper)); color: var(--cinnabar);
  font-family: var(--serif); font-weight: 700; font-size: 1.05rem; letter-spacing: 2px; cursor: pointer; transition: .18s;
}
.cal-today-btn:hover { background: var(--cinnabar); color: #fff; border-color: var(--cinnabar); }
.cal-today-btn:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 2px; }

/* 月曆格線 */
.cal {
  background: linear-gradient(180deg, #fffdf8, var(--paper)); border: 1px solid var(--paper-line);
  border-radius: var(--radius); box-shadow: var(--shadow-s); overflow: hidden; margin: 0 auto 1.6rem;
  max-width: 560px;
}
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--paper-2); border-bottom: 1px solid var(--paper-line); }
.cal-week span { text-align: center; padding: .5rem 0; font-family: var(--serif); font-weight: 700; font-size: .9rem; color: var(--muted); letter-spacing: 1px; }
.cal-week span.sun { color: var(--cinnabar); }
.cal-week span.sat { color: var(--gold-dk); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell {
  position: relative; min-height: 56px; padding: .35rem .2rem .3rem; border-right: 1px solid var(--paper-line);
  border-bottom: 1px solid var(--paper-line); background: transparent; cursor: pointer; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .05rem;
  transition: background .15s; font-family: inherit; -webkit-tap-highlight-color: transparent; width: 100%;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.is-selectable:hover { background: var(--paper-2); }
.cal-cell:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: -2px; z-index: 2; }
.cal-solar { font-family: var(--serif); font-weight: 700; font-size: 1.28rem; line-height: 1; color: var(--ink-on-paper); }
.cal-lunar { font-family: var(--serif); font-size: .74rem; color: var(--muted); line-height: 1.2; }
.cal-lunar.is-first { color: var(--cinnabar-dp); font-weight: 700; }

/* 節氣：硃色角標，避免與選中滿底衝突 */
.cal-term {
  font-family: var(--serif); font-weight: 700; font-size: .66rem; letter-spacing: .5px; color: #fff;
  background: var(--cinnabar); border-radius: 2px; padding: .04rem .28rem; margin-top: .06rem;
}

/* 他月補位日：灰階、非互動（不可點，避免誤觸切月的困惑），文字仍達 AA 對比 */
.cal-cell.is-other {
  cursor: default; background: repeating-linear-gradient(135deg, transparent 0 6px, var(--paper-2) 6px 12px);
}
.cal-cell.is-other .cal-solar,
.cal-cell.is-other .cal-lunar { color: var(--muted); }

/* 今日：金框＋「今」字（冗餘：框為非文字 3:1 主要線索，字為次要可讀線索） */
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--gold-dk); }
.cal-cell.is-today::after {
  content: "今"; position: absolute; top: 3px; right: 4px; font-family: var(--serif); font-weight: 900;
  font-size: .62rem; color: var(--cinnabar-dp); line-height: 1;
}

/* 選中：硃底白字（冗餘：滿底反轉＋內緣印泥線＋ aria-current，狀態不只靠色） */
.cal-cell.is-sel {
  background: linear-gradient(180deg, var(--cinnabar), var(--cinnabar-dp));
  box-shadow: inset 0 0 0 1.5px rgba(255,244,230,.35);
}
.cal-cell.is-sel .cal-solar,
.cal-cell.is-sel .cal-lunar { color: #fff; }
.cal-cell.is-sel .cal-term { background: #fff; color: var(--cinnabar-dp); }

/* 今日＋選中同格：兩態必須同時可辨。硃底白字（選中）＋金亮外框（今日）＋內緣印泥線，
   三層 box-shadow 併存不互相覆蓋（單一 .is-sel／.is-today 各自的 box-shadow 會互相蓋掉，
   金框恰在兩態重合時消失 → DW-1.2 Critical）。金框於深硃底改用 --gold-lt
   （對 --cinnabar-dp 5.86:1，過非文字 3:1；--gold-dk 僅 2.36:1 不足）。 */
.cal-cell.is-today.is-sel {
  box-shadow: inset 0 0 0 2px var(--gold-lt), inset 0 0 0 3.5px rgba(255,244,230,.35);
}
.cal-cell.is-sel.is-today::after { color: var(--gold-lt); }

@media (max-width: 360px) {
  .cal-cell { min-height: 50px; padding: .3rem .1rem .25rem; }
  .cal-solar { font-size: 1.12rem; }
  .cal-lunar { font-size: .68rem; }
  .cal-title { font-size: 1.1rem; letter-spacing: 2px; }
}

/* 通書 API 版詳情：完整干支一行；宜忌下方的權威通書欄位（沖煞／胎神／吉神…） */
.alm-gz.alm-gz-full { justify-content: center; font-family: var(--serif); font-weight: 700; color: var(--cinnabar-dp); letter-spacing: 1px; }
.alm-detail { border-top: 1px solid var(--paper-line); padding: 1rem 1.4rem 0; }
.alm-detail .ad-row {
  display: grid; grid-template-columns: 5.2em 1fr; gap: .3rem .8rem; align-items: baseline;
  padding: .5rem 0; border-bottom: 1px solid var(--paper-line);
}
.alm-detail .ad-row:last-child { border-bottom: none; }
.alm-detail dt { font-family: var(--serif); font-weight: 700; color: var(--muted); font-size: .86rem; letter-spacing: 1px; }
.alm-detail dd { margin: 0; font-size: .9rem; color: var(--ink-on-paper); line-height: 1.7; }
.alm-src { color: var(--muted); }

.almanac-card {
  background: linear-gradient(180deg, #fffdf8, var(--paper)); color: var(--ink-on-paper);
  border: 1px solid var(--paper-line); box-shadow: var(--shadow); overflow: hidden;
  max-width: 560px; margin: 0 auto; scroll-margin-top: 76px;
}
.cal-nav { scroll-margin-top: 76px; }
/* 詳情卡頂端換日工具列：手機上不必捲回月曆即可換日／回月曆 */
.alm-daynav {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .55rem .7rem; background: var(--paper-2); border-bottom: 1px solid var(--paper-line);
}
.alm-daynav-btn, .alm-daynav-cal {
  font-family: var(--serif); font-size: .95rem; font-weight: 700; line-height: 1;
  min-height: 42px; padding: .5rem .8rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--paper-line); background: #fffdf8; color: var(--cinnabar-dp);
  transition: background .15s, border-color .15s, transform .05s;
}
.alm-daynav-cal { color: var(--muted); font-size: .88rem; }
.alm-daynav-btn:hover, .alm-daynav-cal:hover { background: var(--gold-lt); border-color: var(--gold-dk); }
.alm-daynav-btn:active, .alm-daynav-cal:active { transform: translateY(1px); }
.alm-daynav-btn:focus-visible, .alm-daynav-cal:focus-visible { outline: 2px solid var(--gold-dk); outline-offset: 2px; }
.alm-top {
  position: relative; background: radial-gradient(120% 120% at 50% 0%, var(--cinnabar) 0%, var(--cinnabar-dp) 100%);
  color: var(--paper); padding: 1.8rem 1.6rem; text-align: center;
  border-bottom: 3px solid var(--gold);
}
.alm-solar { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--gold-lt); letter-spacing: 1px; }
.alm-solar .alm-greg { display: inline-flex; align-items: center; }
/* 國曆／農曆標籤：讓長輩一眼分得出兩種曆法 */
.alm-cal-tag {
  display: inline-block; font-size: .62rem; font-weight: 700; line-height: 1;
  letter-spacing: 1px; padding: .22rem .4rem; margin-right: .45rem; border-radius: 999px;
  color: var(--gold-lt); border: 1px solid var(--gold-lt); background: rgba(0,0,0,.3);
}
.alm-cal-tag--lunar { color: var(--cinnabar-dp); background: var(--gold-lt); border-color: var(--gold-lt); }
.alm-lunar-head {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 1.05rem; letter-spacing: 3px; color: var(--gold-lt); margin-top: .9rem;
}
.alm-big {
  font-family: var(--serif); font-weight: 900; font-size: 3.8rem; color: #fff; line-height: 1.05; margin: .1rem 0 .15rem;
  text-shadow: 0 2px 10px rgba(0,0,0,.3);
}
.alm-lunar { font-family: var(--serif); font-size: 1.1rem; letter-spacing: 4px; color: var(--gold-lt); }
.alm-gz {
  display: flex; justify-content: space-around; flex-wrap: wrap; gap: .5rem;
  padding: 1rem 1.2rem; background: var(--paper-2); font-size: .92rem; color: var(--muted); border-bottom: 1px dashed var(--paper-line);
}
.alm-gz b { font-family: var(--serif); color: var(--cinnabar); font-weight: 700; }

.yiji { display: grid; grid-template-columns: 1fr 1fr; }
.yiji-col { padding: 1.5rem; position: relative; }
.yiji-col h4 { font-family: var(--serif); font-weight: 900; font-size: 1.8rem; margin-bottom: .7rem; display: flex; align-items: center; gap: .5rem; }
.yiji-col h4::before { content: ""; width: 26px; height: 26px; border-radius: 50%; display: inline-block; }
.yiji-col p { font-size: .92rem; color: var(--ink-on-paper); line-height: 1.9; }
/* 宜／忌逐項標籤：加底色分隔，方便逐條閱讀 */
.yiji-tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.yiji-tag {
  font-family: var(--serif); font-size: .92rem; line-height: 1.4;
  padding: .26rem .62rem; border-radius: 7px;
  color: var(--ink-on-paper); background: var(--paper-2); border: 1px solid var(--paper-line);
}
.yiji-empty { color: var(--muted); font-size: .9rem; }
.yiji-col.yi { border-right: 1px solid var(--paper-line); }
.yiji-col.yi h4 { color: var(--ok); }
.yiji-col.yi h4::before { background: var(--ok); box-shadow: inset 0 0 0 2px #fff, 0 0 0 1px var(--ok); }
.yiji-col.yi .yiji-tag { background: rgba(63,125,78,.13); border-color: rgba(63,125,78,.42); }
.yiji-col.ji h4 { color: var(--cinnabar); }
.yiji-col.ji h4::before { background: var(--cinnabar); box-shadow: inset 0 0 0 2px #fff, 0 0 0 1px var(--cinnabar); }
.yiji-col.ji .yiji-tag { background: rgba(196,38,29,.10); border-color: rgba(196,38,29,.34); }

.alm-foot { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; padding: 1rem 1.4rem; border-top: 1px solid var(--paper-line); font-size: .85rem; color: var(--muted); }
.alm-foot .term-today { color: var(--cinnabar-dp); font-weight: 700; }
.alm-note { padding: 0 1.4rem 1.3rem; font-size: .76rem; color: var(--muted); }

/* ====================================================================
 * 求籤解籤
 * ==================================================================== */
.oracle-wrap { max-width: 560px; margin: 0 auto; }
.oracle-steps {
  list-style: none; counter-reset: step; margin-bottom: 2rem;
  display: grid; gap: .5rem;
}
.oracle-steps li {
  counter-increment: step; position: relative; padding-left: 2.4rem;
  font-size: .92rem; color: #5f4f3a;
}
.oracle-steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 26px; height: 26px; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 900; font-size: .85rem; color: var(--cinnabar);
  border: 1.5px solid var(--gold-dk); border-radius: 50%;
}

.lot-tube-wrap { display: flex; flex-direction: column; align-items: center; gap: 1.4rem; }
.lot-tube {
  position: relative; width: 120px; height: 150px; cursor: pointer;
  background: none; border: none; padding: 0;
  filter: drop-shadow(0 14px 22px rgba(10,4,2,.4));
  transition: transform .2s;
}
.lot-tube:hover { transform: translateY(-3px); }
.tube-body {
  position: absolute; inset: 26px 14px 0; border-radius: 8px 8px 14px 14px;
  background: linear-gradient(100deg, var(--cinnabar-dp) 0%, var(--cinnabar) 45%, #e0533f 55%, var(--cinnabar) 70%, var(--cinnabar-dp) 100%);
  box-shadow: inset 0 0 0 2px var(--gold-dk), inset -8px 0 16px rgba(0,0,0,.35);
  overflow: hidden;
}
.tube-body::before, .tube-body::after {
  content: ""; position: absolute; left: 0; right: 0; height: 7px; background: var(--gold);
  box-shadow: 0 0 0 1px var(--gold-dk);
}
.tube-body::before { top: 18px; }
.tube-body::after { bottom: 22px; }
.tube-label {
  position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%);
  writing-mode: vertical-rl; text-align: center; line-height: 1.05;
  font-family: var(--serif); font-weight: 900; font-size: 1.5rem; color: var(--gold-lt); letter-spacing: 4px;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
/* 露出的籤枝 */
.lot-stick {
  position: absolute; top: -22px; width: 5px; height: 54px; border-radius: 3px;
  background: linear-gradient(var(--paper-3), #cdb88e); box-shadow: 0 1px 2px rgba(0,0,0,.3);
  transform-origin: bottom center;
}
.lot-stick::after { content: ""; position: absolute; top: 6px; left: 0; right: 0; height: 4px; background: var(--cinnabar); }
.lot-stick.s1 { left: 30px; transform: rotate(-14deg); }
.lot-stick.s2 { left: 45px; transform: rotate(-6deg); height: 60px; top: -28px; }
.lot-stick.s3 { left: 58px; transform: rotate(0deg); height: 64px; top: -32px; }
.lot-stick.s4 { left: 71px; transform: rotate(7deg); height: 58px; top: -26px; }
.lot-stick.s5 { left: 85px; transform: rotate(15deg); }

.lot-tube.shaking { animation: tubeShake .5s ease-in-out infinite; }
.lot-tube.shaking .lot-stick { animation: stickJitter .25s ease-in-out infinite alternate; }
@keyframes tubeShake {
  0%,100% { transform: rotate(-7deg) translateY(0); }
  25% { transform: rotate(6deg) translateY(-6px); }
  50% { transform: rotate(-5deg) translateY(2px); }
  75% { transform: rotate(7deg) translateY(-4px); }
}
@keyframes stickJitter { from { transform: translateY(0); } to { transform: translateY(-6px); } }

/* 籤詩結果卡 */
.lot-result { margin-top: 2.2rem; }
.lot-card {
  position: relative; background: linear-gradient(180deg, #fffdf8, var(--paper));
  border: 1px solid var(--paper-line); box-shadow: var(--shadow);
  padding: 1.8rem 1.8rem 1.4rem; border-top: 4px solid var(--cinnabar);
  animation: modalIn .45s cubic-bezier(.2,.8,.2,1) both;
}
.lot-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed var(--paper-line); }
.lot-no-cn { display: block; font-family: var(--serif); font-weight: 900; font-size: 1.5rem; color: var(--ink); letter-spacing: 2px; }
.lot-no-gz { display: block; font-size: .78rem; color: var(--muted); letter-spacing: 1px; margin-top: .2rem; }
.lot-level {
  flex: none; font-family: var(--serif); font-weight: 900; font-size: 1.1rem; letter-spacing: 2px;
  padding: .35rem .9rem; border-radius: 2px; color: #fff;
}
.lv-great .lot-level { background: var(--cinnabar); box-shadow: inset 0 0 0 2px #fff3, 0 4px 12px -5px var(--cinnabar-dp); }
.lv-good  .lot-level { background: var(--gold-dk); }
.lv-mid   .lot-level { background: #6f6353; }
.lv-low   .lot-level { background: #8a6a4a; }
.lv-bad   .lot-level { background: #4a4038; }
.lv-great { border-top-color: var(--cinnabar); }
.lv-bad   { border-top-color: #4a4038; }

.lot-poem {
  display: flex; justify-content: center; gap: 1.1rem; padding: 1.8rem 0;
  direction: rtl;
}
.lot-poem p {
  writing-mode: vertical-rl; text-orientation: upright;
  font-family: var(--serif); font-weight: 700; font-size: 1.5rem; letter-spacing: 6px;
  color: var(--ink); line-height: 1.3;
}
.lv-bad .lot-poem p, .lv-low .lot-poem p { color: #3a302a; }

.lot-jie { background: var(--paper-2); border-left: 3px solid var(--gold); padding: 1rem 1.2rem; border-radius: 2px; }
.lot-jie h4 { font-family: var(--serif); font-weight: 900; color: var(--cinnabar); font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; letter-spacing: 2px; }
.seal-mini { width: 26px; height: 26px; display: grid; place-items: center; background: var(--cinnabar); color: #fff; font-size: .8rem; border-radius: 3px; box-shadow: inset 0 0 0 2px #fff4; }
.lot-jie p { font-size: .95rem; color: var(--ink-on-paper); line-height: 1.9; }
.lot-foot { margin-top: 1rem; font-size: .76rem; color: var(--muted); text-align: center; }

/* 擲筊請示 */
.jiao-stage {
  max-width: 460px; margin: 2rem auto 0; text-align: center;
  background: linear-gradient(180deg, #fffdf8, var(--paper));
  border: 1px solid var(--paper-line); border-top: 4px solid var(--gold);
  padding: 1.6rem 1.4rem; box-shadow: var(--shadow-s);
  animation: modalIn .35s cubic-bezier(.2,.8,.2,1) both;
}
.drawn-no { font-size: 1.05rem; color: var(--ink-on-paper); }
.drawn-no b { font-family: var(--serif); font-weight: 900; font-size: 1.5rem; color: var(--cinnabar); letter-spacing: 2px; }
.drawn-no .gz { font-family: var(--serif); color: var(--gold-dk); }
.jiao-hint { font-size: .86rem; color: var(--muted); margin: .5rem 0 1.2rem; }
.jiao-hint b { color: var(--cinnabar); }

/* 擲筊台：物理模擬的範圍（重力／彈跳／摩擦／牆壁碰撞由 js/oracle.js 計算）。
   兩只筊杯為貼圖 .cup-face（flat.png 平面／bump.png 凸面），翻面以 scaleY 偽 3D。 */
.jiao-arena {
  position: relative; width: 100%; height: 190px; margin: 0 auto .5rem;
  border-bottom: 2px solid var(--paper-line);           /* 落地線 */
}
.jiao-cup {
  position: absolute; left: 0; top: 0; width: 80px; height: 80px;
  margin: -40px 0 0 -40px;                              /* 以中心定位，JS 以 transform 擺放 */
  transform: translate(-200px, -200px);                /* 初始離場，等 JS 接管 */
  will-change: transform; pointer-events: none; backface-visibility: hidden;
}
.jiao-cup .cup-face {
  width: 100%; height: 100%; display: block;
  filter: drop-shadow(0 5px 6px rgba(0, 0, 0, .35));
  -webkit-user-drag: none; user-select: none;
}

.jiao-result { min-height: 1.5em; font-weight: 700; font-size: .95rem; margin: .3rem 0 .6rem; letter-spacing: 1px; }
.jiao-result.sheng  { color: var(--ok); }
.jiao-result.xiao   { color: var(--gold-dk); }
.jiao-result.yinbei { color: #8a6a4a; }

.jiao-streak { display: flex; align-items: center; justify-content: center; gap: .4rem; margin-bottom: 1.1rem; }
.streak-label { font-size: .8rem; color: var(--muted); margin-right: .2rem; }
.jiao-streak .cup {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%;
  font-family: var(--serif); font-size: .8rem; border: 1.5px solid var(--paper-line);
  color: var(--muted); background: #fffdf8; transition: .2s;
}
.jiao-streak .cup.on { background: var(--ok); color: #fff; border-color: var(--ok); box-shadow: 0 3px 8px -3px var(--ok); transform: scale(1.08); }
.streak-cnt { font-size: .78rem; color: var(--muted); margin-left: .2rem; }

/* 籤詩卡——豐富內容區 */
.lot-sec { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--paper-line); }
.lot-sec h4 { font-family: var(--serif); font-weight: 900; color: var(--gold-dk); font-size: 1rem; letter-spacing: 2px; margin-bottom: .45rem; }
.lot-sec p { font-size: .92rem; color: var(--ink-on-paper); line-height: 1.9; }
.lot-sec p.cl { font-family: var(--serif); color: #4a3f33; letter-spacing: .5px; }

.zhan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .9rem; }
.zhan-item { display: flex; gap: .5rem; font-size: .88rem; align-items: baseline; }
.zhan-k { flex: none; font-family: var(--serif); font-weight: 700; color: #fff; background: var(--cinnabar); padding: .08rem .45rem; border-radius: 2px; font-size: .78rem; }
.zhan-v { color: var(--ink-on-paper); line-height: 1.6; }

/* ====================================================================
 * 關於
 * ==================================================================== */
.about-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.3rem; }
.about-grid article {
  position: relative; background: linear-gradient(180deg, #fffdf8, var(--paper));
  border: 1px solid var(--paper-line); padding: 2.2rem 1.5rem 1.6rem; box-shadow: var(--shadow-s);
}
.about-no {
  position: absolute; top: -18px; left: 22px;
  width: 38px; height: 38px; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 900; font-size: 1.2rem; color: #fff; background: var(--cinnabar);
  box-shadow: inset 0 0 0 2px #fff4, 0 6px 14px -6px var(--cinnabar-dp); border-radius: 4px;
}
.about-grid h3 { font-family: var(--serif); font-weight: 900; color: var(--ink); font-size: 1.2rem; letter-spacing: 2px; margin-bottom: .5rem; }
.about-grid p { font-size: .92rem; color: #5f4f3a; }

/* ====================================================================
 * 頁尾
 * ==================================================================== */
.site-footer {
  background: linear-gradient(180deg, var(--ink), #0c0805); color: var(--paper);
  text-align: center; padding: 2.6rem 1.4rem; border-top: 2px solid var(--gold-dk);
}
.foot-emblem { width: 54px; height: 54px; margin: 0 auto .9rem; }
.foot-name { font-family: var(--serif); font-weight: 900; font-size: 1.4rem; letter-spacing: 6px; color: var(--paper); }
.foot-sub { font-size: .82rem; color: var(--gold); letter-spacing: 2px; margin-top: .3rem; }
.site-footer .muted { font-size: .74rem; color: #8a7355; margin-top: 1rem; max-width: 36em; margin-left: auto; margin-right: auto; }

/* ====================================================================
 * 彈窗
 * ==================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(12,6,4,.72); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 1rem;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative; width: min(560px, 100%); max-height: 90vh; overflow-y: auto;
  background: linear-gradient(180deg, #fffdf8, var(--paper));
  border-top: 5px solid var(--cinnabar);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--paper-line); padding: 2rem 1.8rem;
  animation: modalIn .3s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.modal-close { position: absolute; top: .9rem; right: 1.1rem; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); }
.modal-close:hover { color: var(--cinnabar); }
.modal-title { font-family: var(--serif); font-weight: 900; color: var(--cinnabar); letter-spacing: 3px; display: flex; align-items: center; gap: .6rem; font-size: 1.4rem; }
.modal-title .seal { width: 32px; height: 32px; display: grid; place-items: center; background: var(--cinnabar); color: #fff; font-size: .9rem; border-radius: 4px; box-shadow: inset 0 0 0 2px #fff4; }
.modal-done h3 { font-family: var(--serif); font-weight: 900; color: var(--cinnabar); }
.form-hint { font-size: .84rem; color: var(--muted); margin: .4rem 0 1.2rem; }
.modal-form label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .9rem; font-weight: 700; letter-spacing: 1px; }
.modal-form input, .modal-form select, .modal-form textarea {
  width: 100%; margin-top: .35rem; padding: .65rem .75rem; font-family: var(--sans); font-size: .92rem; font-weight: 400;
  border: 1px solid var(--paper-line); background: #fffdf8; color: var(--ink); border-radius: var(--radius);
}
.modal-form input:focus, .modal-form select:focus, .modal-form textarea:focus { outline: none; border-color: var(--cinnabar); box-shadow: 0 0 0 3px rgba(196,38,29,.12); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.req { color: var(--cinnabar); }
.modal-actions { display: flex; gap: .8rem; justify-content: flex-end; margin-top: .8rem; flex-wrap: wrap; }
.modal-done { text-align: center; padding: 1rem; }
.done-mark { width: 66px; height: 66px; margin: 0 auto 1.1rem; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-size: 2rem; box-shadow: 0 10px 24px -10px var(--ok); }
.modal-done p { color: #5f4f3a; margin: .7rem 0 1.5rem; }

/* ====================================================================
 * RWD
 * ==================================================================== */
@media (max-width: 900px) {
  .only-pc { display: none; }
  .couplet { display: none; }

  .top-nav {
    display: none; position: absolute; top: 100%; right: 0; left: 0;
    flex-direction: column; gap: 0; background: var(--ink-2);
    padding: .4rem; border-bottom: 1px solid var(--gold-dk);
  }
  .top-nav.open { display: flex; }
  .nav-link { padding: .85rem 1rem; }
  .nav-link::after { display: none; }
  .nav-toggle { display: flex; }

  .map-section { grid-template-columns: 1fr; min-height: 0; }
  .panel { max-height: none; border-right: none; border-bottom: 3px solid var(--gold-dk); order: 2; }
  .branch-list { max-height: 52vh; }
  .map-wrap { order: 1; height: 56vh; }
  /* 地圖填滿外框內緣（扣掉硃砂框帶 padding），避免超出外框 */
  #map { min-height: 0; height: 100%; }

  .about-grid { grid-template-columns: 1fr; gap: 2rem; }
  .form-row { grid-template-columns: 1fr; }
  .yiji { grid-template-columns: 1fr; }
  .yiji-col.yi { border-right: none; border-bottom: 1px solid var(--paper-line); }

  .hero-stats { gap: 1.1rem; }
  .hero-stats i { height: 34px; }
  .hero-stats strong { font-size: 2.2rem; }
}

@media (max-width: 480px) {
  .sec-ord { width: 46px; height: 46px; font-size: 1.4rem; }
  .hero-stats div { min-width: 70px; }
}

/* ====================================================================
 * LINE 多頁架構：頁首列 + 底部分頁列 + 首頁功能入口
 * ==================================================================== */
/* 宣紙外框：頁首與底部分頁列同為淺紙底＋硃砂線，全頁連續紙感 */
.app-header {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 1rem; padding: .6rem 1.1rem;
  background: linear-gradient(180deg, rgba(250,244,228,.86), rgba(239,227,203,.86));
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1.5px solid var(--cinnabar);   /* 與底部分頁列同一條硃砂線，上下成框 */
  box-shadow: 0 6px 18px -14px rgba(60,30,10,.4);
}
.app-brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; margin-right: auto; }
/* 廟徽：原圖已是完整圓形印徽，不加任何外框 */
.app-emblem { width: 44px; height: 44px; }
.app-brand-text { display: flex; flex-direction: column; line-height: 1.08; }
.app-brand-text strong {
  font-family: var(--serif); font-weight: 900; font-size: 1.4rem; color: var(--ink);
  letter-spacing: 5px;
}

/* ───── 書法字標 wordmark（assets/wordmark.png，墨筆＋透明底）─────
   頁首墨色直接呈現；hero／頁尾深底以 filter 反白為宣紙色。
   僅 body.has-wordmark 生效；原廟名文字保留為 sr-only 供螢幕報讀。 */
.wm-img { display: none; height: auto; width: auto; }
.has-wordmark .wm-img { display: block; }
.has-wordmark .app-brand-text strong,
.has-wordmark .hero-title,
.has-wordmark .foot-name {
  position: absolute !important; width: 1px; height: 1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.wm-head { height: 34px; }                       /* 頁首：墨色字標，與 44px 廟徽等高呼應（移除「關聖帝君」kicker 後放大）*/
.wm-hero {                                        /* hero：深底 → 反白為暖宣紙色＋硃砂暈 */
  height: clamp(52px, 14vw, 96px); margin: .1rem auto .3rem;
  filter: brightness(0) invert(1) sepia(.16) saturate(1.25)
          drop-shadow(0 1px 10px rgba(196, 38, 29, .5));
}
.wm-foot { height: 34px; margin: 0 auto;         /* 頁尾：反白為暖宣紙色 */
  filter: brightness(0) invert(1) sepia(.16) saturate(1.25); }
.header-tabs { display: flex; gap: .1rem; }
.header-tabs .htab {
  position: relative; color: var(--muted); text-decoration: none;
  padding: .5rem .9rem; font-size: .92rem; letter-spacing: 2px; transition: color .2s;
}
.header-tabs .htab::after {
  content: ""; position: absolute; left: .9rem; right: .9rem; bottom: .28rem; height: 2px;
  background: var(--cinnabar); transform: scaleX(0); transform-origin: center; transition: transform .25s;
}
.header-tabs .htab:hover { color: var(--ink); }
.header-tabs .htab:hover::after, .header-tabs .htab.active::after { transform: scaleX(1); }
.header-tabs .htab.active { color: var(--cinnabar); }

/* 底部分頁列（行動裝置／LINE webview）— 同款宣紙底＋硃砂線 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: linear-gradient(180deg, rgba(244,234,212,.88), rgba(232,217,189,.9));
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1.5px solid var(--cinnabar);
  box-shadow: 0 -5px 18px -10px rgba(60,30,10,.35);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: .5rem 0 .55rem; text-decoration: none; color: var(--muted); font-size: .72rem; letter-spacing: 1px; transition: color .2s, transform .1s; }
.tab-ic svg { width: 23px; height: 23px; display: block; }
.tab.active { color: var(--cinnabar); }
.tab.active .tab-ic { filter: drop-shadow(0 1px 3px rgba(196,38,29,.45)); }
.tab:active { transform: scale(.94); }

/* 首頁功能入口卡 */
.home-entries { padding: 2.4rem 1.2rem; max-width: 860px; margin: 0 auto; }
.entry-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.entry-card {
  display: flex; flex-direction: column; gap: .55rem; padding: 1.5rem 1.2rem;
  background: linear-gradient(180deg, #fffdf8, var(--paper));
  border: 1px solid var(--paper-line); border-top: 3px solid var(--cinnabar);
  box-shadow: var(--shadow-s); text-decoration: none; transition: transform .18s, box-shadow .25s;
}
.entry-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.entry-ic { width: 46px; height: 46px; display: grid; place-items: center; color: var(--cinnabar); background: var(--paper-2); border-radius: 10px; }
.entry-ic svg { width: 26px; height: 26px; }
.entry-card h3 { font-family: var(--serif); font-weight: 900; color: var(--ink); font-size: 1.18rem; letter-spacing: 2px; }
.entry-card p { font-size: .82rem; color: var(--muted); }

/* 地圖頁：登記按鈕移至面板底部頁尾（瀏覽優先、登記為次要動作） */
.panel-actions {
  display: flex; gap: .5rem; padding: .8rem 1.3rem;
  border-top: 1px solid var(--paper-line);
  background: linear-gradient(180deg, transparent, rgba(214,189,150,.18));
}
.panel-actions .btn { flex: 1; }

@media (max-width: 900px) {
  .header-tabs { display: none; }
  /* 手機無右側分頁 → 品牌置中，避免右側大片留白失衡 */
  .app-header { justify-content: center; }
  .app-brand { margin-right: 0; }
  body.has-tabbar { padding-bottom: 64px; }
}
@media (min-width: 901px) {
  .tabbar { display: none; }
}
/* 手機維持 2×2，四項一眼看完（不再單欄捲動）；卡片置中精簡 */
@media (max-width: 480px) {
  .home-entries { padding: 1.8rem 1rem; }
  .entry-grid { gap: .75rem; }
  .entry-card { align-items: center; text-align: center; padding: 1.4rem .8rem; gap: .45rem; min-height: 150px; justify-content: center; }
  .entry-ic { width: 54px; height: 54px; }
  .entry-ic svg { width: 30px; height: 30px; }
  .entry-card h3 { font-size: 1.18rem; }
  .entry-card p { font-size: .8rem; line-height: 1.5; }
}

/* ====================================================================
 * 分靈地圖 — 手機大字清晰化（字大、行高足、觸控目標 ≥44px）
 * ==================================================================== */
.sec-head-inset h2 { font-size: 1.55rem; letter-spacing: 3px; }
.result-count { font-size: .95rem; }

#searchInput { font-size: 1.05rem; padding: .85rem 1rem; }
.region-row { gap: .6rem; }
.region-row select { font-size: 1rem; padding: .72rem .7rem; }
.chip { font-size: .98rem; padding: .55rem 1.1rem; }
.vp-toggle { font-size: .95rem; }
.vp-toggle input { width: 19px; height: 19px; }

.branch-item { padding: 1rem 1.1rem; margin-bottom: .35rem; }
.bi-top { gap: .55rem; }
.bi-name { font-size: 1.22rem; }
.bi-badge { font-size: .8rem; padding: .18rem .6rem; }
.bi-verified { font-size: .82rem; }
.bi-verified.pending { font-size: .82rem; }
.bi-addr { font-size: 1rem; margin-top: .4rem; line-height: 1.6; }
.bi-meta { font-size: .92rem; margin-top: .25rem; }

.pager { padding: .8rem; gap: .4rem; }
.pg-btn { min-width: 40px; height: 40px; font-size: 1.15rem; }
.pg-info { font-size: .88rem; }
.panel-actions .btn { font-size: .98rem; padding: .65rem 1.1rem; }

/* 地圖泡泡放大 */
.leaflet-popup-content { font-size: 1rem; }
.pop-name { font-size: 1.25rem; }
.pop-deity { font-size: .95rem; }
.pop-addr { font-size: .98rem; }
.pop-note { font-size: .92rem; }

/* 手機進一步加大，確保長輩易讀、單手好按 */
@media (max-width: 900px) {
  .sec-head-inset { padding: 1.2rem 1.2rem .8rem; }
  .sec-head-inset h2 { font-size: 1.7rem; }
  .result-count { font-size: 1.02rem; }
  #searchInput { font-size: 1.15rem; padding: .95rem 1rem; }
  .region-row select { font-size: 1.1rem; padding: .85rem .7rem; min-height: 50px; }
  .chip { font-size: 1.08rem; padding: .62rem 1.2rem; }
  .vp-toggle { font-size: 1.02rem; }
  .bi-name { font-size: 1.32rem; }
  .bi-addr { font-size: 1.08rem; }
  .bi-meta { font-size: 1rem; }
  .bi-badge { font-size: .88rem; padding: .22rem .7rem; }
  .bi-verified { font-size: .9rem; }
  .branch-item { padding: 1.15rem 1.15rem; }
  .panel-actions .btn { font-size: 1.08rem; padding: .85rem 1rem; width: 100%; }
  .pg-btn { min-width: 46px; height: 46px; font-size: 1.3rem; }
  .pg-info { font-size: .98rem; }
  /* 手機把清單顯示高度加大，方便瀏覽 */
  .map-wrap { height: 46vh; }
  #map { min-height: 0; height: 100%; }
  .branch-list { max-height: none; }
}

/* 檢視範圍分段控制（台灣 / 全球）：面板內，與篩選同組，不浮在地圖上。
   做成「匾額／硃漆牌」：金框＋宣紙漸層軌、金分隔線、明體字；作用段為硃漆＋印泥內線（DESIGN.md §6.1） */
.scope-seg {
  display: flex; margin-top: .7rem;
  border: 1px solid var(--gold-dk); border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(180deg, #fffdf8, #f3e9d2);
  box-shadow: inset 0 1px 2px rgba(120,90,40,.12);
}
.seg-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font-family: var(--serif); font-size: .98rem; font-weight: 700; letter-spacing: 2px;
  cursor: pointer; padding: .6rem .4rem; border: none; background: transparent;
  color: var(--ink-on-paper); white-space: nowrap; transition: background .18s, color .18s;
}
.seg-btn .seg-ic { width: 1.05em; height: 1.05em; opacity: .68; flex: none; }
.seg-btn + .seg-btn { border-left: 1px solid var(--gold-dk); }
.seg-btn:hover { background: rgba(196,160,82,.14); }
.seg-btn.active {
  background: linear-gradient(180deg, var(--cinnabar), var(--cinnabar-dp));
  color: #fff;
  box-shadow: inset 0 0 0 1.5px rgba(255,244,230,.35), inset 0 2px 4px rgba(0,0,0,.22);
}
.seg-btn.active .seg-ic { opacity: 1; }
@media (max-width: 900px) {
  .seg-btn { font-size: 1.12rem; padding: .72rem .4rem; min-height: 48px; }
}

/* ====================================================================
 * 求籤 — 關聖帝君線上直播
 * ==================================================================== */
.live-block {
  margin-bottom: 2rem;
  /* 深色霜玻璃：半透明深墨讓底圖背景畫透出一點，仍夠深以維持金字對比 */
  background: linear-gradient(180deg, rgba(31, 23, 18, .84), rgba(20, 14, 11, .88));
  backdrop-filter: blur(7px) saturate(1.05);
  -webkit-backdrop-filter: blur(7px) saturate(1.05);
  border: 1px solid var(--gold-dk); border-top: 4px solid var(--cinnabar);
  border-radius: var(--radius); padding: .9rem .9rem 1rem;
  box-shadow: var(--shadow);
}
.live-head {
  display: flex; align-items: flex-start; gap: .5rem; flex-wrap: wrap; row-gap: .15rem;
  font-family: var(--serif); font-weight: 900; font-size: 1.1rem; letter-spacing: 2px;
  color: var(--gold-lt); padding: .2rem .2rem .7rem;
}
.live-head .live-h-name, .live-head .live-h-title { white-space: nowrap; }  /* 只在「·」處換行，片語不拆 */
.live-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #e0533f; flex: none;
  margin-top: .42em;   /* 對齊首行（多行時不置中於整塊）*/
  box-shadow: 0 0 0 0 rgba(224,83,63,.6); animation: livePulse 1.6s ease-out infinite;
}
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(224,83,63,.6); }
  100% { box-shadow: 0 0 0 11px rgba(224,83,63,0); }
}
.live-frame {
  position: relative; aspect-ratio: 16 / 9; width: 100%;
  background: #000; border-radius: 3px; overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--gold-dk);
}
.live-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.live-note { margin-top: .7rem; text-align: center; font-size: .9rem; color: #cbb893; letter-spacing: 1px; }
@media (max-width: 900px) {
  .live-head { font-size: 1.2rem; }
  .live-note { font-size: 1rem; }
}

/* 籤詩結果卡底部動作（再求一籤）*/
.lot-actions { margin-top: 1.2rem; display: flex; justify-content: center; }
.lot-actions .btn { min-width: 60%; }
@media (max-width: 900px) { .lot-actions .btn { width: 100%; font-size: 1.05rem; } }

/* ============================================================
 * 求籤頁 視覺精修 v2 — Design for Hackers
 *   排版(ch03/05/07) · 配色(ch08/09) · 籤筒筊杯圖示 · 動畫(motion)
 *   ※ 選擇器皆為求籤頁專屬，不影響其他頁
 * ============================================================ */

/* —— 求籤區氛圍：暖色聚焦，凸顯儀式焦點（ch06 焦點 / 圖地）。
   改半透明，讓底圖透出，與農民曆一致（仍保留上緣暖色聚光）—— */
#oracle-section {
  background:
    radial-gradient(130% 70% at 50% -5%, rgba(251,241,216,.62) 0%, rgba(244,236,219,.55) 48%, rgba(235,220,194,.6) 100%);
}

/* —— 籤筒：近黃金比 + 竹節 + 待機微浮（ch05 比例；signifier 邀請點擊）—— */
.lot-tube { width: 122px; height: 196px; }                 /* 1 : 1.6 近黃金比 */
.lot-tube:not(.shaking) { animation: tubeFloat 3.6s ease-in-out infinite; }
.lot-tube:hover { animation: none; transform: translateY(-5px) scale(1.03); }
@keyframes tubeFloat { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-6px) rotate(1.2deg); } }
.tube-body {
  background:
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(0,0,0,.12) 31px 33px),
    linear-gradient(100deg, var(--cinnabar-dp) 0%, var(--cinnabar) 45%, #e0533f 55%, var(--cinnabar) 70%, var(--cinnabar-dp) 100%);
}
.tube-label { font-size: 1.7rem; }

/* 聖杯進度：填入時彈入（goal-gradient 視覺強化）*/
.jiao-streak .cup.on { animation: cupPop .36s cubic-bezier(.2,.9,.3,1.05) both; }
@keyframes cupPop { 0% { transform: scale(.4); opacity: .2; } 60% { transform: scale(1.18); } 100% { transform: scale(1.08); opacity: 1; } }

/* —— 籤紙：暖米黃 + 硃紅內框 + 暖色陰影（ch09 暖色前進；common-region）—— */
.lot-card {
  background: linear-gradient(180deg, #fdf7e6 0%, #f5e9cf 100%);
  box-shadow: 0 22px 55px -20px rgba(60,20,6,.5), inset 0 0 0 1px #e7d2a2;
  border-top-width: 5px;
}
.lot-card::before {                                  /* 內側硃紅細框，似籤紙 */
  content: ""; position: absolute; inset: 9px; pointer-events: none;
  border: 1px solid rgba(196,38,29,.32); border-radius: 2px;
}

/* —— 排版：籤詩為主焦點（ch07 支配；ch05 比例）—— */
.lot-no-cn { font-size: 1.7rem; letter-spacing: 3px; }
.lot-poem { padding: 2.1rem 0 1.9rem; gap: 1.25rem; }
.lot-poem p {
  font-size: clamp(1.55rem, 6.2vw, 1.95rem); letter-spacing: 8px; line-height: 1.5;
  color: var(--ink); text-shadow: 0 1px 0 #fff8;
}
.lv-great .lot-poem p { color: var(--cinnabar-dp); }   /* 大吉/上上 籤詩染硃，呼應吉象 */
.lot-sec h4 { display: flex; align-items: center; gap: .45rem; }
.lot-sec h4::before { content: "❖"; color: var(--cinnabar); font-size: .7em; }
.lot-jie h4::before { content: none; }                 /* 淺釋已有印章標記 */

/* —— 開籤動畫：各段交錯入場，視線由上而下、焦點落在籤詩（motion：ease-out 入場）—— */
.lot-card > * { animation: rise .55s cubic-bezier(.2,.8,.2,1) both; }
.lot-card > *:nth-child(1) { animation-delay: .02s; }
.lot-card > *:nth-child(2) { animation-delay: .12s; }   /* 籤詩 */
.lot-card > *:nth-child(3) { animation-delay: .24s; }
.lot-card > *:nth-child(4) { animation-delay: .34s; }
.lot-card > *:nth-child(5) { animation-delay: .42s; }
.lot-card > *:nth-child(6) { animation-delay: .50s; }
.lot-card > *:nth-child(n+7) { animation-delay: .58s; }

/* —— 無障礙：尊重減少動態（motion.md 必備）—— */
@media (prefers-reduced-motion: reduce) {
  .lot-tube, .lot-tube:not(.shaking), .lot-tube.shaking, .lot-tube .lot-stick,
  .jiao.tossing, .lot-card, .lot-card > *, .jiao-streak .cup.on, .live-dot {
    animation: none !important;
  }
  .lot-tube:hover { transform: none; }
}

/* 首頁主視覺：標語與功能清單分行（手機可讀，不靠 PC 斷行）*/
.hero-lead { margin-bottom: .5rem; }
.hero-sub {
  margin: 0 auto 2rem; color: var(--gold-lt);
  font-size: .95rem; letter-spacing: 2px; line-height: 1.7;
  animation: rise .9s .45s both;
}

/* ============================================================
 * 全站一致性精修 v3
 * ============================================================ */

/* 四個內容頁標題統一「頁首」簽名：H2 下方短硃紅線（map 面板內嵌標題不受影響）*/
.feature-inner > .sec-head .sec-titles h2 { position: relative; padding-bottom: .5rem; }
.feature-inner > .sec-head .sec-titles h2::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 2.4rem; height: 3px; background: var(--cinnabar); border-radius: 2px;
}

/* 農民曆「通書」卡：沿用求籤籤紙暖色＋暖陰影，全站紙感材質一致 */
.almanac-card {
  background: linear-gradient(180deg, #fdf7e6 0%, #f5e9cf 100%);
  box-shadow: 0 20px 50px -20px rgba(60,20,6,.45), inset 0 0 0 1px #e7d2a2;
}
/* 巨大農曆數字加字距，明體捺腳更從容（兩字日如「十一」不擠）*/
.alm-big { letter-spacing: 4px; }

/* ====================================================================
 * 分靈名單後台 admin.html（P1：外殼＋登入＋狀態篩選清單）
 * ==================================================================== */
.admin-body { min-height: 100vh; }

/* 登入卡 */
/* 後台登入門面：神龕／匾額式（匾額四角＋硃砂上緣＋宣紙欄位），沿用站內墨硃金語彙 */
.admin-login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.admin-login[hidden] { display: none; }   /* 否則 display:grid 會蓋過 [hidden] 的 display:none */
.login-card {
  position: relative; width: 100%; max-width: 380px; text-align: center;
  background: linear-gradient(180deg, #fdf7e6, #f2e4c6);
  border: 1.5px solid var(--gold-dk); border-top: 3px solid var(--cinnabar);
  border-radius: var(--radius);
  padding: 2.3rem 1.9rem 1.6rem;
  box-shadow: 0 26px 64px -26px rgba(60,40,16,.6), inset 0 0 0 1px rgba(255,247,230,.5);
}
.login-card .card-corner { border-color: var(--gold-dk); }
.login-emblem { width: 74px; height: 74px; object-fit: contain; }
.login-title { font-family: var(--serif); font-weight: 900; font-size: 1.6rem; letter-spacing: 5px; color: var(--ink); margin: .7rem 0 0; }
.login-title::after { content: ""; display: block; width: 2.2rem; height: 2px; background: var(--cinnabar); margin: .6rem auto 0; }  /* 硃砂短線（呼應 h2::after） */
.login-sub { color: var(--muted); font-size: .85rem; letter-spacing: 1px; margin: .55rem 0 1.5rem; }
#loginForm { display: grid; gap: .85rem; text-align: left; }
.login-field { display: grid; gap: .32rem; }
.field-label { font-size: .8rem; font-weight: 700; letter-spacing: 1px; color: var(--ink-on-paper); }
#loginForm input[type="email"], #loginForm input[type="password"] {
  width: 100%; padding: .78rem .9rem; font-size: 1rem; font-family: var(--sans);
  border: 1px solid var(--gold-dk); border-radius: var(--radius); background: #fffdf8; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
#loginForm input:focus { outline: none; border-color: var(--cinnabar); box-shadow: 0 0 0 3px rgba(196,38,29,.12); }
#loginForm .btn-primary { margin-top: .35rem; letter-spacing: 6px; }
.login-err { color: var(--cinnabar); font-size: .85rem; text-align: center; margin-top: .1rem; }
.login-note { margin-top: 1.1rem; font-size: .74rem; color: var(--muted); line-height: 1.6; }

/* 後台主體 */
.admin-shell { max-width: 760px; margin: 0 auto; padding: 0 1rem 3rem; }
.admin-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem .2rem; border-bottom: 1.5px solid var(--cinnabar); margin-bottom: 1rem;
}
.admin-brand { display: inline-flex; align-items: center; gap: .55rem; font-family: var(--serif); font-weight: 900; font-size: 1.2rem; letter-spacing: 2px; color: var(--ink); }
.admin-emblem { width: 36px; height: 36px; object-fit: contain; }

.admin-head-actions { display: flex; gap: .5rem; }
.admin-toolbar { display: grid; gap: .7rem; margin-bottom: 1rem; }
.admin-toolbar-top { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.admin-stats { font-size: .85rem; color: var(--muted); }
.ar-actions { display: flex; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.ar-actions .btn { padding: .4rem .9rem; }
.ar-del { color: var(--cinnabar); }
/* 核准鈕：綠底白字（成功語意），退回鈕沿用 ghost */
.ar-approve { background: var(--ok); color: #fff; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.25); }
.ar-approve:hover { background: #356a42; }
.ar-check { width: 17px; height: 17px; accent-color: var(--cinnabar); flex: none; cursor: pointer; }

/* 批次審核工具列 */
.batch-bar {
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
  padding: .6rem .8rem; margin-bottom: .8rem;
  background: linear-gradient(180deg, #fffdf8, #f3e9d2);
  border: 1px solid var(--gold-dk); border-radius: var(--radius);
}
.batch-all { display: inline-flex; align-items: center; gap: .4rem; font-size: .88rem; color: var(--ink-on-paper); cursor: pointer; }
.batch-all input { width: 17px; height: 17px; accent-color: var(--cinnabar); cursor: pointer; }
.batch-count { font-size: .85rem; color: var(--muted); }
.batch-actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.batch-actions .btn:disabled { opacity: .4; cursor: not-allowed; }

/* 建立／編輯表單的「祖廟」勾選 */
.edit-home { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--ink-on-paper); cursor: pointer; }
.edit-home input { width: 17px; height: 17px; accent-color: var(--cinnabar); flex: none; }
.edit-home b { color: var(--cinnabar); }

/* 狀態分段（沿用匾額語彙，作用段硃漆） */
.admin-seg {
  display: flex; border: 1px solid var(--gold-dk); border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(180deg, #fffdf8, #f3e9d2);
}
.admin-seg-btn {
  flex: 1; min-height: 44px; cursor: pointer; border: none; background: transparent;
  font-family: var(--serif); font-weight: 700; font-size: .95rem; letter-spacing: 1px; color: var(--ink-on-paper);
  transition: background .18s, color .18s;
}
.admin-seg-btn + .admin-seg-btn { border-left: 1px solid var(--gold-dk); }
.admin-seg-btn b { font-family: var(--sans); font-weight: 700; font-size: .82em; opacity: .75; margin-left: .15em; }
.admin-seg-btn:hover { background: rgba(196,160,82,.14); }
.admin-seg-btn.active { background: linear-gradient(180deg, var(--cinnabar), var(--cinnabar-dp)); color: #fff;
  box-shadow: inset 0 0 0 1.5px rgba(255,244,230,.35), inset 0 2px 4px rgba(0,0,0,.22); }
.admin-seg-btn.active b { opacity: 1; }

#adminSearch {
  width: 100%; padding: .7rem .9rem; font-size: .95rem; font-family: var(--sans);
  border: 1px solid var(--paper-line); border-radius: var(--radius); background: #fffdf8; color: var(--ink);
}
#adminSearch:focus { outline: none; border-color: var(--cinnabar); box-shadow: 0 0 0 3px rgba(196,38,29,.12); }

/* 清單 */
.admin-list { list-style: none; display: grid; gap: .5rem; }
.admin-row {
  background: #fffdf8; border: 1px solid var(--paper-line); border-left: 4px solid var(--paper-line);
  border-radius: var(--radius); padding: .8rem 1rem;
}
.admin-row.status-pending  { border-left-color: #b07b2a; }
.admin-row.status-approved { border-left-color: var(--ok); }
.admin-row.status-rejected { border-left-color: var(--muted); }
.ar-main { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.ar-name { font-family: var(--serif); font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.ar-type { font-size: .78rem; color: var(--muted); }
.ar-badge { font-size: .72rem; padding: .15rem .55rem; border-radius: 2px; color: #fff; letter-spacing: 1px; box-shadow: inset 0 0 0 1px rgba(255,244,230,.3); }
.ar-badge.st-pending  { background: #b07b2a; }
.ar-badge.st-approved { background: var(--ok); }
.ar-badge.st-rejected { background: var(--muted); }
.ar-badge.st-draft    { background: var(--ink-3); }
.ar-addr { font-size: .85rem; color: #6f5d44; margin-top: .35rem; }
.ar-meta { font-size: .76rem; color: var(--muted); margin-top: .15rem; }
.admin-empty { text-align: center; color: var(--muted); padding: 2rem; }

/* 批次匯入彈窗（admin） */
.modal.modal-wide { max-width: 680px; }
#importText {
  width: 100%; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .82rem;
  padding: .7rem .8rem; border: 1px solid var(--paper-line); border-radius: var(--radius);
  background: #fffdf8; color: var(--ink); resize: vertical; line-height: 1.5;
}
#importText:focus { outline: none; border-color: var(--cinnabar); box-shadow: 0 0 0 3px rgba(196,38,29,.12); }
.import-actions { display: flex; align-items: center; gap: .6rem; margin-top: .7rem; }
.import-file-label { position: relative; overflow: hidden; cursor: pointer; }
.import-file-label input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.import-summary { font-size: .88rem; color: var(--ink-on-paper); margin: .2rem 0 .7rem; }
.import-summary .imp-ok { color: var(--ok); } .import-summary .imp-geo { color: #b07b2a; }
.import-summary .imp-bad { color: var(--cinnabar); } .import-summary .imp-dup { color: var(--muted); }
.import-controls { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .6rem; flex-wrap: wrap; }
.imp-status { font-size: .85rem; color: var(--muted); display: inline-flex; align-items: center; gap: .4rem; }
.imp-status select { padding: .4rem .5rem; font-family: var(--sans); border: 1px solid var(--paper-line); border-radius: var(--radius); background: #fffdf8; color: var(--ink); }
.import-table-wrap { max-height: 46vh; overflow: auto; border: 1px solid var(--paper-line); border-radius: var(--radius); }
.import-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.import-table th, .import-table td { padding: .4rem .55rem; text-align: left; border-bottom: 1px solid var(--paper-line); white-space: nowrap; }
.import-table td:nth-child(4) { white-space: normal; min-width: 9rem; }
.imp-head th { position: sticky; top: 0; background: var(--paper-2); font-family: var(--serif); font-weight: 700; color: var(--ink); }
.imp-row.imp-bad { background: rgba(196,38,29,.07); }
.imp-row.imp-geo .imp-status-cell { color: #b07b2a; }
.imp-row.imp-bad .imp-status-cell { color: var(--cinnabar); font-weight: 700; }
.imp-row.imp-ok .imp-status-cell { color: var(--ok); }
.imp-row.imp-dup .imp-status-cell { color: var(--muted); }
