:root {
  --logo-fg: #1E3A8A;
  --ink: #0f2a43;
  --brand: #0c6cb8;
  --brand-dark: #084e86;
  --accent: #17a398;
  --bg: #f5f8fb;
  --card: #ffffff;
  --border: #e2e9f0;
  --muted: #5b6b7b;
  --radius: 14px;
  --pill: 999px;
  --shadow: 0 1px 2px rgba(15,42,67,.04), 0 8px 24px rgba(15,42,67,.06);
  --shadow-hover: 0 6px 16px rgba(15,42,67,.10), 0 18px 40px rgba(15,42,67,.10);

  /* ผิวที่ผูกกับธีม */
  --header-bg: linear-gradient(90deg, #eef0fb 0%, #3438a6 42%, #171c96 100%);
  --header-fg: #eaeeff;
  --header-fg-strong: #ffffff;
  --header-fg-dim: rgba(255,255,255,.4);
  --header-shadow: 0 2px 14px rgba(15,20,80,.18);
  --header-border: transparent;
  --cta-bg: rgba(255,255,255,.06);
  --cta-border: rgba(255,255,255,.55);
  --cta-fg: #ffffff;
  --cta-hover-bg: #ffffff;
  --cta-hover-fg: var(--brand);
  --footer-bg: #1a259c;
  --footer-fg: #cfd5f4;
  --footer-strong: #ffffff;
  --hero-bg: radial-gradient(130% 130% at 100% 0%, rgba(23,163,152,.12), transparent 55%), radial-gradient(100% 100% at 0% 0%, rgba(12,108,184,.10), transparent 50%), linear-gradient(180deg, #eef4fa, var(--bg));
  --section-alt: linear-gradient(180deg, #eef4fa66, transparent 40%);
}

/* ================= Tech / Futuristic ================= */
:root[data-theme="tech"] {
  --logo-fg: #ffffff;
  --ink: #0b1b2e;
  --brand: #0ea5b7;
  --brand-dark: #0b7f8c;
  --accent: #6366f1;
  --bg: #eef3f8;
  --card: #ffffff;
  --border: #d5e0ea;
  --muted: #5a6b7d;
  --radius: 10px;
  --pill: 8px;
  --shadow: 0 1px 2px rgba(10,26,47,.05), 0 10px 26px rgba(10,26,47,.08);
  --shadow-hover: 0 8px 20px rgba(10,26,47,.12), 0 22px 44px rgba(14,165,183,.14);
  --header-bg: linear-gradient(100deg, #0a1a2f 0%, #123a63 55%, #0a1a2f 100%);
  --header-fg: #cfe9f2;
  --header-fg-strong: #ffffff;
  --header-fg-dim: rgba(255,255,255,.35);
  --header-shadow: 0 2px 18px rgba(14,165,183,.22);
  --cta-bg: rgba(14,165,183,.14);
  --cta-border: rgba(120,220,235,.6);
  --cta-fg: #ffffff;
  --cta-hover-bg: #22d3ee;
  --cta-hover-fg: #06222b;
  --footer-bg: #0a1a2f;
  --footer-fg: #a9c6d6;
  --footer-strong: #ffffff;
  --hero-bg: radial-gradient(120% 120% at 100% 0%, rgba(99,102,241,.16), transparent 55%), radial-gradient(120% 120% at 0% 10%, rgba(14,165,183,.16), transparent 55%), linear-gradient(180deg, #e6f0f6, var(--bg));
  --section-alt: linear-gradient(180deg, rgba(14,165,183,.06), transparent 45%);
}

/* ================= Minimal / Clean ================= */
:root[data-theme="minimal"] {
  --logo-fg: #111827;
  --ink: #111827;
  --brand: #1f2937;
  --brand-dark: #111827;
  --accent: #2563eb;
  --bg: #ffffff;
  --card: #ffffff;
  --border: #ececec;
  --muted: #6b7280;
  --radius: 8px;
  --pill: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.03), 0 4px 14px rgba(0,0,0,.05);
  --shadow-hover: 0 6px 18px rgba(0,0,0,.08);
  --header-bg: #ffffff;
  --header-fg: #374151;
  --header-fg-strong: #111827;
  --header-fg-dim: #cbd0d6;
  --header-shadow: 0 1px 0 #eeeeee;
  --header-border: #eeeeee;
  --cta-bg: transparent;
  --cta-border: #111827;
  --cta-fg: #111827;
  --cta-hover-bg: #111827;
  --cta-hover-fg: #ffffff;
  --footer-bg: #f9fafb;
  --footer-fg: #4b5563;
  --footer-strong: #111827;
  --hero-bg: linear-gradient(180deg, #fafafa, #ffffff);
  --section-alt: #fafafa;
}

/* ================= Soft / Friendly ================= */
:root[data-theme="soft"] {
  --logo-fg: #234050;
  --ink: #234050;
  --brand: #2f9bb5;
  --brand-dark: #227a8f;
  --accent: #ff8a5c;
  --bg: #f1f7f9;
  --card: #ffffff;
  --border: #e2edf1;
  --muted: #5f7284;
  --radius: 20px;
  --pill: 999px;
  --shadow: 0 2px 6px rgba(47,155,181,.08), 0 12px 30px rgba(47,155,181,.10);
  --shadow-hover: 0 10px 26px rgba(47,155,181,.16), 0 24px 48px rgba(47,155,181,.14);
  --header-bg: linear-gradient(90deg, #eaf6f8 0%, #5cc0c9 48%, #2f9bb5 100%);
  --header-fg: #ecfbfd;
  --header-fg-strong: #ffffff;
  --header-fg-dim: rgba(255,255,255,.45);
  --header-shadow: 0 4px 18px rgba(47,155,181,.22);
  --cta-bg: rgba(255,255,255,.12);
  --cta-border: rgba(255,255,255,.7);
  --cta-fg: #ffffff;
  --cta-hover-bg: #ffffff;
  --cta-hover-fg: var(--brand-dark);
  --footer-bg: #2b6b7a;
  --footer-fg: #d3ecf1;
  --footer-strong: #ffffff;
  --hero-bg: radial-gradient(130% 130% at 100% 0%, rgba(255,138,92,.14), transparent 55%), radial-gradient(120% 120% at 0% 0%, rgba(47,155,181,.16), transparent 55%), linear-gradient(180deg, #e8f5f7, var(--bg));
  --section-alt: linear-gradient(180deg, rgba(47,155,181,.07), transparent 45%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Noto Sans Thai", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  font-size: 16px;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { font-family: "Prompt", "Noto Sans Thai", sans-serif; font-weight: 600; line-height: 1.3; margin: 0; }

.container { width: min(1160px, 92vw); margin-inline: auto; }

/* ===== Header / Nav ===== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  box-shadow: var(--header-shadow);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 74px; }
.brand img { height: 44px; width: auto; display: block; }
.main-nav { display: flex; align-items: center; gap: 1.75rem; }
.main-nav a { font-size: .98rem; color: var(--header-fg); position: relative; padding: .25rem 0; transition: color .15s; }
.main-nav a:hover { color: var(--header-fg-strong); }
.main-nav a.is-active { color: var(--header-fg-strong); font-weight: 600; }
.main-nav a.is-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 2px;
  background: var(--header-fg-strong); border-radius: 2px;
}
.nav-cta {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--cta-bg); color: var(--cta-fg) !important;
  padding: .5rem 1.25rem; border-radius: var(--pill);
  border: 1px solid var(--cta-border); font-weight: 500; letter-spacing: .01em;
  transition: background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.nav-cta:hover {
  background: var(--cta-hover-bg); color: var(--cta-hover-fg) !important; border-color: var(--cta-hover-bg);
  box-shadow: 0 6px 18px rgba(0,0,0,.18); transform: translateY(-1px);
}
.nav-cta .cta-ic { display: inline-flex; opacity: .95; }
.nav-cta .cta-ic svg { width: 15px; height: 15px; }

.nav-toggle, .nav-toggle-label { display: none; }

/* ===== Page hero ===== */
.page-hero {
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(23,163,152,.10), transparent 55%),
    linear-gradient(180deg, #eef4fa, var(--bg));
  padding: 3.2rem 0 2.4rem;
  border-bottom: 1px solid var(--border);
}
.eyebrow {
  display: inline-flex; align-items: center; gap: .5rem;
  margin: 0 0 .6rem; font-size: .9rem; letter-spacing: .02em; color: var(--brand);
  font-weight: 500;
}
.page-hero h1 { font-size: clamp(2rem, 4vw, 2.9rem); color: var(--ink); }
.page-hero-sub { margin: .6rem 0 0; color: var(--muted); max-width: 46ch; }

/* signature: IoT node dot */
.node-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--brand);
  position: relative; flex: 0 0 auto; box-shadow: 0 0 0 4px rgba(12,108,184,.14);
}
.node-dot-accent { background: var(--accent); box-shadow: 0 0 0 4px rgba(23,163,152,.16); }

/* ===== Sections ===== */
.section { padding: 3rem 0; }
.section-alt { background: var(--section-alt); }
.section-title {
  display: flex; align-items: center; gap: .7rem;
  font-size: clamp(1.35rem, 2.4vw, 1.7rem); color: var(--ink); margin-bottom: 1.6rem;
}
.empty { color: var(--muted); }

/* ===== Card grid ===== */
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: #d3e0ec; }
.card-media { display: block; aspect-ratio: 16 / 10; background: #eaf1f7; overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.card:hover .card-media img { transform: scale(1.04); }
.card-placeholder {
  width: 100%; height: 100%; display: grid; place-items: center; color: var(--brand);
  background:
    radial-gradient(60% 60% at 50% 40%, rgba(12,108,184,.10), transparent),
    repeating-linear-gradient(135deg, #eef4fa, #eef4fa 10px, #e7eff6 10px, #e7eff6 20px);
  opacity: .9;
}
.card-body { padding: 1.15rem 1.2rem 1.3rem; display: flex; flex-direction: column; gap: .6rem; flex: 1; }
.badge {
  align-self: flex-start; font-size: .74rem; font-weight: 600; letter-spacing: .02em;
  padding: .22rem .6rem; border-radius: 999px;
}
.badge-news { background: #e3f0fb; color: #0b5b9c; }
.badge-special { background: #e0f4f1; color: #0d7a6f; }
.card-title { font-size: 1.02rem; font-weight: 500; line-height: 1.45; }
.card-title a { transition: color .15s; }
.card-title a:hover { color: var(--brand); }
.card-excerpt { margin: 0; color: var(--muted); font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding-top: .5rem; border-top: 1px solid var(--border); }
.card-date { font-size: .82rem; color: var(--muted); }
.card-more { font-size: .86rem; color: var(--brand); font-weight: 500; transition: gap .15s; }
.card-more:hover { color: var(--brand-dark); }

/* ===== Pagination ===== */
.pagination { display: flex; gap: .5rem; justify-content: center; margin-top: 2.4rem; }
.pagination a {
  min-width: 40px; height: 40px; padding: 0 .8rem; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--ink);
  font-size: .92rem; transition: all .15s;
}
.pagination a:hover { border-color: var(--brand); color: var(--brand); }
.pagination a.is-current { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination .page-next { font-weight: 500; }

/* ===== Gallery ===== */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.gallery-item { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); aspect-ratio: 4/3; background: #eaf1f7; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.gallery-item:hover img { transform: scale(1.06); }

/* ===== Footer ===== */
.site-footer { background: var(--footer-bg); color: var(--footer-fg); margin-top: 3rem; }
.footer-grid { display: grid; grid-template-columns: auto 1.4fr 1.1fr; gap: 2.5rem; align-items: start; padding: 3rem 0 2.6rem; }
.footer-logo-card { background: #fff; border-radius: 18px; padding: 1.6rem 2rem; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
.footer-logo-card img { height: 66px; width: auto; display: block; }
.footer-company-col h4, .footer-social-col h4 { color: var(--footer-strong); font-size: 1.2rem; margin-bottom: 1.1rem; font-family: "Prompt", sans-serif; }
.footer-address { margin: 0 0 1.1rem; font-size: 1.02rem; line-height: 1.9; color: var(--footer-fg); max-width: 40ch; }
.footer-phone { display: inline-flex; align-items: center; gap: .6rem; margin: 0; font-size: 1.05rem; color: var(--footer-strong); }
.footer-phone .fic { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.14); display: inline-flex; align-items: center; justify-content: center; color: #fff; }

.footer-social-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem 1.4rem; }
.footer-soc { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .85rem; }
.footer-soc a { display: inline-flex; align-items: center; gap: .7rem; color: var(--footer-fg); font-size: 1rem; transition: color .15s; }
.footer-soc a:hover { color: var(--footer-strong); }
.footer-soc .social-ic { border-color: rgba(255,255,255,.45); color: #fff; }

.footer-bottom { border-top: 1px solid rgba(255,255,255,.14); padding: 1rem 0; font-size: .84rem; color: #a9b1e0; }
.footer-bottom-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer-seal { display: inline-block; background: #fff; border-radius: 8px; padding: 6px 8px; line-height: normal; vertical-align: middle; }
.footer-seal, .footer-seal * { box-sizing: content-box; }
.footer-seal img { display: inline-block; max-width: none; vertical-align: middle; }

/* ===================== ADMIN ===================== */
.admin-body { background: #eef2f6; }
.admin-topbar { background: var(--ink); color: #fff; }
.admin-topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 58px; }
.admin-topbar strong { font-family: "Prompt", sans-serif; }
.admin-topbar-actions { display: flex; align-items: center; gap: 1rem; }
.link-muted { color: #b9c9d8; font-size: .92rem; }
.link-muted:hover { color: #fff; }

.admin-main { padding: 2rem 0 3rem; }
.admin-main.narrow { width: min(760px, 92vw); }
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.4rem; }
.admin-head h1 { font-size: 1.5rem; }
.count { display: inline-block; background: #dbe6f0; color: var(--brand-dark); border-radius: 999px; font-size: .85rem; padding: .1rem .6rem; margin-left: .4rem; vertical-align: middle; }

.admin-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.admin-table th, .admin-table td { text-align: left; padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table th { background: #f7fafc; font-size: .82rem; color: var(--muted); font-weight: 600; }
.admin-table tr:last-child td { border-bottom: none; }
.cell-thumb img { width: 56px; height: 40px; object-fit: cover; border-radius: 6px; }
.no-thumb { color: #b6c2ce; }
.cell-title { font-weight: 500; max-width: 420px; }
.cell-date { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.cell-actions { white-space: nowrap; text-align: right; }
.admin-empty { background: #fff; border: 1px dashed var(--border); border-radius: var(--radius); padding: 3rem; text-align: center; color: var(--muted); }
.admin-empty .btn { margin-top: 1rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font-family: "Prompt", sans-serif; font-size: .92rem; font-weight: 500; padding: .55rem 1.1rem; border-radius: 10px; border: 1px solid var(--border); background: #fff; color: var(--ink); cursor: pointer; transition: all .15s; }
.btn:hover { border-color: #cfdae5; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { background: transparent; }
/* ปุ่มในแถบแอดมิน (พื้นเข้ม) ให้ตัวอักษรขาว มองเห็นชัด */
.admin-topbar .btn-ghost {
  color: #fff; border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.08);
}
.admin-topbar .btn-ghost:hover {
  color: #fff; background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.6);
}
.btn-danger { color: #b3261e; border-color: #f0d2cf; background: #fdf3f2; }
.btn-danger:hover { background: #fbe7e5; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; }

/* forms */
.stack-form { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 1.1rem; }
.stack-form label { display: flex; flex-direction: column; gap: .4rem; font-size: .92rem; font-weight: 500; color: var(--ink); }
.stack-form input[type=text], .stack-form input[type=url], .stack-form input[type=date], .stack-form select, .stack-form textarea, .login-card input {
  font-family: inherit; font-size: 1rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: #fbfdfe; color: var(--ink); width: 100%;
}
.stack-form input:focus, .stack-form select:focus, .stack-form textarea:focus, .login-card input:focus { outline: 2px solid rgba(12,108,184,.35); outline-offset: 1px; border-color: var(--brand); }
.stack-form textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .8rem; margin-top: .4rem; }
.current-image { display: flex; align-items: center; gap: .8rem; margin-bottom: .5rem; font-weight: 400; font-size: .85rem; color: var(--muted); }
.current-image img { width: 90px; height: 60px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 2.2rem; width: min(400px, 100%); display: flex; flex-direction: column; gap: 1rem; }
.login-logo { height: 44px; width: auto; margin: 0 auto .3rem; }
.login-card h1 { font-size: 1.3rem; text-align: center; margin-bottom: .4rem; }
.login-card label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; font-weight: 500; }
.form-error { background: #fdf3f2; color: #b3261e; border: 1px solid #f0d2cf; border-radius: 10px; padding: .6rem .8rem; font-size: .9rem; margin: 0; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .card-grid, .gallery { grid-template-columns: repeat(2, 1fr); }
  .footer-inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .nav-toggle-label { display: inline-flex; flex-direction: column; gap: 5px; cursor: pointer; padding: 8px; }
  .nav-toggle-label span { width: 24px; height: 2px; background: var(--header-fg-strong); border-radius: 2px; transition: .2s; }
  .main-nav {
    position: absolute; top: 74px; left: 0; right: 0; flex-direction: column; align-items: stretch;
    gap: 0; background: var(--footer-bg); border-bottom: none;
    max-height: 0; overflow: hidden; transition: max-height .25s ease; box-shadow: var(--shadow);
  }
  .main-nav a { padding: .9rem 6vw; border-top: 1px solid rgba(255,255,255,.12); color: var(--footer-fg); }
  .main-nav a.is-active::after { display: none; }
  .nav-cta { margin: .8rem 6vw; text-align: center; justify-content: center; }
  .lang-switch { justify-content: center; padding: .6rem 0 1rem; }
  .nav-toggle:checked ~ .main-nav { max-height: 480px; }
}
@media (max-width: 560px) {
  .card-grid, .gallery { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table tr { margin-bottom: 1rem; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
  .admin-table td { border-bottom: 1px solid var(--border); text-align: left; }
  .cell-actions { text-align: left; }
}

/* ===== Article / รายละเอียดกิจกรรม ===== */
.narrow-article { width: min(760px, 92vw); }
.back-link { display: inline-block; margin-bottom: 1rem; color: var(--brand); font-size: .92rem; font-weight: 500; }
.back-link:hover { color: var(--brand-dark); }
.article-date { color: var(--muted); font-size: .95rem; margin: .6rem 0 0; }
.article-cover { width: 100%; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.8rem; aspect-ratio: 16/9; object-fit: cover; }
.article-body { font-size: 1.05rem; line-height: 1.85; color: #26414f; }
.article-body p { margin: 0 0 1.1rem; }
.article-lead { font-size: 1.18rem; color: var(--ink); font-weight: 500; line-height: 1.7; }
.article-body .btn { margin-top: .6rem; }

/* ===== แกลเลอรีในบทความ + lightbox ===== */
.article-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin-top: 1.8rem; }
.ag-item { padding: 0; border: none; background: #eaf1f7; border-radius: 12px; overflow: hidden; cursor: pointer; aspect-ratio: 4/3; }
.ag-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.ag-item:hover img { transform: scale(1.05); }

.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(9,20,30,.92); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lb-img { max-width: 90vw; max-height: 86vh; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lb-btn { position: absolute; background: rgba(255,255,255,.14); color: #fff; border: none; width: 48px; height: 48px; border-radius: 50%; font-size: 1.7rem; line-height: 1; cursor: pointer; transition: background .15s; display: flex; align-items: center; justify-content: center; }
.lb-btn:hover { background: rgba(255,255,255,.28); }
.lb-close { top: 20px; right: 20px; }
.lb-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 20px; top: 50%; transform: translateY(-50%); }

/* ช่องจัดการแกลเลอรีในฟอร์มแอดมิน */
.gallery-edit { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .7rem; margin: .4rem 0 .6rem; }
.gallery-edit-item { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.gallery-edit-item img { width: 100%; height: 72px; object-fit: cover; }
.remove-check { display: flex; align-items: center; gap: .3rem; justify-content: center; font-size: .78rem; font-weight: 400; color: var(--muted); padding: .3rem; border-top: 1px solid var(--border); }
.field-hint { font-size: .8rem; color: var(--muted); font-weight: 400; }

@media (max-width: 560px) { .article-gallery { grid-template-columns: repeat(2, 1fr); } }

/* ===== หมวดกิจกรรมฝึกอบรม ===== */
.badge-training { background: #fbeede; color: #9a5a0c; }
.node-dot-accent, .node-dot-special { background: var(--accent); box-shadow: 0 0 0 4px rgba(23,163,152,.16); }
.node-dot-training { background: #e29a19; box-shadow: 0 0 0 4px rgba(226,154,25,.18); }
.node-dot-news { background: var(--brand); box-shadow: 0 0 0 4px rgba(12,108,184,.14); }

/* ===== หมวดผลิตภัณฑ์ ===== */
.badge-aiot { background: #e3f0fb; color: #0b5b9c; }
.badge-ev { background: #e6f5ea; color: #2c7a3f; }
.badge-other { background: #eef1f5; color: #4a5a6a; }
.node-dot-aiot { background: var(--brand); box-shadow: 0 0 0 4px rgba(12,108,184,.14); }
.node-dot-ev { background: #37a04e; box-shadow: 0 0 0 4px rgba(55,160,78,.18); }
.node-dot-other { background: #8a97a6; box-shadow: 0 0 0 4px rgba(138,151,166,.18); }

/* สเปคในหน้ารายละเอียดผลิตภัณฑ์ */
.spec-heading { font-size: 1.2rem; margin: 1.6rem 0 .8rem; color: var(--ink); }
.spec-list { margin: 0 0 1.2rem; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #fff; }
.spec-list li { padding: .7rem 1rem; border-bottom: 1px solid var(--border); font-size: .98rem; position: relative; padding-left: 2.2rem; }
.spec-list li:last-child { border-bottom: none; }
.spec-list li::before { content: ""; position: absolute; left: 1rem; top: 1.15rem; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* แท็บสลับหมวดในแอดมิน */
.admin-brand { display: flex; align-items: center; gap: 1.2rem; }
.admin-nav { display: flex; gap: .3rem; }
.admin-nav a { color: #b9c9d8; font-size: .92rem; padding: .35rem .8rem; border-radius: 8px; transition: all .15s; }
.admin-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.admin-nav a.is-active { color: #fff; background: rgba(255,255,255,.16); font-weight: 500; }

@media (max-width: 560px) { .admin-brand { flex-direction: column; align-items: flex-start; gap: .4rem; } }

/* ===== หมวดโซลูชั่น / เกี่ยวกับ ===== */
.badge-solutions { background: #efeafc; color: #4a3f9e; }
.badge-about { background: #e9eef4; color: #385570; }
.node-dot-solutions { background: #7268d6; box-shadow: 0 0 0 4px rgba(114,104,214,.18); }
.node-dot-about { background: #4d6b86; box-shadow: 0 0 0 4px rgba(77,107,134,.18); }

/* ===================== หน้าติดต่อเรา ===================== */
.contact-top { display: grid; grid-template-columns: 0.85fr 1.15fr; gap: 2.2rem; align-items: start; }
.contact-photo { width: 100%; height: 300px; object-fit: cover; border-radius: 14px 14px 0 0; box-shadow: var(--shadow); }
.contact-card { background: var(--ink); color: #dbe6f2; border-radius: 0 0 14px 14px; padding: 1.8rem; margin-top: -4px; }
.contact-card h3 { color: #fff; font-size: 1.15rem; margin-bottom: .8rem; }
.info-list { list-style: none; margin: 0 0 .2rem; padding: 0; }
.info-list li { padding: .25rem 0; font-size: 1.02rem; line-height: 1.7; }
.info-list a { color: #dbe6f2; }
.info-list a:hover { color: #fff; }
.info-key { color: #9db6cf; }
.info-note { color: #9db6cf; }
.card-divider { border: none; border-top: 1px solid rgba(255,255,255,.18); margin: 1.3rem 0; }

.contact-heading { font-size: clamp(1.6rem, 3vw, 2.2rem); color: var(--ink); margin-bottom: 1rem; }
.contact-address { font-size: 1.1rem; line-height: 1.9; color: #34495c; margin: 0 0 1.4rem; }
.contact-map { border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); height: 380px; background: #eaf1f7; }
.contact-map iframe { display: block; height: 100%; width: 100%; }

/* แถบน้ำเงินด้านล่าง */
.contact-band { background: var(--ink); color: #c7d6e4; margin-top: 2rem; padding-top: 2.8rem; }
.contact-band-inner { display: grid; grid-template-columns: 0.85fr 1.15fr; gap: 2.5rem; padding-bottom: 2.4rem; }
.contact-band h3 { color: #fff; font-size: 1.15rem; margin-bottom: 1.2rem; }
.social-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .9rem; }
.social-list a { display: inline-flex; align-items: center; gap: .8rem; color: #dbe6f2; font-size: 1.05rem; transition: color .15s; }
.social-list a:hover { color: #fff; }
.social-ic { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.4); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.qr-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.2rem; }
.qr-item { margin: 0; text-align: center; }
.qr-item img { width: 100%; max-width: 140px; aspect-ratio: 1; background: #fff; border-radius: 10px; padding: 8px; }
.qr-item figcaption { margin-top: .6rem; color: #fff; font-size: 1rem; font-family: "Prompt", sans-serif; }

.nav-cta.is-active-cta { background: var(--cta-hover-bg); color: var(--cta-hover-fg) !important; border-color: var(--cta-hover-bg); }

@media (max-width: 860px) {
  .contact-top, .contact-band-inner { grid-template-columns: 1fr; }
  .qr-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 560px) {
  .qr-grid { grid-template-columns: repeat(2, 1fr); }
  .contact-map { height: 300px; }
}

/* ===================== หน้าแรก ===================== */
.home-hero {
  background: var(--hero-bg);
  padding: 4rem 0 3.4rem;
  border-bottom: 1px solid var(--border);
}
.home-hero h1 { font-size: clamp(2.4rem, 5vw, 3.4rem); color: var(--ink); }
.home-hero-inner { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 2.6rem; align-items: center; }
.hero-media { display: flex; flex-direction: column; gap: 1rem; }
.hero-cover { aspect-ratio: 16 / 11; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); background: #eaf1f7; }
.hero-cover img { width: 100%; height: 100%; object-fit: cover; }
.hero-thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.hero-thumb { aspect-ratio: 16 / 10; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); background: #eaf1f7; }
.hero-thumb img { width: 100%; height: 100%; object-fit: cover; }
.hero-cover .card-placeholder, .hero-thumb .card-placeholder { border-radius: 0; }
.home-hero-sub { font-size: clamp(1.2rem, 2.4vw, 1.6rem); color: var(--brand); margin: .6rem 0 1rem; font-weight: 500; }
.home-hero-body { max-width: 62ch; color: #34495c; font-size: 1.06rem; line-height: 1.9; margin-bottom: 1.6rem; }
.home-hero-body p { margin: 0 0 1rem; }
.home-hero-body .article-lead { color: var(--ink); font-weight: 500; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; }
.section-head .section-title { margin-bottom: 0; }
.view-all {
  flex: 0 0 auto; color: var(--brand); font-weight: 500; font-size: .95rem;
  padding: .4rem .9rem; border: 1px solid var(--border); border-radius: 999px; background: #fff;
  transition: all .15s;
}
.view-all:hover { border-color: var(--brand); color: var(--brand-dark); background: #f2f8fd; }

@media (max-width: 820px) {
  .home-hero-inner { grid-template-columns: 1fr; gap: 2rem; }
  .hero-media { order: -1; }
}

/* Footer responsive */
@media (max-width: 860px) {
  .footer-grid { grid-template-columns: 1fr; gap: 1.8rem; }
}
@media (max-width: 480px) {
  .footer-social-grid { grid-template-columns: 1fr; }
}

/* ===== Hero slideshow ===== */
.hero-slider { position: relative; aspect-ratio: 4 / 3.7; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); background: #0f2a43; }
.hero-slides { position: absolute; inset: 0; }
.hero-slide { position: absolute; inset: 0; opacity: 0; transition: opacity .6s ease; display: block; }
.hero-slide.is-active { opacity: 1; }
.hero-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-slider .card-placeholder { border-radius: 0; }
.hero-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 50%; border: none; background: rgba(255,255,255,.88); color: var(--ink); font-size: 1.5rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 10px rgba(0,0,0,.18); transition: background .15s; }
.hero-nav:hover { background: #fff; }
.hero-prev { left: 12px; } .hero-next { right: 12px; }
.hero-dots { position: absolute; bottom: 14px; left: 0; right: 0; display: flex; gap: 7px; justify-content: center; }
.hero-dot { width: 9px; height: 9px; border-radius: 50%; border: none; background: rgba(255,255,255,.55); cursor: pointer; padding: 0; transition: all .2s; }
.hero-dot.is-active { background: #fff; width: 24px; border-radius: 5px; }

/* ===== แอดมิน: สไลด์ ===== */
.slide-add { margin-bottom: 1.6rem; }
.slide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.2rem; }
.slide-item { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.slide-thumb { aspect-ratio: 16/10; background: #eaf1f7; }
.slide-thumb img { width: 100%; height: 100%; object-fit: cover; }
.slide-meta { display: flex; align-items: center; gap: .5rem; padding: .7rem .8rem .3rem; }
.slide-order { font-weight: 600; color: var(--brand); font-family: "Prompt", sans-serif; }
.slide-link { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slide-link.none { font-style: italic; }
.slide-actions { display: flex; gap: .35rem; padding: 0 .8rem .6rem; }
.slide-edit { display: flex; gap: .4rem; padding: .6rem .8rem; border-top: 1px solid var(--border); }
.slide-edit input { flex: 1; font-family: inherit; font-size: .85rem; padding: .4rem .55rem; border: 1px solid var(--border); border-radius: 8px; background: #fbfdfe; min-width: 0; }

/* ===== ปุ่มสลับภาษา TH/EN ===== */
.lang-switch { display: inline-flex; align-items: center; gap: .35rem; margin-left: .4rem; font-family: "Prompt", sans-serif; font-size: .9rem; }
.lang-switch a { color: var(--header-fg); padding: .15rem .1rem; }
.lang-switch a.is-active { color: var(--header-fg-strong); font-weight: 600; }
.lang-switch a:hover { color: var(--header-fg-strong); }
.lang-sep { color: var(--header-fg-dim); }
@media (max-width: 820px){ .lang-switch { margin: .3rem 0 0; } }

/* ===== ช่องกรอกสองภาษาในแอดมิน ===== */
.bi-field { display: block; margin-bottom: 1rem; }
.bi-label { display: block; font-weight: 500; color: var(--ink); margin-bottom: .4rem; font-size: .95rem; }
.bi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.bi-lang { display: block; position: relative; margin: 0; }
.bi-tag { display: inline-block; font-size: .72rem; font-weight: 600; color: var(--brand); background: #e9f2fb; border-radius: 5px; padding: .1rem .4rem; margin-bottom: .3rem; letter-spacing: .04em; }
.bi-tag-en { color: #7a5c00; background: #fbf1d8; }
.bi-field input, .bi-field textarea { width: 100%; font-family: inherit; font-size: .95rem; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; background: #fbfdfe; }
@media (max-width: 640px){ .bi-grid { grid-template-columns: 1fr; } }

/* ===== เครื่องมือครอป/ย่อรูป ===== */
.upload-note { display: inline-block; margin-top: .4rem; color: #2c7a3f; font-size: .82rem; font-weight: 500; }
.sj-crop-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(10,20,40,.72); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.sj-crop-modal { background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.4); max-width: 96vw; }
.sj-crop-head { padding: .9rem 1.2rem; font-family: "Prompt", sans-serif; font-weight: 500; color: var(--ink); border-bottom: 1px solid var(--border); }
.sj-crop-stage { position: relative; margin: 1rem auto; user-select: none; touch-action: none; background: #eef2f6; }
.sj-crop-stage img { display: block; pointer-events: none; }
.sj-crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.5); cursor: move; box-sizing: border-box; }
.sj-crop-box .h { position: absolute; width: 14px; height: 14px; background: #fff; border: 1px solid var(--brand); border-radius: 2px; }
.sj-crop-box .nw { left: -8px; top: -8px; cursor: nwse-resize; }
.sj-crop-box .ne { right: -8px; top: -8px; cursor: nesw-resize; }
.sj-crop-box .sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.sj-crop-box .se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.sj-crop-bar { display: flex; align-items: center; gap: .7rem; padding: .9rem 1.2rem; border-top: 1px solid var(--border); }
.sj-lock { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--ink); cursor: pointer; }

/* ===== ปุ่มสลับธีมใน footer ===== */
.theme-switch { display: inline-flex; align-items: center; gap: .45rem; }
.theme-dot { width: 16px; height: 16px; border-radius: 50%; display: inline-block; border: 2px solid transparent; box-shadow: 0 0 0 1px rgba(255,255,255,.25) inset; transition: transform .15s; }
.theme-dot:hover { transform: scale(1.15); }
.theme-dot.is-on { border-color: currentColor; box-shadow: 0 0 0 2px var(--footer-bg), 0 0 0 3px currentColor; }

/* ===== การ์ดเลือกธีมในแอดมิน ===== */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.theme-card { position: relative; display: block; border: 2px solid var(--border); border-radius: 14px; padding: 1.1rem; background: #fff; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.theme-card:hover { box-shadow: var(--shadow); }
.theme-card.is-selected { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(12,108,184,.12); }
.theme-card input { position: absolute; top: 1rem; right: 1rem; }
.theme-swatch { display: flex; gap: 0; border-radius: 8px; overflow: hidden; height: 40px; margin-bottom: .8rem; }
.theme-swatch span { flex: 1; }
.theme-name { display: block; font-family: "Prompt", sans-serif; font-weight: 600; color: var(--ink); }
.theme-desc { display: block; font-size: .85rem; color: var(--muted); margin-top: .2rem; }


/* ===== แจ้งเตือนในแอดมิน ===== */
.alert { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .95rem; }
.alert-error { background: #fdecea; color: #b02a1f; border: 1px solid #f5c6c0; }
.alert-ok { background: #e7f6ec; color: #1e7d3c; border: 1px solid #bfe6cb; }

/* ===== ช่องค้นหา ===== */
.search-bar { display: flex; gap: .5rem; margin-top: 1.3rem; max-width: 440px; }
.search-bar input { flex: 1; font-family: inherit; font-size: 1rem; padding: .6rem .9rem; border: 1px solid var(--border); border-radius: var(--pill); background: var(--card); color: var(--ink); }
.search-bar button { font-family: "Prompt", sans-serif; font-weight: 500; border: none; background: var(--brand); color: #fff; padding: .6rem 1.3rem; border-radius: var(--pill); cursor: pointer; transition: background .15s; }
.search-bar button:hover { background: var(--brand-dark); }

/* ===== ฟอร์มติดต่อในหน้า contact ===== */
.contact-form-wrap { grid-column: 1 / -1; margin-top: 2rem; }
.contact-form { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem; box-shadow: var(--shadow); max-width: 720px; }
.contact-form label { display: block; font-weight: 500; margin-bottom: .9rem; color: var(--ink); font-size: .95rem; }
.contact-form input, .contact-form textarea { width: 100%; margin-top: .3rem; font-family: inherit; font-size: 1rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: #fbfdfe; color: var(--ink); }
.cf-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.cf-hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }
@media (max-width: 560px){ .cf-row { grid-template-columns: 1fr; } }

/* ===== กล่องข้อความ (แอดมิน) ===== */
.msg-list { display: flex; flex-direction: column; gap: 1rem; }
.msg-item { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem 1.3rem; box-shadow: var(--shadow); }
.msg-top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.msg-name { font-family: "Prompt", sans-serif; font-size: 1.05rem; color: var(--ink); }
.msg-date { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.msg-contact { font-size: .9rem; color: var(--brand); margin-top: .2rem; }
.msg-body { margin: .7rem 0 1rem; white-space: pre-wrap; line-height: 1.7; }
.msg-actions { display: flex; gap: .5rem; }

/* ===== ตั้งค่า (แอดมิน) ===== */
.settings-block { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1.4rem 1.6rem; box-shadow: var(--shadow); margin-bottom: 1.4rem; }
.settings-block h2 { font-size: 1.2rem; margin-bottom: .5rem; color: var(--ink); }

/* ===== Accessibility ===== */
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 200; background: var(--brand); color: #fff; padding: .6rem 1rem; border-radius: 0 0 8px 0; font-family: "Prompt", sans-serif; }
.skip-link:focus { left: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.main-nav a:focus-visible, .nav-cta:focus-visible { outline-color: #fff; }

/* ===== fade-in ตอนเลื่อน ===== */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1 !important; transform: none !important; transition: none; } }

/* ===== ปุ่มแชร์ ===== */
.share { display: flex; align-items: center; gap: .5rem; margin: 1.6rem 0 .5rem; flex-wrap: wrap; }
.share-label { font-family: "Prompt", sans-serif; font-weight: 500; color: var(--muted); margin-right: .2rem; }
.share-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--card); color: var(--brand); cursor: pointer; transition: all .15s; position: relative; }
.share-btn:hover { color: #fff; background: var(--brand); border-color: var(--brand); transform: translateY(-2px); }
.share-fb:hover { background: #1877f2; border-color: #1877f2; }
.share-x:hover { background: #000; border-color: #000; }
.share-line:hover { background: #06c755; border-color: #06c755; }
.share-copy.is-copied { color: #fff; background: var(--accent); border-color: var(--accent); }
.copied-note { position: absolute; bottom: -1.7rem; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: .78rem; color: var(--accent); font-weight: 600; }

/* ===== สถานะเว็บ (แอดมิน) + หน้าปิดปรับปรุง ===== */
.status-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: .3rem; }
.status-badge { font-family: "Prompt", sans-serif; font-weight: 600; padding: .35rem .8rem; border-radius: 999px; font-size: .95rem; }
.status-on { background: #e7f6ec; color: #1e7d3c; }
.status-off { background: #fdecea; color: #b02a1f; }
.btn-warn { color: #b45309; border-color: #f0c88a; }
.btn-warn:hover { background: #b45309; color: #fff; border-color: #b45309; }
.maint-icon { color: var(--brand); display: flex; justify-content: center; }
.maint-contact { margin-top: 1.6rem; color: var(--muted); font-size: .95rem; }

/* ===== โลโก้ SVG ฝังในตัว ===== */
.brand-logo { height: 48px; width: auto; display: block; }
.footer-logo-card .brand-logo { height: 104px; }   /* ในการ์ดขาว footer */
.login-logo .brand-logo { height: 88px; margin: 0 auto; }  /* หน้า login */
