/* ============================================================
   โอฆะบุรี เฟื่องนคร — สไตล์หลักของเว็บไซต์
   ฟอนต์: Pridi (หัวข้อ/เมนู) · Niramit (เนื้อหา)
   โทนสี: ดินเผา–น้ำตาล + เขียวใบไม้
   ============================================================ */

:root {
  --ink: #493628;
  --ink-soft: #6b5344;
  --brown: #AB886D;
  --brown-d: #8c6b52;
  --sand: #D6C0B3;
  --paper: #E4E0E1;
  --cream: #FBF8F5;
  --green-d: #597445;
  --green: #658147;
  --green-l: #729762;
  --mint: #E7F0DC;
  --white: #ffffff;

  --radius: 18px;
  --radius-lg: 26px;
  --shadow-sm: 0 2px 10px rgba(73, 54, 40, .07);
  --shadow: 0 10px 30px rgba(73, 54, 40, .10);
  --shadow-lg: 0 26px 60px rgba(73, 54, 40, .18);
  --container: 1200px;
  --head-h: 76px;

  --font-head: 'Pridi', 'Niramit', serif;
  --font-body: 'Niramit', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.8;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, .font-head { font-family: var(--font-head); font-weight: 600; line-height: 1.35; margin: 0 0 .6em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.28rem; }
p { margin: 0 0 1em; }
a { color: var(--green-d); text-decoration: none; transition: color .2s; }
a:hover { color: var(--brown-d); }
img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--paper); margin: 28px 0; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.muted { color: var(--ink-soft); }
.text-center { text-align: center; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 0 0 10px 0;
}
.skip-link:focus { left: 0; }

/* ---------------- แถบบนสุด ---------------- */
.topbar {
  background: var(--ink);
  color: rgba(255, 255, 255, .82);
  font-size: .84rem;
}
.topbar-in { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 38px; flex-wrap: wrap; }
.topbar a { color: rgba(255, 255, 255, .82); }
.topbar a:hover { color: var(--mint); }
.topbar-links { display: flex; gap: 18px; }
.topbar-org { opacity: .9; }

/* ---------------- ส่วนหัว/เมนู ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, .93);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid rgba(214, 192, 179, .55);
  transition: box-shadow .25s;
}
.site-header.scrolled { box-shadow: 0 6px 24px rgba(73, 54, 40, .12); }
.header-in { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: var(--head-h); }

.brand { display: flex; align-items: center; gap: 13px; color: var(--ink); }
.brand-mark {
  width: 50px; height: 50px; border-radius: 15px; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--brown), var(--ink));
  box-shadow: var(--shadow-sm);
}
.brand-logo-img { width: 52px; height: 52px; object-fit: contain; }
.brand-text strong { display: block; font-family: var(--font-head); font-size: 1.32rem; font-weight: 600; line-height: 1.2; }
.brand-text small { display: block; font-size: .74rem; color: var(--ink-soft); line-height: 1.4; max-width: 340px; }

.main-nav ul { list-style: none; display: flex; align-items: center; gap: 4px; margin: 0; padding: 0; }
.main-nav > ul > li > a {
  font-family: var(--font-head); font-size: 1.01rem; font-weight: 500;
  color: var(--ink); padding: 10px 15px; border-radius: 11px; display: block; white-space: nowrap;
  transition: background .2s, color .2s;
}
.main-nav > ul > li > a:hover { background: var(--mint); color: var(--green-d); }
.main-nav > ul > li > a.active { background: var(--ink); color: #fff; }
.main-nav li.has-sub { position: relative; }
.main-nav .sub {
  display: none; position: absolute; top: 100%; left: 0; min-width: 230px;
  background: #fff; border: 1px solid var(--paper); border-radius: 14px;
  box-shadow: var(--shadow); padding: 8px; flex-direction: column; gap: 2px;
}
.main-nav li.has-sub:hover .sub, .main-nav li.has-sub:focus-within .sub { display: flex; }
.main-nav .sub a { display: block; padding: 9px 13px; border-radius: 9px; color: var(--ink); font-size: .96rem; }
.main-nav .sub a:hover { background: var(--mint); color: var(--green-d); }

.nav-toggle {
  display: none; width: 46px; height: 42px; border: 1px solid var(--sand); background: #fff;
  border-radius: 12px; cursor: pointer; padding: 10px 11px; flex-direction: column; justify-content: space-between;
}
.nav-toggle span { display: block; height: 2px; background: var(--ink); border-radius: 2px; transition: .25s; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

/* ---------------- แบนเนอร์หน้าแรก ---------------- */
.hero { position: relative; height: calc(100vh - var(--head-h) - 38px); min-height: 520px; overflow: hidden; background: var(--ink); }
.hero-slides { position: absolute; inset: 0; }
.hero-slide {
  position: absolute; inset: 0; opacity: 0; transform: scale(1.06);
  transition: opacity 1.1s ease, transform 7s ease;
  background-size: cover; background-position: center;
}
.hero-slide.on { opacity: 1; transform: scale(1); }
.hero-slide::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(73, 54, 40, .30) 0%, rgba(73, 54, 40, .58) 55%, rgba(73, 54, 40, .86) 100%);
}
.hero-empty { background: linear-gradient(140deg, #5a4433, #493628 45%, #3a2c21); }
.hero-inner {
  position: relative; z-index: 2; height: 100%;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; color: #fff; padding: 60px 20px 100px;
}
.hero-eyebrow {
  display: inline-block; font-family: var(--font-head); letter-spacing: .16em; font-size: .8rem;
  text-transform: uppercase; background: rgba(231, 240, 220, .16); border: 1px solid rgba(231, 240, 220, .38);
  padding: 7px 20px; border-radius: 999px; margin-bottom: 22px; backdrop-filter: blur(4px);
}
.hero h1 {
  font-family: var(--font-head); font-weight: 600;
  font-size: clamp(2.6rem, 7.4vw, 5.4rem); line-height: 1.1; margin: 0 0 18px;
  text-shadow: 0 8px 34px rgba(0, 0, 0, .42);
}
.hero-sub { font-size: clamp(1.02rem, 2.1vw, 1.42rem); max-width: 900px; margin: 0 auto 12px; font-weight: 300; }
.hero-note { font-size: .95rem; opacity: .82; max-width: 760px; margin: 0 auto; }
.hero-actions { margin-top: 30px; display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.hero-dots { position: absolute; bottom: 34px; left: 0; right: 0; z-index: 3; display: flex; gap: 10px; justify-content: center; }
.hero-dots button {
  width: 34px; height: 4px; border: 0; border-radius: 3px; background: rgba(255, 255, 255, .38); cursor: pointer; padding: 0;
  transition: background .3s, width .3s;
}
.hero-dots button.on { background: var(--mint); width: 54px; }
.hero-scroll {
  position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%); z-index: 3;
  color: rgba(255, 255, 255, .7); font-size: .8rem; letter-spacing: .1em; animation: bob 2.2s infinite;
}
@keyframes bob { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 8px); } }

/* ---------------- ปุ่ม ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  font-family: var(--font-head); font-size: 1rem; font-weight: 500;
  padding: 12px 26px; border-radius: 999px; border: 1.5px solid transparent;
  transition: transform .18s, box-shadow .18s, background .2s, color .2s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: linear-gradient(135deg, var(--green-d), var(--green)); color: #fff; box-shadow: 0 8px 22px rgba(89, 116, 69, .32); }
.btn-primary:hover { color: #fff; box-shadow: 0 12px 28px rgba(89, 116, 69, .42); }
.btn-earth { background: linear-gradient(135deg, var(--ink), var(--brown)); color: #fff; box-shadow: 0 8px 22px rgba(73, 54, 40, .3); }
.btn-earth:hover { color: #fff; }
.btn-ghost { border-color: rgba(255, 255, 255, .6); color: #fff; background: rgba(255, 255, 255, .08); backdrop-filter: blur(3px); }
.btn-ghost:hover { background: #fff; color: var(--ink); }
.btn-outline { border-color: var(--sand); color: var(--ink); background: #fff; }
.btn-outline:hover { border-color: var(--green); color: var(--green-d); }
.btn-sm { padding: 8px 18px; font-size: .92rem; }

/* ---------------- ส่วนย่อยของหน้า ---------------- */
.section { padding: 78px 0; }
.section-alt { background: linear-gradient(180deg, var(--mint) 0%, rgba(231, 240, 220, .25) 100%); }
.section-paper { background: var(--paper); }
.section-head { text-align: center; max-width: 780px; margin: 0 auto 46px; }
.section-head .eyebrow {
  display: inline-block; font-family: var(--font-head); letter-spacing: .18em; font-size: .78rem;
  color: var(--green-d); text-transform: uppercase; margin-bottom: 12px;
}
.section-head h2 { margin-bottom: 12px; }
.section-head p { color: var(--ink-soft); margin: 0; }
.divider-leaf { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 14px 0 0; color: var(--brown); }
.divider-leaf::before, .divider-leaf::after { content: ''; height: 1px; width: 60px; background: linear-gradient(90deg, transparent, var(--sand)); }

/* ---------------- การ์ดเมนู (แบบภาพตัวอย่าง) ---------------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 26px; }
.menu-card {
  position: relative; background: #fff; border: 1px solid var(--paper); border-radius: var(--radius);
  padding: 26px 26px 0; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-sm); transition: transform .25s, box-shadow .25s, border-color .25s;
}
.menu-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--brown), var(--green)); opacity: 0; transition: opacity .25s;
}
.menu-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); border-color: var(--sand); }
.menu-card:hover::before { opacity: 1; }
.menu-card .card-icon {
  width: 58px; height: 58px; border-radius: 15px; display: grid; place-items: center;
  background: var(--mint); color: var(--green-d); margin-bottom: 20px;
}
.menu-card .card-icon svg { width: 27px; height: 27px; }
.menu-card .card-badge {
  position: absolute; top: 24px; right: 26px; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; background: linear-gradient(140deg, var(--sand), var(--brown));
  color: #fff; border: 3px solid #fff; box-shadow: var(--shadow-sm);
}
.menu-card .card-badge svg { width: 24px; height: 24px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600;
  background: var(--mint); color: var(--green-d); padding: 4px 12px; border-radius: 8px; margin-bottom: 12px;
}
.chip-sand { background: rgba(214, 192, 179, .45); color: var(--brown-d); }
.menu-card .chip { align-self: flex-start; }
.menu-card h3 { font-size: 1.2rem; margin: 0 0 6px; }
.menu-card p { color: var(--ink-soft); font-size: .95rem; margin: 0 0 22px; flex: 1; }
.card-foot {
  border-top: 1px solid var(--paper); margin: 0 -26px; padding: 16px 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-foot .go-text { font-family: var(--font-head); font-weight: 500; color: var(--ink); font-size: .98rem; }
.card-foot .go-text span { color: var(--brown); font-size: .86rem; }
.go-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
  background: linear-gradient(140deg, var(--ink), var(--brown)); color: #fff; transition: transform .2s;
}
.menu-card:hover .go-btn { transform: translateX(3px) scale(1.06); }
.go-btn svg { width: 18px; height: 18px; }

/* ---------------- สถิติ ---------------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 20px; }
.stat {
  background: #fff; border: 1px solid var(--paper); border-radius: var(--radius);
  padding: 26px 24px; text-align: center; box-shadow: var(--shadow-sm);
}
.stat b { display: block; font-family: var(--font-head); font-size: 2.4rem; color: var(--green-d); line-height: 1.1; }
.stat span { color: var(--ink-soft); font-size: .95rem; }

/* ---------------- หัวหน้าใน ---------------- */
.page-hero {
  position: relative; padding: 62px 0 56px; color: #fff; overflow: hidden;
  background: linear-gradient(135deg, #4b3729 0%, #6d523d 55%, #8a6a4f 100%);
}
.page-hero::after {
  content: ''; position: absolute; right: -80px; bottom: -120px; width: 420px; height: 420px;
  border-radius: 50%; background: radial-gradient(circle, rgba(231, 240, 220, .16), transparent 70%);
}
.page-hero.green { background: linear-gradient(135deg, #4c6539 0%, #597445 50%, #74905a 100%); }
.page-hero h1 { margin: 0 0 10px; position: relative; z-index: 2; }
.page-hero p { margin: 0; max-width: 820px; opacity: .92; position: relative; z-index: 2; }
.breadcrumb { font-size: .88rem; opacity: .8; margin-bottom: 14px; position: relative; z-index: 2; }
.breadcrumb a { color: #fff; }
.breadcrumb span { margin: 0 8px; }

/* ---------------- ตัวกรอง ---------------- */
.filter-bar {
  background: #fff; border: 1px solid var(--paper); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); margin-bottom: 28px;
}
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; align-items: end; }
.field label { display: block; font-size: .84rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--paper); border-radius: 12px;
  font-family: inherit; font-size: .97rem; color: var(--ink); background: #fff; transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(101, 129, 71, .15);
}
.filter-actions { display: flex; gap: 10px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 22px; }
.pill {
  padding: 8px 18px; border-radius: 999px; border: 1.5px solid var(--paper); background: #fff;
  font-family: var(--font-head); font-size: .93rem; color: var(--ink); cursor: pointer;
}
.pill:hover { border-color: var(--brown); color: var(--brown-d); }
.pill.on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------------- ตาราง ---------------- */
.table-wrap { background: #fff; border: 1px solid var(--paper); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; min-width: 720px; }
table.data thead th {
  background: var(--ink); color: #fff; font-family: var(--font-head); font-weight: 500;
  text-align: left; padding: 15px 18px; font-size: .96rem; white-space: nowrap;
}
table.data tbody td { padding: 15px 18px; border-bottom: 1px solid var(--paper); vertical-align: top; font-size: .96rem; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: rgba(231, 240, 220, .38); }
table.data .grade-badge {
  display: inline-block; min-width: 52px; text-align: center; background: var(--mint); color: var(--green-d);
  font-family: var(--font-head); font-weight: 600; padding: 5px 12px; border-radius: 9px;
}
table.data td.cell-empty { text-align: center; background: rgba(228, 224, 225, .28); }
table.data td .dash { color: var(--sand); font-size: 1.1rem; }
table.data.matrix td, table.data.matrix th { padding: 13px 14px; }
table.data.matrix .col-grade {
  position: sticky; left: 0; z-index: 2; width: 100px;
  background: #fff; box-shadow: 3px 0 8px -4px rgba(73, 54, 40, .22);
}
table.data.matrix thead .col-grade { background: var(--ink); }
table.data.matrix tbody tr:hover .col-grade { background: #fbfaf8; }
table.data.list-view td { padding: 14px 16px; }
.table-hint { font-size: .85rem; margin-top: 12px; display: flex; align-items: center; gap: 7px; }
.chip-stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------------- การ์ดไฟล์ในตาราง ---------------- */
.doc-chip {
  display: flex; align-items: center; gap: 11px;
  background: #fff; border: 1px solid var(--paper); border-radius: 13px;
  padding: 9px 11px; transition: border-color .2s, box-shadow .2s, transform .2s;
}
.doc-chip:hover { border-color: var(--sand); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.doc-chip .file-tag { flex: 0 0 auto; height: 30px; min-width: 42px; border-radius: 8px; font-size: .7rem; }
.doc-chip-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-chip-title {
  font-weight: 600; color: var(--ink); font-size: .93rem; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.doc-chip-title:hover { color: var(--green-d); }
.doc-chip-meta { font-size: .78rem; color: var(--ink-soft); }
.doc-chip-act { display: flex; gap: 6px; flex: 0 0 auto; }
.mini-btn {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  background: var(--mint); color: var(--green-d); border: 1px solid transparent;
  font-size: .8rem; font-weight: 600; padding: 6px 11px; border-radius: 9px; transition: all .18s;
}
.mini-btn:hover { background: var(--green-d); color: #fff; }
.mini-btn.ghost { background: #fff; border-color: var(--paper); color: var(--ink-soft); }
.mini-btn.ghost:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.mini-btn svg { width: 15px; height: 15px; }

/* ในตารางเมทริกซ์ จัดการ์ดไฟล์เป็น 2 บรรทัด เพื่อให้ชื่อไฟล์อ่านง่ายในคอลัมน์แคบ */
table.data.matrix { table-layout: fixed; }
table.data.matrix .doc-chip {
  display: grid; grid-template-columns: auto 1fr; gap: 7px 9px;
  align-items: start; padding: 10px 11px;
}
table.data.matrix .doc-chip-act { grid-column: 1 / -1; }
table.data.matrix .mini-btn { flex: 1; justify-content: center; padding: 6px 9px; font-size: .78rem; }
table.data.matrix .doc-chip-title { font-size: .89rem; -webkit-line-clamp: 3; }
table.data.matrix .file-tag { min-width: 40px; height: 26px; margin-top: 2px; }

.file-link { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.file-tag {
  display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 26px;
  border-radius: 7px; font-size: .68rem; font-weight: 700; color: #fff; letter-spacing: .04em;
}
.ft-pdf { background: #c0392b; } .ft-doc { background: #2a5699; } .ft-xls { background: #217346; }
.ft-ppt { background: #d24726; } .ft-img { background: var(--brown); } .ft-video { background: #7a3fa0; }
.ft-zip { background: #7f8c8d; } .ft-file { background: var(--ink-soft); } .ft-link { background: var(--green); }

/* ---------------- การ์ดแหล่งเรียนรู้ ---------------- */
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 26px; }
.res-card {
  background: #fff; border: 1px solid var(--paper); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); transition: transform .25s, box-shadow .25s; display: flex; flex-direction: column;
}
.res-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.res-thumb { position: relative; aspect-ratio: 16/10; background: var(--paper) center/cover no-repeat; }
.res-thumb .no-img { position: absolute; inset: 0; display: grid; place-items: center; color: var(--brown); background: linear-gradient(140deg, var(--sand), var(--paper)); }
.res-thumb .type-chip {
  position: absolute; left: 14px; bottom: 14px; background: rgba(73, 54, 40, .86); color: #fff;
  font-size: .78rem; padding: 5px 13px; border-radius: 999px; backdrop-filter: blur(4px);
}
.res-body { padding: 20px 22px; flex: 1; display: flex; flex-direction: column; }
.res-body h3 { font-size: 1.12rem; margin: 0 0 8px; }
.res-body h3 a { color: var(--ink); }
.res-body h3 a:hover { color: var(--green-d); }
.res-meta { font-size: .87rem; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 10px; }
.res-body p { font-size: .93rem; color: var(--ink-soft); flex: 1; }
.res-foot { border-top: 1px solid var(--paper); padding: 13px 22px; display: flex; justify-content: space-between; align-items: center; font-size: .86rem; color: var(--ink-soft); }

/* ---------------- รายละเอียดแหล่งเรียนรู้ ---------------- */
.detail-wrap { display: grid; grid-template-columns: 1.55fr 1fr; gap: 36px; align-items: start; }
.detail-card { background: #fff; border: 1px solid var(--paper); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 32px 34px; }
.detail-title { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 8px; }
.stat-pills { display: flex; gap: 10px; margin: 6px 0 22px; }
.stat-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 15px; border-radius: 10px; font-size: .88rem; font-weight: 600; }
.stat-pill.views { background: #e8f1fb; color: #2a6fb0; }
.stat-pill.likes { background: #fdecec; color: #c0392b; cursor: pointer; border: 0; font-family: inherit; }
.stat-pill.likes:hover { background: #fbdcdc; }
.spec { display: grid; grid-template-columns: 190px 1fr; gap: 12px 18px; }
.spec dt { font-weight: 600; color: var(--ink-soft); }
.spec dd { margin: 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 22px; }
.gallery a { display: block; aspect-ratio: 4/3; border-radius: 14px; overflow: hidden; border: 1px solid var(--paper); }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.gallery a:hover img { transform: scale(1.07); }
.side-card { background: #fff; border: 1px solid var(--paper); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 22px; }
.side-card h4 { font-size: 1.05rem; margin: 0; padding: 16px 20px; background: var(--mint); color: var(--green-d); }
.side-card .side-body { padding: 18px 20px; }
.cover-lg { width: 100%; aspect-ratio: 4/3; object-fit: cover; }

/* ---------------- แผนที่บนหน้าแรก ---------------- */
.map-panel {
  display: grid; grid-template-columns: 1fr 320px; gap: 0;
  background: #fff; border: 1px solid var(--paper); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden;
}
#map.home-map { height: 540px; border: 0; border-radius: 0; box-shadow: none; }
.map-side {
  padding: 26px 24px; display: flex; flex-direction: column; gap: 14px;
  background: linear-gradient(180deg, #fff, var(--mint));
  border-left: 1px solid var(--paper);
}
.map-stat {
  display: flex; align-items: baseline; gap: 10px;
  background: #fff; border: 1px solid var(--paper); border-radius: 14px; padding: 12px 16px;
}
.map-stat b { font-family: var(--font-head); font-size: 1.7rem; color: var(--green-d); line-height: 1; }
.map-stat span { font-size: .9rem; color: var(--ink-soft); }

.map-legend { flex: 1; }
.map-legend h4 { font-size: .98rem; margin: 6px 0 10px; }
.map-legend ul { list-style: none; margin: 0; padding: 0; }
.map-legend li {
  display: flex; align-items: center; gap: 10px; font-size: .88rem;
  padding: 7px 0; border-bottom: 1px dashed rgba(171, 136, 109, .3);
}
.map-legend li:last-child { border-bottom: 0; }
.lg-dot { width: 13px; height: 13px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 0 3px rgba(255, 255, 255, .8); }
.lg-name { flex: 1; color: var(--ink); line-height: 1.45; }
.lg-n {
  font-weight: 700; color: var(--green-d); background: rgba(255, 255, 255, .75);
  border-radius: 8px; padding: 1px 9px; font-size: .82rem;
}
.map-cta { justify-content: center; }

@media (max-width: 900px) {
  .map-panel { grid-template-columns: 1fr; }
  #map.home-map { height: 400px; }
  .map-side { border-left: 0; border-top: 1px solid var(--paper); }
}

/* ---------------- แผนที่ ---------------- */
#map { height: 560px; border-radius: var(--radius); border: 1px solid var(--paper); box-shadow: var(--shadow-sm); z-index: 1; }
.map-mini { height: 260px; border-radius: 14px; }
.leaflet-popup-content { font-family: var(--font-body); }
.leaflet-popup-content h4 { font-family: var(--font-head); margin: 0 0 4px; font-size: 1rem; }

/* ---------------- เนื้อหาอิสระ (WYSIWYG) ---------------- */
.rich { font-size: 1.03rem; }
.rich h2, .rich h3, .rich h4 { margin-top: 1.6em; }
.rich img { border-radius: 14px; margin: 18px auto; box-shadow: var(--shadow-sm); }
.rich ul, .rich ol { padding-left: 26px; }
.rich li { margin-bottom: .4em; }
.rich blockquote {
  margin: 22px 0; padding: 16px 24px; background: var(--mint);
  border-left: 4px solid var(--green); border-radius: 0 14px 14px 0; color: var(--ink-soft);
}
.rich table { width: 100%; border-collapse: collapse; margin: 20px 0; }
.rich table th, .rich table td { border: 1px solid var(--paper); padding: 10px 14px; }
.rich table th { background: var(--mint); font-family: var(--font-head); }
.rich iframe { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 14px; }

/* ---------------- รายการเอกสาร/วิดีโอ ---------------- */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
.doc-card {
  background: #fff; border: 1px solid var(--paper); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow-sm); transition: transform .25s, box-shadow .25s; display: flex; flex-direction: column; gap: 8px;
}
.doc-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
.doc-card .doc-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--mint); color: var(--green-d); margin-bottom: 8px; }
.doc-card h3 { font-size: 1.08rem; margin: 0; }
.doc-card p { font-size: .93rem; color: var(--ink-soft); margin: 0; flex: 1; }
.doc-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.video-frame { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 14px; box-shadow: var(--shadow-sm); }

/* ---------------- ภาพตัวอย่างเอกสาร ---------------- */
.doc-preview {
  position: relative; display: block; margin: -24px -24px 16px; overflow: hidden;
  background: linear-gradient(140deg, var(--mint), var(--paper));
  aspect-ratio: 4 / 2.7; border-bottom: 1px solid var(--paper);
}
.doc-preview img { width: 100%; height: 100%; object-fit: cover; object-position: top center; transition: transform .45s ease; }
.doc-card:hover .doc-preview img { transform: scale(1.04); }
.preview-mask {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: linear-gradient(180deg, rgba(73, 54, 40, 0) 40%, rgba(73, 54, 40, .55));
  opacity: 0; transition: opacity .28s;
}
.doc-preview:hover .preview-mask, .doc-preview:focus-visible .preview-mask { opacity: 1; }
.preview-btn {
  display: inline-flex; align-items: center; gap: 8px; background: #fff; color: var(--ink);
  font-family: var(--font-head); font-size: .95rem; padding: 10px 20px; border-radius: 999px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .25); transform: translateY(8px); transition: transform .28s;
}
.doc-preview:hover .preview-btn { transform: none; }
.preview-ext {
  position: absolute; left: 14px; top: 14px; color: #fff; font-size: .72rem; font-weight: 700;
  letter-spacing: .05em; padding: 4px 11px; border-radius: 7px; box-shadow: 0 4px 12px rgba(0, 0, 0, .22);
}
.doc-card { overflow: hidden; }

/* ป้าย "คลิกเพื่ออ่าน" — แสดงตลอดเวลาเพื่อให้ใช้งานบนมือถือได้ */
.preview-hint {
  position: absolute; right: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .94); color: var(--ink); font-size: .8rem; font-weight: 600;
  padding: 6px 13px; border-radius: 999px; box-shadow: 0 4px 14px rgba(73, 54, 40, .2);
}
.preview-hint svg { width: 14px; height: 14px; }

/* ---------------- อ่านเอกสารในหน้าเว็บ ---------------- */
.doc-card.reading { grid-column: 1 / -1; }
.doc-card.reading .doc-preview { display: none; }
.doc-reader {
  margin: -24px -24px 16px; border-bottom: 1px solid var(--paper);
  background: #f2efec; display: flex; flex-direction: column;
}
.reader-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 11px 16px; background: var(--ink); color: #fff;
}
.reader-bar .rt { font-family: var(--font-head); font-size: .96rem; flex: 1; min-width: 150px; }
.reader-bar .btn { padding: 7px 15px; font-size: .85rem; }
.reader-frame { width: 100%; height: min(78vh, 900px); border: 0; background: #f2efec; display: block; }
.reader-note {
  padding: 9px 16px; font-size: .84rem; color: var(--ink-soft);
  background: var(--mint); display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.reader-note a { font-weight: 600; }
.reader-loading {
  padding: 26px 20px; text-align: center; color: var(--ink-soft); font-size: .92rem;
  background: #f2efec; border-bottom: 1px solid var(--paper);
}

/* ---------------- แถวสถิติเล็ก ---------------- */
.stat-line {
  display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 4px;
  font-size: .84rem; color: var(--ink-soft);
}
.stat-line span { display: inline-flex; align-items: center; gap: 5px; }
.stat-line b { color: var(--green-d); font-weight: 600; }
.stat-line svg { opacity: .7; }
.file-sub { font-size: .82rem; color: var(--ink-soft); margin: 3px 0 0 42px; display: flex; gap: 8px; flex-wrap: wrap; }
.file-sub a { font-weight: 600; }

/* ---------------- ตัวเล่นวิดีโอ ---------------- */
.video-box {
  position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden;
  background: #2b2118; cursor: pointer; box-shadow: var(--shadow-sm);
}
.video-box img.video-poster { width: 100%; height: 100%; object-fit: cover; transition: transform .5s, filter .3s; }
.video-box:hover img.video-poster { transform: scale(1.05); filter: brightness(.82); }
.video-poster-blank { position: absolute; inset: 0; display: grid; place-items: center; color: var(--sand); }
.video-play {
  position: absolute; inset: 0; margin: auto; width: 74px; height: 54px; border: 0; background: none;
  cursor: pointer; padding: 0; display: grid; place-items: center; transition: transform .25s;
}
.video-box:hover .video-play { transform: scale(1.12); }
.video-box iframe { width: 100%; height: 100%; border: 0; }

/* ---------------- หน้าต่างดูตัวอย่างเอกสาร ---------------- */
.docview { position: fixed; inset: 0; z-index: 600; display: none; }
.docview.on { display: block; }
.docview-bg { position: absolute; inset: 0; background: rgba(30, 22, 16, .82); backdrop-filter: blur(3px); }
.docview-box {
  position: relative; width: min(1000px, 94vw); height: min(88vh, 900px); margin: 5vh auto 0;
  background: #fff; border-radius: 18px; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}
.docview-head {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  background: var(--ink); color: #fff; flex-wrap: wrap;
}
.docview-head h4 { font-family: var(--font-head); margin: 0; font-size: 1.02rem; flex: 1; min-width: 180px; }
.docview-head .btn { padding: 8px 16px; font-size: .88rem; }
.docview-close { background: none; border: 0; color: #fff; font-size: 1.7rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.docview-body { flex: 1; background: #f2efec; position: relative; }
.docview-body iframe, .docview-body embed { width: 100%; height: 100%; border: 0; }
.docview-body .reader-loading { position: absolute; inset: 0; display: grid; place-items: center; border: 0; }
.docview .dv-note { flex: 0 0 auto; }
.docview-head .btn { cursor: pointer; }
.docview-note { padding: 40px 24px; text-align: center; color: var(--ink-soft); }

/* ---------------- กล่องว่าง ---------------- */
.empty {
  text-align: center; padding: 64px 24px; background: #fff; border: 1px dashed var(--sand);
  border-radius: var(--radius); color: var(--ink-soft);
}
.empty svg { width: 64px; height: 64px; color: var(--sand); margin-bottom: 12px; }

/* ---------------- ติดต่อ ---------------- */
.contact-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 36px; align-items: start; }
.contact-list { list-style: none; padding: 0; margin: 0; }
.contact-list li { display: flex; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--paper); }
.contact-list li:last-child { border-bottom: 0; }
.contact-list .ic { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 13px; background: var(--mint); color: var(--green-d); display: grid; place-items: center; }
.contact-list b { display: block; font-family: var(--font-head); font-weight: 500; }

/* ---------------- ฟุตเตอร์ ---------------- */
.site-footer {
  position: relative; margin-top: 70px; color: rgba(255, 255, 255, .8);
  background: linear-gradient(170deg, #55402F 0%, #493628 45%, #3B2C21 100%);
  overflow: hidden;
}
.site-footer::after {          /* แสงนวลมุมขวาบน ให้ไม่ทึบจนเกินไป */
  content: ''; position: absolute; right: -140px; top: -180px; width: 520px; height: 520px;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(231, 240, 220, .10), transparent 68%);
}
.footer-wave {                 /* เส้นคาดไล่สีด้านบน */
  height: 5px; background: linear-gradient(90deg, var(--green-d), var(--brown) 45%, var(--sand) 75%, var(--green));
}

.footer-grid {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1.7fr 1fr 1.5fr; gap: 46px;
  padding: 58px 20px 46px;
}

/* คอลัมน์แบรนด์ */
.f-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.f-logo {
  width: 54px; height: 54px; flex: 0 0 auto; border-radius: 16px; display: grid; place-items: center;
  color: var(--mint); background: rgba(231, 240, 220, .12); border: 1px solid rgba(231, 240, 220, .22);
}
.f-logo-img { width: 56px; height: 56px; flex: 0 0 auto; object-fit: contain; }
.f-head strong { display: block; font-family: var(--font-head); font-size: 1.4rem; color: #fff; line-height: 1.25; }
.f-head small { display: block; font-size: .86rem; color: rgba(255, 255, 255, .62); line-height: 1.55; margin-top: 3px; }
.f-owner { font-size: .89rem; color: rgba(255, 255, 255, .55); line-height: 1.75; margin: 0 0 20px; max-width: 420px; }

.f-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.f-btn {
  display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-head); font-size: .93rem;
  padding: 10px 20px; border-radius: 999px; color: var(--ink) !important; background: var(--mint);
  transition: transform .2s, background .2s, color .2s;
}
.f-btn:hover { transform: translateY(-2px); background: #fff; }
.f-btn.ghost { background: rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .88) !important; border: 1px solid rgba(255, 255, 255, .22); }
.f-btn.ghost:hover { background: rgba(255, 255, 255, .16); color: #fff !important; }
.f-btn svg { width: 16px; height: 16px; }

/* หัวคอลัมน์ */
.site-footer h4 {
  position: relative; color: #fff; font-size: 1.06rem; margin: 0 0 20px; padding-bottom: 12px;
}
.site-footer h4::after {
  content: ''; position: absolute; left: 0; bottom: 0; width: 38px; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, var(--sand), var(--green-l));
}

/* รายการลิงก์ */
.footer-links, .footer-contact { list-style: none; padding: 0; margin: 0; font-size: .93rem; }
.footer-links li { margin-bottom: 4px; }
.footer-links a {
  display: inline-flex; align-items: center; gap: 9px; padding: 5px 0;
  color: rgba(255, 255, 255, .76); transition: color .2s, transform .2s;
}
.footer-links a::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto;
  background: var(--brown); transition: background .2s, transform .2s;
}
.footer-links a:hover { color: #fff; transform: translateX(4px); }
.footer-links a:hover::before { background: var(--mint); transform: scale(1.3); }

/* รายการติดต่อ */
.footer-contact li { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 13px; line-height: 1.7; }
.fc-ic {
  width: 32px; height: 32px; flex: 0 0 auto; border-radius: 10px; display: grid; place-items: center;
  background: rgba(231, 240, 220, .1); color: var(--sand); margin-top: 1px;
}
.fc-ic svg { width: 16px; height: 16px; }
.site-footer a { color: rgba(255, 255, 255, .8); }
.site-footer a:hover { color: var(--mint); }

/* แถบล่างสุด */
.footer-bottom {
  position: relative; z-index: 1;
  border-top: 1px solid rgba(255, 255, 255, .12); padding: 18px 0;
  font-size: .85rem; color: rgba(255, 255, 255, .52); background: rgba(0, 0, 0, .12);
}
.fb-in { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.fb-links { display: flex; gap: 20px; }
.fb-links a { color: rgba(255, 255, 255, .6); }
.fb-links a:hover { color: var(--mint); }

.to-top {
  position: fixed; right: 22px; bottom: 22px; width: 46px; height: 46px; border-radius: 50%;
  border: 0; background: var(--ink); color: #fff; font-size: 1.2rem; cursor: pointer; opacity: 0;
  pointer-events: none; transition: opacity .3s, transform .3s; z-index: 90; box-shadow: var(--shadow);
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { transform: translateY(-3px); }

/* ---------------- Lightbox ---------------- */
.lb { position: fixed; inset: 0; background: rgba(30, 22, 16, .9); display: none; place-items: center; z-index: 500; padding: 30px; }
.lb.on { display: grid; }
.lb img { max-width: 92vw; max-height: 88vh; border-radius: 14px; }
.lb-close { position: absolute; top: 22px; right: 26px; background: none; border: 0; color: #fff; font-size: 2.2rem; cursor: pointer; }

/* ---------------- อนิเมชัน ---------------- */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------------- ตอบสนองหน้าจอ ---------------- */
@media (max-width: 1024px) {
  .detail-wrap, .contact-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .f-brand { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .nav-toggle { display: flex; }
  /* สำคัญ: backdrop-filter ทำให้แถบหัวกลายเป็นกรอบอ้างอิงของ position:fixed
     แผงเมนูจึงไม่เต็มจอและเลื่อนตามแถบหัว — ปิดเอฟเฟกต์นี้บนจอเล็ก */
  .site-header { backdrop-filter: none; -webkit-backdrop-filter: none; background: #fff; }
  .main-nav {
    position: fixed; top: 0; right: -100%; width: min(340px, 86vw); height: 100vh; background: #fff;
    box-shadow: -14px 0 40px rgba(73, 54, 40, .2); padding: 90px 22px 30px; transition: right .32s ease; overflow-y: auto; z-index: 120;
  }
  .main-nav.open { right: 0; }
  .main-nav ul { flex-direction: column; align-items: stretch; gap: 4px; }
  .main-nav > ul > li > a { padding: 13px 16px; font-size: 1.06rem; }
  .main-nav .sub { display: flex; position: static; box-shadow: none; border: 0; border-left: 2px solid var(--mint); border-radius: 0; margin-left: 16px; }
  .nav-backdrop { position: fixed; inset: 0; background: rgba(73, 54, 40, .45); z-index: 110; opacity: 0; pointer-events: none; transition: opacity .3s; }
  .nav-backdrop.on { opacity: 1; pointer-events: auto; }
  /* แถบหัวเว็บสร้าง stacking context ของตัวเอง (z-index:100)
     เมื่อเปิดเมนูจึงต้องยกให้สูงกว่าฉากหลัง ไม่งั้นฉากหลังจะทับเมนูจนกดไม่ได้ */
  body.nav-open .site-header { z-index: 200; }
  .main-nav a { -webkit-tap-highlight-color: rgba(101, 129, 71, .25); }
  .main-nav > ul > li > a:active { background: var(--mint); }
  .brand-text small { display: none; }
  .spec { grid-template-columns: 1fr; gap: 2px 0; }
  .spec dt { margin-top: 12px; }
}
@media (max-width: 780px) {
  /* ป้ายชนิดไฟล์อยู่แถวเดียวกับปุ่ม ส่วนชื่อไฟล์ (ถ้ามี) ขึ้นบรรทัดบน */
  .doc-chip { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; }
  .doc-chip-main { grid-column: 1 / -1; }
  .doc-chip-act { width: 100%; }
  .mini-btn { flex: 1; justify-content: center; padding: 9px 12px; }
  .reader-frame { height: 70vh; }
  .reader-bar { padding: 10px 12px; }
  .reader-bar .rt { width: 100%; flex: none; }

  /* ---- มุมมองรายการ: เปลี่ยนตารางเป็นการ์ดบนจอเล็ก อ่านง่ายกว่าเลื่อนแนวนอน ---- */
  .table-wrap.list-wrap { overflow: visible; background: none; border: 0; box-shadow: none; }
  table.data.list-view { min-width: 0 !important; width: 100%; }
  table.data.list-view thead { display: none; }
  table.data.list-view, table.data.list-view tbody, table.data.list-view tr, table.data.list-view td { display: block; width: 100%; }
  table.data.list-view tr {
    background: #fff; border: 1px solid var(--paper); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); margin-bottom: 16px; padding: 6px 4px 10px; overflow: hidden;
  }
  table.data.list-view tr:hover { background: #fff; }
  table.data.list-view td { border: 0; padding: 7px 16px; }
  table.data.list-view td[data-th]::before {
    content: attr(data-th) ' '; display: block;
    font-size: .74rem; font-weight: 700; letter-spacing: .04em;
    color: var(--brown); text-transform: uppercase; margin-bottom: 3px;
  }
  table.data.list-view td[data-th="ระดับชั้น"] { display: inline-block; width: auto; padding-bottom: 0; }
  table.data.list-view td[data-th="ประเภท"]   { display: inline-block; width: auto; padding-bottom: 0; }
  table.data.list-view td[data-th="รายการ"] b { font-size: 1.02rem; line-height: 1.55; display: block; }
  table.data.list-view td[data-th="ไฟล์"] { border-top: 1px solid var(--paper); margin-top: 6px; padding-top: 12px; }
  .table-hint { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .section { padding: 54px 0; }
  .hero { height: auto; min-height: 88vh; }
  .topbar-org { display: none; }
  .footer-grid { grid-template-columns: 1fr; gap: 32px; padding: 42px 20px 32px; }
  .fb-in { justify-content: center; text-align: center; }
  .fb-links { justify-content: center; }
  .f-actions .f-btn { flex: 1; justify-content: center; }
  .detail-card { padding: 24px 20px; }
  .card-grid, .res-grid, .doc-grid { grid-template-columns: 1fr; }
}

/* ---------------- พิมพ์ ---------------- */
@media print {
  .topbar, .site-header, .site-footer, .to-top, .filter-bar, .hero-dots { display: none !important; }
  body { background: #fff; }
}
