/* คณะสงฆ์ธรรมยุต จังหวัดลพบุรี — โทนฟ้าคราม ขาว ทอง ตามพระอุโบสถ
   mobile-first: แถบเมนูล่างบนมือถือ → เมนูบนเมื่อจอ ≥ 900px */

:root {
  --sky: #1F5FA8;
  --sky-deep: #123B6B;
  --sky-wash: #EAF2FB;
  --gold: #B88A2E;
  --gold-soft: #F7EED9;
  --bg: #F7F9FC;
  --paper: #FFFFFF;
  --ink: #16243A;
  --ink-2: #4B5B73;
  --line: #DCE5F0;
  --ok: #2E6B3A;
  --danger: #9B2C14;
  --shadow: 0 1px 2px rgba(18, 59, 107, .06), 0 8px 24px rgba(18, 59, 107, .07);

  /* ฟอนต์ตามบทบาท (assets/fonts/fonts.css) */
  --f-logo: 'Mitr', Tahoma, sans-serif;
  --f-head: 'Kanit', Tahoma, sans-serif;
  --f-title: 'Prompt', Tahoma, sans-serif;
  --f-ui: 'Anuphan', Tahoma, sans-serif;
  --f-body: 'Noto Sans Thai', Tahoma, 'Leelawadee UI', sans-serif;
  --f-num: 'IBM Plex Sans Thai', Tahoma, sans-serif;
  --f-note: 'Athiti', Tahoma, sans-serif;

  --r-btn: 10px;
  --r-card: 14px;
  --tab-h: 62px;

  /* ชื่อเดิมที่หลังบ้านใช้ */
  --accent: var(--sky);
  --link: var(--sky);
  --sand: var(--sky-wash);
  --body2: var(--ink-2);
  --muted: var(--ink-2);
  --serif: var(--f-head);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-admin]) {
    --sky: #86B6EE; --sky-deep: #0C1F38; --sky-wash: #14263F; --gold: #DDB96C; --gold-soft: #2B2514;
    --bg: #0A1524; --paper: #102036; --ink: #E8EEF7; --ink-2: #A6B4C8; --line: #22364F;
    --ok: #8CC79A; --danger: #F0907A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"]:not([data-admin]) {
  --sky: #86B6EE; --sky-deep: #0C1F38; --sky-wash: #14263F; --gold: #DDB96C; --gold-soft: #2B2514;
  --bg: #0A1524; --paper: #102036; --ink: #E8EEF7; --ink-2: #A6B4C8; --line: #22364F;
  --ok: #8CC79A; --danger: #F0907A;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--f-body); font-size: 17px; line-height: 1.75;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
}
body.admin, body:has(.login-wrap) { padding-bottom: 0; }
img { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; text-wrap: balance; color: var(--ink); }
h1, h2 { font-family: var(--f-head); }
h1 { font-weight: 700; }
h2 { font-weight: 500; }
h3, h4 { font-family: var(--f-title); font-weight: 600; }
p { margin: 0; }
b, strong { font-weight: 600; }
button, input, select, textarea, .btn, .chip, nav { font-family: var(--f-ui); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.num, time { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--paper); padding: 8px 14px; border-radius: 8px; }
.skip:focus { top: 12px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }

.container {
  width: 100%; max-width: 1160px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
@media (min-width: 700px) { .container { padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px)); } }
.section { padding-block: 44px; }
@media (min-width: 900px) { .section { padding-block: 64px; } }
.band { background: var(--sky-wash); }

.eyebrow { display: inline-block; font-family: var(--f-ui); font-size: 13.5px; font-weight: 600; letter-spacing: .06em; color: var(--gold); }
.eyebrow.on-dark { color: #F3DFAE; }
.section-head { display: grid; gap: 6px; margin-bottom: 24px; }
.section-head h2 { font-size: clamp(25px, 5.6vw, 36px); }
.section-head p { color: var(--ink-2); max-width: 44em; }
.section-head.row { grid-template-columns: 1fr; align-items: end; gap: 14px; }
@media (min-width: 800px) { .section-head.row { grid-template-columns: 1fr auto; } }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-card); }

/* ---------- buttons, chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 20px; border-radius: 999px; border: 1px solid transparent;
  font-size: 16px; font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2;
}
.btn-accent { background: var(--sky); color: #fff; }
.btn-accent:hover { background: var(--sky-deep); }
.btn-gold { background: #E9C774; color: #2A1E05; }
.btn-gold:hover { background: #F1D58F; }
.btn-glass { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .6); color: #fff; }
.btn-outline { background: transparent; border-color: var(--sky); color: var(--sky); }
:root[data-theme="dark"]:not([data-admin]) .btn-accent { color: #0A1524; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-admin]) .btn-accent { color: #0A1524; } }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 6px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-2); font-size: 15px; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.chip[aria-current="true"], .chip[aria-pressed="true"] { background: var(--sky); border-color: var(--sky); color: var(--paper); font-weight: 600; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px);
}
.top-in { display: flex; align-items: center; gap: 12px; min-height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand .chakra { flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-family: var(--f-logo); font-weight: 600; font-size: 17px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-family: var(--f-note); font-weight: 500; font-size: 13px; color: var(--ink-2); line-height: 1.2; }
.topnav { display: none; margin-left: auto; gap: 2px; }
.topnav a { text-decoration: none; color: var(--ink-2); padding: 8px 14px; border-radius: 999px; font-size: 15.5px; }
.topnav a:hover { background: var(--sky-wash); color: var(--sky); }
.topnav a[aria-current="page"] { color: var(--sky); font-weight: 600; background: var(--sky-wash); }
.theme-btn { margin-left: auto; flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); color: var(--ink-2); display: grid; place-items: center; cursor: pointer; }
@media (min-width: 900px) { .topnav { display: flex; } .theme-btn { margin-left: 6px; } }

/* ---------- bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
.tabbar a { display: grid; justify-items: center; align-content: center; gap: 1px; height: var(--tab-h); text-decoration: none; color: var(--ink-2); font-family: var(--f-ui); font-size: 12.5px; }
.tabbar a[aria-current="page"] { color: var(--sky); font-weight: 600; }
@media (min-width: 900px) { .tabbar { display: none; } body { padding-bottom: 0; } }

/* ---------- home hero ---------- */
.hero { position: relative; overflow: hidden; background: var(--sky-deep); color: #fff; isolation: isolate; }
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 62% 50%; z-index: -2; }
.hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(10, 32, 64, 0) 0%, rgba(10, 32, 64, .25) 40%, rgba(10, 32, 64, .88) 100%); }
.hero-in { display: grid; gap: 14px; padding-block: 140px 32px; }
.hero h1 { color: #fff; font-size: clamp(32px, 7.6vw, 56px); text-shadow: 0 2px 18px rgba(0, 0, 0, .25); }
.hero .lead { max-width: 36em; color: #E3ECF7; font-size: clamp(15.5px, 3.8vw, 19px); }
.cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.uposatha { display: inline-flex; gap: 8px; align-items: center; width: fit-content; max-width: 100%; margin-top: 6px; padding: 6px 14px; border-radius: 999px; background: rgba(233, 199, 116, .18); border: 1px solid rgba(233, 199, 116, .5); color: #F7E7BF; font-family: var(--f-ui); font-size: 14.5px; }
@media (min-width: 900px) { .hero-in { padding-block: 230px 56px; } }

.stats-band { background: var(--paper); border-bottom: 1px solid var(--line); padding-block: 20px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.stat { background: var(--paper); padding: 14px 16px; display: flex; flex-direction: column; text-decoration: none; color: var(--ink); }
.stat b, .stat .n { font-family: var(--f-num); font-weight: 600; font-size: 30px; color: var(--sky); line-height: 1.15; }
.stat span { font-size: 14px; color: var(--ink-2); }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }

/* chief */
.chief { display: grid; gap: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); }
.chief-photo { width: 120px; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; background: var(--gold-soft); display: grid; place-items: center; border: 1px solid var(--line); }
.chief-photo img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.chief-body { display: grid; gap: 4px; align-content: start; min-width: 0; }
.chief-body h3 { font-size: clamp(22px, 5vw, 28px); }
.chief blockquote { margin: 12px 0 4px; padding: 4px 0 4px 16px; border-left: 3px solid var(--gold); font-family: var(--f-body); }
@media (min-width: 700px) { .chief { grid-template-columns: 160px 1fr; padding: 28px; } .chief-photo { width: 160px; } }

/* zone cards (home) */
.zone-cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .zone-cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .zone-cards { grid-template-columns: repeat(3, 1fr); } }
.zone-card { display: flex; gap: 14px; align-items: center; padding: 14px 16px; text-decoration: none; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.zone-card:hover { border-color: var(--sky); box-shadow: var(--shadow); }
.zone-text { display: grid; min-width: 0; }
.zone-text strong { font-family: var(--f-title); font-weight: 600; font-size: 16.5px; line-height: 1.4; }
.zname { font-family: var(--f-ui); font-size: 13px; font-weight: 600; color: var(--sky); letter-spacing: .02em; }
.avatar { width: 58px; height: 58px; flex: none; border-radius: 50%; overflow: hidden; background: var(--gold-soft); display: grid; place-items: center; box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--gold); }
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: top; }

.quick { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 800px) { .quick { grid-template-columns: repeat(3, 1fr); } }
.quick-card { display: grid; gap: 2px; padding: 18px 20px; text-decoration: none; color: var(--ink); }
.quick-card strong { font-family: var(--f-title); font-size: 18px; }
.quick-card:hover { border-color: var(--sky); }

/* ---------- inner page hero ---------- */
.page-hero { background: linear-gradient(160deg, var(--sky-deep), #1A4F8C); color: #E3ECF7; padding-block: 28px 32px; }
.page-hero h1 { color: #fff; font-size: clamp(28px, 6.4vw, 44px); }
.page-hero p { margin-top: 6px; max-width: 46em; }
.page-hero.has-overlap { padding-bottom: 72px; }
.breadcrumb { font-family: var(--f-note); font-weight: 500; font-size: 14.5px; color: #B9CCE6; margin-bottom: 6px; }
.breadcrumb a { color: #E9C774; text-decoration: none; }
@media (min-width: 900px) { .page-hero { padding-block: 48px 52px; } .page-hero.has-overlap { padding-bottom: 96px; } }

/* prose */
.prose { display: grid; gap: 14px; max-width: 44em; }
.prose h2 { font-size: 24px; }
.notice { background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); border-radius: var(--r-btn); padding: 12px 16px; font-family: var(--f-note); font-weight: 500; font-size: 15.5px; color: var(--ink); }
.empty { text-align: center; padding: 32px 16px; color: var(--ink-2); background: var(--paper); border: 1px dashed var(--line); border-radius: var(--r-card); }
.link-more { font-family: var(--f-ui); font-weight: 600; text-decoration: none; }

/* about */
.grid-3 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.duty { padding: 18px 20px; display: grid; gap: 4px; }
.duty .num { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--gold); color: var(--gold); font-weight: 600; }
.duty p { color: var(--ink-2); font-size: 15.5px; }

/* ---------- officials ---------- */
.org-level { display: grid; gap: 18px; margin-bottom: 48px; }
.org-level > h2 { font-size: clamp(22px, 5vw, 30px); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.org-level > h2 .num { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; border: 2px solid var(--gold); color: var(--gold); font-size: 17px; }
.grid-officials { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 800px) { .grid-officials { grid-template-columns: 1fr 2fr; } }
.official-card { display: flex; gap: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px; box-shadow: var(--shadow); }
.official-card .photo { width: 104px; flex: none; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; background: var(--gold-soft); display: grid; place-items: center; }
.official-card .photo img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.official-card .info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.role { font-family: var(--f-ui); font-size: 13.5px; font-weight: 600; color: var(--gold); letter-spacing: .02em; }
.o-name { font-family: var(--f-title); font-weight: 600; font-size: 18px; line-height: 1.4; }
.o-meta { color: var(--ink-2); font-size: 15px; }
.footer-title { font-family: var(--f-title); font-weight: 600; }
.person-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.person-list li { display: flex; flex-direction: column; gap: 1px; padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.person-list li:last-child { border-bottom: 0; }
.person-list .o-name { font-size: 16.5px; }
.zone { padding: 18px; display: grid; gap: 10px; }
.zone h3 { font-size: 20px; color: var(--sky); }
.zone-sub { font-family: var(--f-note); font-weight: 500; color: var(--ink-2); font-size: 15px; }
.zone-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 800px) { .zone { padding: 24px; } .zone-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 28px; } }
.lead-official { display: flex; gap: 14px; align-items: flex-start; }
.lead-official .avatar { width: 72px; height: 72px; }
.span-2 { min-width: 0; }

/* ---------- temples ---------- */
.filter-panel { margin-top: -56px; position: relative; }
.filter-box { display: grid; gap: 16px; padding: 18px; box-shadow: var(--shadow); }
.field-label { font-family: var(--f-ui); font-weight: 600; font-size: 15px; }
.search-field { position: relative; display: flex; gap: 8px; }
.search-field svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-2); pointer-events: none; }
.search-field input { flex: 1; min-width: 0; min-height: 48px; padding: 10px 14px 10px 44px; border-radius: var(--r-btn); border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); font-size: 16.5px; }
.search-field input:focus { border-color: var(--sky); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--sky) 20%, transparent); }
.js [data-nojs-only] { display: none; }
@media (min-width: 900px) { .filter-panel { margin-top: -72px; } .filter-box { padding: 24px; } }
.results-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px; color: var(--ink-2); font-size: 15px; }
.results-meta strong { color: var(--ink); font-family: var(--f-num); }
.temple-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .temple-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1050px) { .temple-grid { grid-template-columns: repeat(3, 1fr); } }
.temple-card { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.temple-card .photo { aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--sky-wash), var(--gold-soft)); display: grid; place-items: center; color: var(--gold); }
.temple-card .photo img { width: 100%; height: 100%; object-fit: cover; }
.temple-card .info { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.temple-card h2 { font-family: var(--f-title); font-weight: 600; font-size: 18.5px; }
.temple-card h2 a { color: var(--ink); text-decoration: none; }
.temple-card h2 a:hover { color: var(--sky); }
.temple-card .line { font-size: 14.5px; color: var(--ink-2); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-family: var(--f-ui); font-size: 12.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--sky-wash); color: var(--sky); }
.tag-district { background: transparent; border: 1px solid var(--line); color: var(--ink-2); }
.tag-royal { background: var(--gold-soft); color: var(--gold); }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: auto; padding-top: 8px; font-family: var(--f-ui); font-weight: 600; font-size: 15px; }
.card-actions a { text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; }

/* temple detail / contact */
.detail { display: grid; gap: 24px; grid-template-columns: 1fr; padding-block: 32px 72px; }
@media (min-width: 900px) { .detail { grid-template-columns: minmax(0, 1fr) 360px; gap: 40px; padding-block: 48px 96px; align-items: start; } }
.detail-photo { aspect-ratio: 16 / 10; border-radius: var(--r-card); overflow: hidden; background: linear-gradient(135deg, var(--sky-wash), var(--gold-soft)); display: grid; place-items: center; color: var(--gold); }
.detail-photo img { width: 100%; height: 100%; object-fit: cover; }
.info-card { padding: 20px; display: grid; gap: 14px; }
@media (min-width: 900px) { .info-card { position: sticky; top: 84px; } }
.info-card h2 { font-size: 22px; }
.info-card dl { margin: 0; display: grid; gap: 10px; }
.info-card dl > div { display: grid; gap: 0; }
.info-card dt { font-family: var(--f-note); font-weight: 500; font-size: 14px; color: var(--ink-2); }
.info-card dd { margin: 0; }

/* ---------- news ---------- */
.news-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .news-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .news-grid { grid-template-columns: repeat(3, 1fr); } }
.news-card { display: flex; flex-direction: column; overflow: hidden; text-decoration: none; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.news-card:hover { border-color: var(--sky); box-shadow: var(--shadow); }
.news-card .cover { aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--sky-wash), var(--gold-soft)); display: grid; place-items: center; color: var(--gold); overflow: hidden; }
.news-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.news-card .info { padding: 14px 16px 18px; display: grid; gap: 6px; }
.n-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 13.5px; color: var(--gold); font-weight: 600; }
.n-cat { font-family: var(--f-ui); font-size: 12.5px; padding: 2px 10px; border-radius: 999px; background: var(--sky-wash); color: var(--sky); }
.n-title { font-size: 17.5px; font-weight: 500; line-height: 1.5; }
.pagination { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 32px; font-family: var(--f-num); }
.pagination a, .pagination span { min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); text-decoration: none; }
.pagination span[aria-current] { background: var(--sky); border-color: var(--sky); color: var(--paper); font-weight: 600; }
.article { display: grid; gap: 24px; padding-block: 32px 64px; max-width: 860px; }
.article .cover img { width: 100%; border-radius: var(--r-card); }

/* ---------- footer ---------- */
.foot { background: var(--sky-deep); color: #D3E0F1; padding-block: 40px 28px; font-size: 15.5px; }
:root[data-theme="dark"]:not([data-admin]) .foot { background: #07111F; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-admin]) .foot { background: #07111F; } }
.foot a { color: #fff; text-decoration: none; }
.foot a:hover { text-decoration: underline; }
.foot-grid { display: grid; gap: 26px; }
@media (min-width: 800px) { .foot-grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.foot-brand { display: flex; align-items: center; gap: 10px; font-family: var(--f-logo); font-weight: 600; font-size: 18px; color: #fff; margin-bottom: 8px; }
.foot-title { font-family: var(--f-title); font-weight: 600; font-size: 16.5px; color: #fff; margin-bottom: 8px; }
.foot-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.foot-note { margin-top: 28px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .14); font-family: var(--f-note); font-weight: 500; font-size: 14px; color: #A9BCD6; }
.foot-note a { color: #E9C774; }

/* ---------- แผนภูมิการปกครอง (หน้าทำเนียบ) ----------
   มือถือ: ต้นไม้แนวตั้ง เส้นทองด้านซ้าย · จอ ≥ 1000px: แผนภูมิบนลงล่าง ๖ เขตเรียงแถว */
.pill { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 999px; background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent); font-size: 14px; line-height: 1.5; }
.orgchart { --rail: 2px solid var(--gold); margin-bottom: 56px; padding: 20px 16px 24px; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
@media (min-width: 700px) { .orgchart { padding: 28px 28px 32px; } }
.oc-node { display: grid; gap: 1px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: var(--ink); min-width: 0; position: relative; }
.oc-level { font-family: var(--f-ui); font-size: 12.5px; font-weight: 600; letter-spacing: .03em; color: var(--ink-2); }
.oc-name { font-family: var(--f-title); font-weight: 600; font-size: 16.5px; line-height: 1.4; }
.oc-row { display: flex; gap: 12px; align-items: center; margin-top: 4px; }
.oc-row .avatar { width: 52px; height: 52px; }
.oc-text { display: grid; min-width: 0; }
.oc-text .o-meta, .oc-node > .o-meta { font-size: 14px; }
.oc-region { background: var(--sky-deep); border-color: var(--sky-deep); color: #fff; }
.oc-region .oc-level, .oc-region .o-meta { color: #B9CCE6; }
.oc-region .role { color: #E9C774; }
.oc-region .oc-name { color: #fff; }
.oc-chief { border: 2px solid var(--gold); background: var(--gold-soft); }
.oc-chief .oc-name { font-size: 19px; }
.oc-advisors { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed color-mix(in srgb, var(--gold) 45%, transparent); }
.oc-sub-label { width: 100%; font-family: var(--f-note); font-weight: 500; font-size: 14px; color: var(--ink-2); }
.oc-zone { border-color: color-mix(in srgb, var(--sky) 45%, var(--line)); border-top: 4px solid var(--sky); }
.oc-zone .oc-level { color: var(--sky); font-size: 13.5px; }
.oc-zone:hover { box-shadow: var(--shadow); }
.oc-sub { padding: 8px 12px; border-style: dashed; }
.oc-sub .role { font-size: 12.5px; color: var(--ink-2); }
.oc-sub .oc-name { font-size: 15px; }
.oc-sub .o-meta { font-size: 13.5px; }

/* mobile: vertical tree */
.oc-spine { display: grid; justify-items: stretch; }
.oc-stem { width: 2px; height: 20px; background: var(--gold); margin-left: 26px; }
.oc-zones, .oc-subs { list-style: none; margin: 0; padding: 0; }
.oc-zones { margin-left: 26px; border-left: var(--rail); }
.oc-zones > li { position: relative; padding: 10px 0 10px 18px; }
.oc-zones > li::before { content: ""; position: absolute; left: 0; top: 34px; width: 16px; border-top: var(--rail); }
.oc-zones > li:last-child::after { content: ""; position: absolute; left: -2px; top: 35px; bottom: 0; width: 2px; background: var(--paper); }
.oc-subs { margin: 8px 0 0 22px; border-left: 2px dotted color-mix(in srgb, var(--sky) 50%, var(--line)); display: grid; gap: 6px; padding: 4px 0 0 14px; }
.oc-subs > li { position: relative; }
.oc-subs > li::before { content: ""; position: absolute; left: -15px; top: 20px; width: 13px; border-top: 2px dotted color-mix(in srgb, var(--sky) 50%, var(--line)); }

/* tablet: zones 2 columns, still connected on the left */
@media (min-width: 640px) and (max-width: 999px) {
  .oc-zones { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; }
  .oc-zones > li:last-child::after { display: none; }
}

/* desktop: top-down chart */
@media (min-width: 1000px) {
  .oc-spine { justify-items: center; }
  .oc-region, .oc-chief { width: min(100%, 560px); text-align: center; }
  .oc-chief .oc-row { justify-content: center; text-align: left; }
  .oc-advisors { justify-content: center; }
  .oc-stem { margin: 0 auto; height: 26px; }
  .oc-zones { margin: 0; border-left: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; }
  .oc-zones > li { padding: 26px 6px 0; }
  .oc-zones > li::before { left: 0; right: 0; top: 0; width: auto; border-top: var(--rail); }
  .oc-zones > li:first-child::before { left: 50%; }
  .oc-zones > li:last-child::before { right: 50%; }
  .oc-zones > li::after, .oc-zones > li:last-child::after { content: ""; position: absolute; left: calc(50% - 1px); top: 0; bottom: auto; width: 2px; height: 26px; background: var(--gold); display: block; }
  .oc-zone { text-align: center; padding: 12px 10px; }
  .oc-zone .oc-row { flex-direction: column; gap: 6px; }
  .oc-zone .oc-name { font-size: 15.5px; }
  .oc-subs { margin: 0 auto; border-left: 0; padding: 0; gap: 0; }
  .oc-subs > li { margin-top: 18px; text-align: center; }
  .oc-subs > li::before { left: calc(50% - 1px); top: -18px; width: 0; height: 18px; border-top: 0; border-left: 2px dotted color-mix(in srgb, var(--sky) 50%, var(--line)); }
}

.oc-legend { list-style: none; margin: 22px 0 0; padding: 14px 0 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px 18px; font-family: var(--f-note); font-weight: 500; font-size: 14px; color: var(--ink-2); }
.oc-legend li { display: inline-flex; align-items: center; gap: 8px; }
.oc-key { width: 18px; height: 12px; border-radius: 3px; border: 1px solid var(--line); }
.k-region { background: var(--sky-deep); }
.k-chief { background: var(--gold-soft); border: 2px solid var(--gold); }
.k-zone { background: var(--paper); border-top: 4px solid var(--sky); }
.k-sub { background: var(--paper); border-style: dashed; }
.grid-officials { align-items: start; }
.filter-box > * { min-width: 0; }
/* วัดที่ยังไม่มีภาพ: แถบตราเล็ก ๆ แทนกรอบภาพเต็ม เพื่อไม่ให้รายการยาวเกินบนมือถือ */
.temple-card .photo:not(:has(img)) { aspect-ratio: auto; height: 64px; }
.temple-card .photo:not(:has(img)) .chakra { width: 34px; height: 34px; }

/* ---------- ชุดสีสดใส ๖ สี (เขตปกครอง เมนู หมวดข่าว) ----------
   ทุกส่วนใช้ --hue ของตัวเอง แล้วผสมเป็นสีพื้นอ่อนด้วย color-mix ให้ใช้ได้ทั้งโหมดสว่างและมืด */
:root { --h1: #1F6FD1; --h2: #0E9F84; --h3: #E07B16; --h4: #D63F78; --h5: #7650D8; --h6: #C99A12; --hue: var(--sky); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-admin]) { --h1: #6FA8F0; --h2: #4FD1B5; --h3: #F5A55A; --h4: #F17FA8; --h5: #A98DF2; --h6: #E8C55A; } }
:root[data-theme="dark"]:not([data-admin]) { --h1: #6FA8F0; --h2: #4FD1B5; --h3: #F5A55A; --h4: #F17FA8; --h5: #A98DF2; --h6: #E8C55A; }
.c1, .cat-gov { --hue: var(--h1); }
.c2 { --hue: var(--h2); }
.c3, .cat-act { --hue: var(--h3); }
.c4 { --hue: var(--h4); }
.c5, .cat-edu { --hue: var(--h5); }
.c6 { --hue: var(--h6); }
[class*="c"], [class*="cat-"] { --tint: color-mix(in srgb, var(--hue) 12%, var(--paper)); --tint-2: color-mix(in srgb, var(--hue) 24%, var(--paper)); }

/* แถบสีรุ้งใต้หัวเว็บ */
.rainbow, .top::after, .page-hero::after {
  background: linear-gradient(90deg, var(--h1) 0 16.6%, var(--h2) 16.6% 33.3%, var(--h3) 33.3% 50%, var(--h4) 50% 66.6%, var(--h5) 66.6% 83.3%, var(--h6) 83.3% 100%);
}
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; }
.page-hero { position: relative; }
.page-hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; }

/* เมนูบน */
.topnav a[class^="c"] { color: var(--hue); font-weight: 500; }
.topnav a[class^="c"]:hover { background: var(--tint); color: var(--hue); }
.topnav a[class^="c"][aria-current="page"] { background: var(--hue); color: #fff; }

/* แถบเมนูล่าง: ไอคอนในวงสีของตัวเอง */
.tabbar { box-shadow: 0 -6px 20px rgba(18, 59, 107, .08); }
.tabbar::before { content: ""; position: absolute; left: 0; right: 0; top: -3px; height: 3px; background: linear-gradient(90deg, var(--h1), var(--h2), var(--h3), var(--h4), var(--h5)); }
.tabbar a[class^="c"] { color: var(--hue); font-weight: 500; }
.tabbar a[class^="c"] svg { width: 40px; height: 30px; padding: 4px 9px; border-radius: 999px; background: var(--tint); transition: background .15s, color .15s; }
.tabbar a[class^="c"][aria-current="page"] svg { background: var(--hue); color: #fff; }
.tabbar a[class^="c"][aria-current="page"] { font-weight: 700; }

/* ชิปกรอง */
.chip[class*=" c"], .chip[class*="cat-"] { background: var(--tint); border-color: color-mix(in srgb, var(--hue) 35%, transparent); color: var(--hue); font-weight: 500; }
.chip[class*=" c"][aria-current="true"], .chip[class*="cat-"][aria-current="true"], .chip[class*="cat-"][aria-pressed="true"] { background: var(--hue); border-color: var(--hue); color: #fff; font-weight: 600; }

/* ตัวเลขสรุป */
.stats { background: transparent; border: 0; gap: 10px; border-radius: 0; overflow: visible; }
.stat[class*=" c"] { background: var(--tint); border-radius: var(--r-card); border: 1px solid color-mix(in srgb, var(--hue) 25%, transparent); }
.stat[class*=" c"] b { color: var(--hue); }

/* การ์ดเขต / ทางลัด */
.zone-card[class*=" c"] { background: linear-gradient(120deg, var(--tint), var(--paper) 70%); border-left: 5px solid var(--hue); }
.zone-card[class*=" c"]:hover { border-color: var(--hue); }
.zone-card[class*=" c"] .zname { color: var(--hue); }
.zone-card[class*=" c"] .avatar { background: var(--tint-2); color: var(--hue); box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--hue); }
.zone-card[class*=" c"] .chakra { stroke: var(--hue); }
.zone-card[class*=" c"] .chakra circle[fill] { fill: var(--hue); }
.quick-card[class*=" c"] { background: var(--tint); border-color: color-mix(in srgb, var(--hue) 30%, transparent); border-top: 5px solid var(--hue); }
.quick-card[class*=" c"] .eyebrow { color: var(--hue); }

/* แผนภูมิ: แต่ละเขตสีของตัวเอง */
.oc-zones > li[class^="c"] .oc-zone { border-top-color: var(--hue); background: var(--tint); border-color: color-mix(in srgb, var(--hue) 35%, var(--line)); border-top-width: 4px; }
.oc-zones > li[class^="c"] .oc-zone .oc-level { color: var(--hue); }
.oc-zones > li[class^="c"] .avatar { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--hue); background: var(--tint-2); }
.oc-zones > li[class^="c"] .chakra { stroke: var(--hue); }
.oc-zones > li[class^="c"] .chakra circle[fill] { fill: var(--hue); }
.oc-zones > li[class^="c"] .oc-subs { border-left-color: var(--hue); }
.oc-zones > li[class^="c"] .oc-sub { border-color: color-mix(in srgb, var(--hue) 40%, var(--line)); }
.oc-zones > li[class^="c"] .oc-sub .role { color: var(--hue); }
.oc-zones > li[class^="c"] .oc-subs > li::before { border-color: var(--hue); }

/* รายละเอียดเขต (หน้าทำเนียบ) */
.zone[class*=" c"] { border-top: 5px solid var(--hue); }
.zone[class*=" c"] h3 { color: var(--hue); }

/* การ์ดวัด: สีตามเขต */
.temple-card[class*=" c"] { border-top: 4px solid var(--hue); }
.temple-card[class*=" c"] .photo { background: linear-gradient(135deg, var(--tint-2), var(--tint)); }
.temple-card[class*=" c"] .photo .chakra { stroke: var(--hue); }
.temple-card[class*=" c"] .photo .chakra circle[fill] { fill: var(--hue); }
.temple-card[class*=" c"] .tag-district { background: var(--tint); border-color: transparent; color: var(--hue); }

/* การ์ดข่าว: สีตามหมวด */
.news-card[class*="cat-"] { border-top: 4px solid var(--hue); }
.news-card[class*="cat-"] .n-cat { background: var(--tint); color: var(--hue); }
.news-card[class*="cat-"] .cover { background: linear-gradient(135deg, var(--tint-2), var(--tint)); }
