/* คู่มือการใช้งาน /manual — สารบัญซ้าย + ตัวอ่านขวา
   มือถือ: สลับหน้าด้วยคลาส .mn-has-sel (CSS ล้วน ไม่มี JS → ปุ่มย้อนกลับของเบราว์เซอร์ทำงานปกติ) */

.mn-page { padding: 16px; }
.mn-wrap { display: flex; gap: 18px; align-items: flex-start; max-width: 1180px; margin: 0 auto; }

/* ───────── สารบัญ (ซ้าย) ───────── */
.mn-nav {
  flex: 0 0 252px; width: 252px; background: #fff; border: 1px solid #e6f0fb;
  border-radius: 14px; padding: 8px 0 10px; position: sticky; top: 76px;
  max-height: calc(100dvh - 96px); overflow-y: auto;
}
.mn-nav-head {
  font-size: .82rem; font-weight: 800; color: #0f2356; padding: 8px 14px 10px;
  border-bottom: 1px solid #eef4fb; margin-bottom: 4px;
}
.mn-nav-head i { color: #2563eb; }
.mn-nav-group { padding-bottom: 4px; }
.mn-nav-cat {
  font-size: .7rem; font-weight: 700; color: #94a3b8; letter-spacing: .03em;
  padding: 9px 14px 4px;
}
.mn-nav-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 14px;
  font-size: .87rem; color: #334155; text-decoration: none; line-height: 1.45;
  border-left: 3px solid transparent;
}
.mn-nav-item i:first-child { flex: 0 0 auto; font-size: .95rem; }
.mn-nav-item:hover { background: #f8fafc; color: #0f2356; }
.mn-nav-item.active {
  background: #eff6ff; color: #1d4ed8; font-weight: 700; border-left-color: #2563eb;
}
.mn-nav-lock { margin-left: auto; font-size: .72rem; color: #cbd5e1; }
.mn-nav-foot {
  font-size: .72rem; color: #94a3b8; line-height: 1.6; padding: 10px 14px 2px;
  margin-top: 6px; border-top: 1px solid #eef4fb;
}

/* ───────── ตัวอ่าน (ขวา) ───────── */
.mn-main {
  flex: 1 1 auto; min-width: 0; background: #fff; border: 1px solid #e6f0fb;
  border-radius: 16px; padding: 18px 20px 22px;
}
.mn-back { display: none; }

.mn-head { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.mn-head-txt { flex: 1 1 280px; min-width: 0; }
.mn-title { font-size: 1.22rem; font-weight: 800; color: #0f2356; margin: 0 0 5px; line-height: 1.4; }
.mn-desc { font-size: .9rem; color: #475569; line-height: 1.7; margin: 0; }
.mn-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.mn-chip {
  font-size: .73rem; font-weight: 600; color: #475569; background: #f1f5f9;
  border-radius: 999px; padding: 3px 10px;
}
.mn-chip i { color: #94a3b8; margin-right: 3px; }

.mn-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px;
  border-radius: 10px; font-weight: 700; font-size: .87rem; text-decoration: none;
  background: #fff; color: #334155; border: 1px solid #e2e8f0; cursor: pointer;
}
.mn-btn:hover { border-color: #cbd5e1; color: #0f2356; }
.mn-btn-main { background: #2563eb; color: #fff; border-color: #2563eb; }
.mn-btn-main:hover { background: #1d4ed8; color: #fff; }

/* แท็บไฟล์ (เล่มที่มีหลายไฟล์) */
.mn-tabs { display: flex; gap: 7px; flex-wrap: wrap; margin: 16px 0 0; }
.mn-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px;
  border-radius: 999px; border: 1px solid #e2e8f0; background: #fff;
  font-size: .82rem; font-weight: 600; color: #475569; text-decoration: none;
}
.mn-tab:hover { border-color: #cbd5e1; color: #0f2356; }
.mn-tab.active { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; font-weight: 700; }
.mn-tab-free {
  font-size: .66rem; font-weight: 700; color: #15803d; background: #dcfce7;
  border-radius: 999px; padding: 1px 7px;
}

.mn-filebar {
  margin: 14px 0 8px; font-size: .8rem; color: #475569; font-weight: 600;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.mn-filebar i { color: #94a3b8; }
.mn-dim { color: #94a3b8; font-weight: 400; }

/* ───────── PDF ─────────
   แสดงในกรอบสูงประมาณหนึ่งหน้า แล้วเลื่อนอ่านในกรอบ (เจ้าของสั่ง 2026-11-05)
   ⛔ กรอบนี้คือ root ของ IntersectionObserver ในตัวอ่าน — เปลี่ยนโครง/คลาสต้องแก้ pdf-viewer.tsx ตาม */
.mn-pdf-shell { border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; background: #fff; }
.mn-pdf-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 13px; border-bottom: 1px solid #e2e8f0; background: #f8fafc;
  font-size: .8rem; color: #475569;
}
.mn-pdf-bar i { color: #94a3b8; }
.mn-pdf-bar b { color: #0f2356; }
.mn-pdf-hint { margin-left: auto; color: #94a3b8; font-size: .75rem; }

.mn-pdf {
  background: #f1f5f9; padding: 12px;
  height: clamp(420px, 74dvh, 920px);
  overflow-y: auto;
  overscroll-behavior: contain;   /* เลื่อนสุดกรอบแล้วไม่ดันหน้าเว็บต่อ */
  -webkit-overflow-scrolling: touch;
}
.mn-pdf-page {
  position: relative; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px;
  margin: 0 0 12px; overflow: hidden; width: 100%;
}
.mn-pdf-page:last-child { margin-bottom: 0; }
.mn-pdf-page canvas { display: block; width: 100%; height: auto; }
.mn-pdf-no {
  position: absolute; right: 8px; bottom: 6px; font-size: .68rem; color: #94a3b8;
  background: rgba(255, 255, 255, .85); border-radius: 5px; padding: 1px 6px;
}
.mn-pdf-msg {
  font-size: .86rem; color: #64748b; text-align: center; padding: 26px 12px; line-height: 1.8;
}
.mn-pdf-err { color: #b91c1c; }
.mn-pdf-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

/* ───────── คลิป ───────── */
.mn-video { margin-top: 20px; }
.mn-video-head { font-size: .88rem; font-weight: 800; color: #0f2356; margin-bottom: 8px; }
.mn-video-head i { color: #dc2626; margin-right: 5px; }
.mn-video-box {
  position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px;
  overflow: hidden; background: #0f172a; border: 1px solid #e2e8f0;
}
.mn-video-box iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ───────── สถานะอื่น ───────── */
.mn-locked {
  display: flex; gap: 14px; align-items: flex-start; background: #fffbeb;
  border: 1px solid #fde68a; border-radius: 12px; padding: 18px 20px; color: #78350f;
}
.mn-locked > i { font-size: 1.5rem; color: #d97706; flex: 0 0 auto; }
.mn-locked b { color: #92400e; font-size: 1rem; }
.mn-locked p { margin: 4px 0 12px; font-size: .88rem; line-height: 1.7; }
.mn-locked .mn-btn { margin-right: 8px; }

.mn-intro { text-align: center; padding: 34px 16px 40px; }
.mn-intro-ic { font-size: 2.3rem; color: #bfdbfe; margin-bottom: 10px; }
.mn-intro .mn-title { justify-content: center; }
.mn-intro .mn-desc { max-width: 460px; margin: 0 auto; }
.mn-note { font-size: .85rem; color: #1e40af; background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 10px; padding: 9px 14px; display: inline-block; margin-top: 16px; }
.mn-note a { color: #1d4ed8; font-weight: 700; }

/* ───────── มือถือ / จอแคบ ───────── */
@media (max-width: 900px) {
  .mn-page { padding: 12px; }
  .mn-wrap { display: block; }
  .mn-nav {
    width: auto; flex: none; position: static; max-height: none; overflow: visible;
    margin-bottom: 14px;
  }
  .mn-main { padding: 16px 15px 20px; }
  /* เลือกเล่มแล้ว = เห็นตัวอ่านเต็มจอ · ยังไม่เลือก = เห็นสารบัญเต็มจอ */
  .mn-wrap.mn-has-sel .mn-nav { display: none; }
  .mn-wrap:not(.mn-has-sel) .mn-main { display: none; }
  .mn-wrap.mn-has-sel .mn-back {
    display: inline-flex; align-items: center; gap: 7px; font-size: .85rem;
    font-weight: 700; color: #2563eb; text-decoration: none; margin-bottom: 12px;
  }
  .mn-title { font-size: 1.1rem; }
  .mn-pdf { padding: 8px; height: clamp(360px, 66dvh, 760px); }
  .mn-pdf-hint { display: none; }
  .mn-head { gap: 10px; }
  .mn-head .mn-btn-main { width: 100%; justify-content: center; }
}
