/* TEGH นัดหมาย — ตัวเปิดรูป (lightbox) กลางทั้งระบบ · ใช้คู่กับ lightbox.js
   พื้นมืดเสมอ (ดูรูปชัด ทั้งกลางวัน/กลางคืน) · จอกว้าง = แผงรายละเอียดขวา · มือถือ = แผงล่างพับได้ */
.tlb {
  --tlb-bg: #080c12;   /* ทึบ — ไม่ให้หน้าเว็บด้านหลังลอดขึ้นมาซ้อนกับรูป */ --tlb-panel: #111a24; --tlb-line: rgba(255, 255, 255, .10);
  --tlb-ink: #eef3f7; --tlb-sub: #9fb1c1; --tlb-acc: #54c08a; --tlb-btn: rgba(255, 255, 255, .10); --tlb-btn-h: rgba(255, 255, 255, .20);
  position: fixed; inset: 0; z-index: 20000; display: flex; flex-direction: column;
  background: var(--tlb-bg); color: var(--tlb-ink); font-family: inherit;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
  animation: tlb-in .16s ease-out;
}
.tlb[hidden] { display: none !important; }
@keyframes tlb-in { from { opacity: 0; } to { opacity: 1; } }

/* แถบบน */
.tlb-top { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 56px; }
.tlb-count { flex: 0 0 auto; font-size: .82rem; font-weight: 700; color: var(--tlb-sub); font-variant-numeric: tabular-nums;
  background: var(--tlb-btn); border-radius: 999px; padding: 4px 11px; }
.tlb-ttl { flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.tlb-ttl b { display: block; font-size: 1rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tlb-ttl small { display: block; font-size: .8rem; color: var(--tlb-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tlb-tools { flex: 0 0 auto; display: flex; gap: 6px; }
.tlb-tb { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--tlb-btn); color: var(--tlb-ink);
  display: grid; place-items: center; cursor: pointer; text-decoration: none; transition: background .12s; }
.tlb-tb:hover, .tlb-tb[aria-pressed="true"] { background: var(--tlb-btn-h); }
.tlb-tb:focus-visible, .tlb-nav:focus-visible, .tlb-th:focus-visible { outline: 2px solid var(--tlb-acc); outline-offset: 2px; }
.tlb-tb svg, .tlb-nav svg { width: 20px; height: 20px; }
.tlb-tb.tlb-x { background: rgba(255, 255, 255, .16); }

/* ตัวรูป + แผงรายละเอียด */
.tlb-body { flex: 1 1 auto; min-height: 0; display: flex; }
.tlb-stage { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; overflow: hidden; touch-action: none; user-select: none;
  display: grid; place-items: center; padding: 8px 14px; }
.tlb-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px;
  transform-origin: 0 0; will-change: transform; cursor: zoom-in; -webkit-user-drag: none; box-shadow: 0 10px 40px rgba(0, 0, 0, .45); }
.tlb.zoomed .tlb-img { cursor: grab; border-radius: 0; box-shadow: none; }
.tlb.dragging .tlb-img { cursor: grabbing; }
.tlb-img.fade { opacity: .25; transition: opacity .12s; }
.tlb-spin { position: absolute; width: 38px; height: 38px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .18);
  border-top-color: var(--tlb-acc); animation: tlb-spin .8s linear infinite; pointer-events: none; }
.tlb-spin[hidden] { display: none; }
@keyframes tlb-spin { to { transform: rotate(360deg); } }
.tlb-err { position: absolute; text-align: center; color: var(--tlb-sub); font-weight: 700; }
.tlb-err[hidden] { display: none; }
.tlb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 72px; border: 0; border-radius: 14px;
  background: rgba(17, 26, 36, .62); color: #fff; display: grid; place-items: center; cursor: pointer; transition: background .12s, opacity .12s; }
.tlb-nav:hover { background: rgba(17, 26, 36, .9); }
.tlb-nav.prev { left: 12px; } .tlb-nav.next { right: 12px; }
.tlb-nav[disabled] { opacity: .2; cursor: default; }
.tlb-nav[hidden] { display: none; }
.tlb-nav svg { width: 28px; height: 28px; }

.tlb-info { flex: 0 0 320px; background: var(--tlb-panel); border-left: 1px solid var(--tlb-line); overflow-y: auto; padding: 16px 18px 20px; }
.tlb-info[hidden] { display: none; }
.tlb-info h3 { margin: 0 0 4px; font-size: 1.05rem; font-weight: 800; color: var(--tlb-ink); text-wrap: balance; }
.tlb-info .tlb-isub { margin: 0 0 12px; font-size: .82rem; color: var(--tlb-sub); }
.tlb-info dl { margin: 0; display: grid; gap: 0; }
.tlb-info dl div { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-top: 1px solid var(--tlb-line); }
.tlb-info dt { color: var(--tlb-sub); font-size: .8rem; font-weight: 600; }
.tlb-info dd { margin: 0; font-size: .9rem; font-weight: 700; overflow-wrap: anywhere; }
.tlb-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; padding: 9px 14px; border-radius: 10px;
  background: var(--tlb-acc); color: #07210f; font-weight: 800; font-size: .88rem; text-decoration: none; }
.tlb-link:hover { filter: brightness(1.06); }
.tlb-link[hidden] { display: none; }

/* แถบรูปย่อ */
.tlb-strip { flex: 0 0 auto; display: flex; gap: 8px; padding: 10px 14px 12px; overflow-x: auto; scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .2) transparent; justify-content: safe center; }
.tlb-strip[hidden] { display: none; }
.tlb-th { flex: 0 0 auto; width: 76px; height: 54px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden;
  background: #000; cursor: pointer; opacity: .55; transition: opacity .12s, border-color .12s; }
.tlb-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tlb-th:hover { opacity: .9; }
.tlb-th.on { opacity: 1; border-color: var(--tlb-acc); }
.tlb-hint { text-align: center; font-size: .74rem; color: var(--tlb-sub); padding: 0 12px 10px; }

/* จอแคบ: แผงรายละเอียดอยู่ล่าง (พับได้) · ปุ่มเลื่อนเล็กลง */
@media (max-width: 900px) {
  .tlb-body { flex-direction: column; }
  .tlb-info { flex: 0 0 auto; max-height: 38vh; border-left: 0; border-top: 1px solid var(--tlb-line); padding: 12px 16px 14px; }
  .tlb-nav { width: 42px; height: 56px; } .tlb-nav.prev { left: 6px; } .tlb-nav.next { right: 6px; }
  .tlb-hint { display: none; }
  .tlb-th { width: 60px; height: 44px; }
}
@media (max-width: 480px) {
  .tlb-top { gap: 8px; padding: 8px 10px; }
  .tlb-tb { width: 36px; height: 36px; }
  .tlb-tools .tlb-hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { .tlb { animation: none; } .tlb-spin { animation-duration: 2s; } }

/* รูปย่อที่เปิดใน lightbox ได้ — บอกผู้ใช้ด้วยเคอร์เซอร์ */
[data-lb] { cursor: zoom-in; }
