/* =========================================================
   global-dm01.css — สไตล์เฉพาะเว็บ dhamma01 (ธรรมะ๐๑)
   Theme: เรียบหรู ชมพูกุหลาบอ่อน + หมึกน้ำตาลเข้ม (ตาม logo ลายเส้นกุหลาบ)
   ========================================================= */
:root {
  --bg: #fdeff1;
  --surface: #fffdfe;
  --ink: #3c2b2b;
  --muted: #a98b90;
  --rose: #dd7787;
  --rose-2: #c05064;
  --rose-soft: #fbdde1;
  --line: #f3c6cd;
  --mark: #ffd9de;
  --chip: #fae2e5;
  --gold: #c9a86a;
  --shadow: 0 1px 3px rgba(180, 80, 95, .07), 0 8px 24px rgba(180, 80, 95, .06);
  --maxw: 920px;
}
/* override global.css ที่ตั้ง html{height:100%} — ทำให้ background ที่ยกไปวาดเป็นพื้น canvas จบแค่จอแรกแล้วเหลือขาว */
html {
  height: auto;
  min-height: 100%;
  background: #fdf3f4;
}
body {
  margin: 0;
  /* พื้นขาวนวลแต้มสีน้ำชมพูจางๆ เหมือนกระดาษสีน้ำ */
  background:
    radial-gradient(55% 40% at 12% 15%, rgba(246, 190, 198, .28), transparent 70%),
    radial-gradient(45% 35% at 88% 10%, rgba(250, 214, 219, .35), transparent 70%),
    radial-gradient(60% 45% at 80% 60%, rgba(242, 172, 183, .18), transparent 72%),
    radial-gradient(50% 40% at 10% 70%, rgba(246, 190, 198, .22), transparent 72%),
    radial-gradient(65% 50% at 50% 100%, rgba(240, 163, 175, .2), transparent 75%),
    linear-gradient(180deg, #fffdfd 0%, #fdf3f4 100%);
  /* override global.css ที่ตั้ง height:100% — ทำให้กล่อง body สูงแค่ 1 จอ แล้ว position:sticky หลุดหลัง scroll พ้นจอแรก */
  height: auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: "Sarabun", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.7;
}
a { color: var(--rose-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.dm-wrap { max-width: var(--maxw); width: 100%; margin: 0 auto; padding: 24px 20px 60px; flex: 1 0 auto; }
.site-foot { margin-top: auto; }
.dm-wrap h1 { font-weight: 700; }


/* home แบบ google: ลิงก์ + ปุ่ม login มุมขวาบน, โลโก้ใหญ่กลางจอ */
.home-top { display: flex; justify-content: flex-end; padding: 16px 24px 0; }
.home-top-links { display: flex; align-items: center; gap: 18px; }
.home-top-links a { color: #8c4350; font-size: .95rem; }
.home-top-links a:hover { color: var(--rose-2); }
.login-btn { background: var(--rose); color: #fff !important; padding: 7px 20px; border-radius: 20px; font-weight: 600; }
.login-btn:hover { background: var(--rose-2); text-decoration: none; }

/* บัญชีผู้ใช้ (หลัง login): รูป profile + dropdown ออกจากระบบ */
.nav-account { position: relative; display: inline-flex; }
.nav-avatar-btn { border: 0; background: none; padding: 0; cursor: pointer; display: inline-flex; }
.nav-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; display: block;
  box-shadow: 0 1px 4px rgba(140, 55, 70, .25);
}
.nav-avatar-empty { display: inline-flex; align-items: center; justify-content: center; background: var(--rose-soft); color: var(--rose-2); font-size: 1.2rem; }
.nav-account-menu {
  display: none; position: absolute; top: calc(100% + 10px); right: 0; z-index: 40;
  min-width: 190px; background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(140, 55, 70, .18); padding: 4px 0; text-align: left;
}
.nav-account.open .nav-account-menu { display: block; }
.nav-account-menu .nam-name {
  padding: 9px 16px; font-weight: 700; color: var(--ink); border-bottom: 1px solid var(--line);
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-account-menu a { display: block; padding: 10px 16px; color: #8c4350; }
.nav-account-menu a:hover { background: var(--rose-soft); text-decoration: none; }

/* หน้า search แบบ google: search box เดียวอยู่บน + ตัวกรอง creator ใต้ search bar */
.search-top {
  position: sticky; top: 0; z-index: 10; padding: 15px 20px; flex-shrink: 0;
  background:
    radial-gradient(60% 120% at 10% 20%, rgba(242, 172, 183, .5), transparent 70%),
    radial-gradient(50% 110% at 85% 10%, rgba(250, 214, 219, .65), transparent 70%),
    radial-gradient(55% 120% at 55% 90%, rgba(238, 158, 170, .35), transparent 72%),
    linear-gradient(180deg, #fbe4e7 0%, #f7d0d6 100%);
  border-bottom: 1px solid #eeb6bf;
}
.st-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 0; }
.st-brand { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.st-brand:hover { text-decoration: none; }
.st-brand img { width: 36px; height: 36px; object-fit: contain; }
.st-brand span { font-weight: 800; font-size: 1.15rem; color: var(--ink); letter-spacing: .5px; }
.st-brand b { color: var(--rose); }
.st-search { flex: 1; display: flex; min-width: 220px; max-width: 560px; }
@media (min-width: 800px) {
  /* desktop: search box กว้างเท่าการ์ดผลลัพธ์ (ขอบซ้าย-ขวาตรงกัน) — logo ชิดซ้ายสุด
     จอแคบ: ขอบซ้ายตามการ์ดจนเกือบชน logo / ขอบขวาหยุดก่อนชนเมนู */
  .search-top .st-search {
    position: absolute; top: 50%; transform: translateY(-50%);
    left: max(68px, calc(50% - 440px));
    right: max(310px, calc(50% - 440px));
    width: auto; max-width: none; min-width: 0;
  }
}
@media (min-width: 800px) and (max-width: 1240px) {
  /* จอแคบ: searchbox ขยับตามการ์ดจนใกล้ logo — ซ่อนคำว่า ธรรมะ๐๑ เหลือแค่รูป */
  .st-brand span { display: none; }
}
.st-search input {
  flex: 1; min-width: 0; padding: 10px 16px; border: 1px solid #eeb6bf; border-right: 0;
  border-radius: 22px 0 0 22px; background: #fff; font-size: 16px; color: var(--ink);
}
.st-search input:focus { outline: none; border-color: var(--rose); }
.st-search button {
  padding: 10px 20px; border: 0; background: var(--rose); color: #fff;
  border-radius: 0 22px 22px 0; cursor: pointer; font-size: 1rem; flex: none;
}
.st-search button:hover { background: var(--rose-2); }
.search-top .home-top-links { margin-left: auto; }
.st-links { position: relative; }
.st-menu { display: flex; align-items: center; gap: 18px; }
.st-menu a.on { color: var(--ink); font-weight: 700; }
.st-menu-toggle { display: none; border: 0; background: none; color: var(--ink); cursor: pointer; font-size: 1.55rem; line-height: 1; padding: 2px 4px; }
/* desktop: ให้ตัวกรองเริ่มตรงขอบซ้ายของคอลัมน์ผลลัพธ์ (920px กึ่งกลาง) */
.search-filters { display: flex; align-items: center; gap: 8px; padding: 12px 20px 0 max(20px, calc(50% - 440px)); flex-wrap: wrap; font-size: .9rem; flex-shrink: 0; }
.creator-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 14px 4px 10px;
  border-radius: 18px; border: 1px solid #eeb6bf; background: rgba(255, 255, 255, .75);
  color: #8c4350; cursor: pointer; margin: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.creator-chip:hover { border-color: var(--rose); }
.creator-chip input {
  accent-color: var(--rose-2); width: 16px; height: 16px; margin: 0; cursor: pointer; flex: none;
}
.creator-chip span { cursor: pointer; }
.creator-chip:has(input:checked) { background: var(--rose-soft); border-color: var(--rose); color: var(--rose-2); font-weight: 600; }
.search-filters .search-spin { display: inline; margin: 0; }
.hero-brand { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 18px; }
.hero-brand img { width: 84px; height: 84px; object-fit: contain; }
.hb-text { font-size: 3rem; font-weight: 800; color: var(--ink); letter-spacing: 1px; line-height: 1; }
.hb-text span { color: var(--rose); }
.home-google .hero { padding-top: 9vh; }

/* hero */
.hero { text-align: center; padding: 52px 0 20px; }
.hero-kicker { color: var(--rose-2); letter-spacing: 3px; margin: 0 0 10px; font-size: .95rem; }
.hero-search { display: flex; max-width: 640px; margin: 0 auto; box-shadow: var(--shadow); border-radius: 30px; }
.hero-search input {
  flex: 1; padding: 16px 22px; border: 1px solid var(--line); border-right: 0;
  border-radius: 30px 0 0 30px; font-size: 16px; background: #fff; color: var(--ink);
}
.hero-search input:focus { outline: none; border-color: var(--rose); }
.hero-search button {
  padding: 0 30px; border: 0; background: var(--rose); color: #fff;
  border-radius: 0 30px 30px 0; cursor: pointer; font-size: 1.05rem; font-weight: 600;
}
.hero-search button:hover { background: var(--rose-2); }
.popular { margin: 22px auto 0; max-width: 680px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.tag { background: var(--chip); padding: 4px 12px; border-radius: 16px; font-size: .9rem; color: var(--ink); }
.tag:hover { background: var(--rose); color: #fff; text-decoration: none; }
.search-spin { display: block; text-align: center; color: var(--muted); margin-top: 8px; font-size: .9rem; }

/* home: creators — แถบเดียว seamless แบ่งด้วยเส้นบาง */
.creators-strip {
  margin: 56px 0 0; padding: 40px 8px 24px; text-align: center;
}
.strip-ornament { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 6px; }
.strip-ornament img { width: 56px; height: 56px; object-fit: contain; opacity: .9; }
.orn-line { flex: 0 1 160px; height: 1px; background: linear-gradient(90deg, transparent, var(--rose-soft) 30%, #eeb3bd); }
.orn-line:last-child { background: linear-gradient(270deg, transparent, var(--rose-soft) 30%, #eeb3bd); }
.strip-kicker { margin: 0 0 30px; color: var(--rose-2); letter-spacing: 3px; font-size: .95rem; }
.creators-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.creator-col { padding: 8px 20px 4px; }
.creator-col h2 { margin: 0 0 2px; font-size: 1.35rem; font-weight: 800; color: var(--ink); letter-spacing: .3px; }
.cc-sub { margin: 0 0 18px; font-size: .95rem; color: var(--muted); }
.cc-links { display: flex; flex-direction: column; gap: 9px; align-items: center; }
.cc-links a {
  display: inline-flex; align-items: center; justify-content: center; min-width: 150px;
  padding: 8px 20px; border-radius: 22px; border: 1px solid #f2c3cb;
  background: rgba(255, 255, 255, .7); color: var(--rose-2); font-weight: 600; font-size: .95rem;
  transition: background .15s, color .15s, border-color .15s;
}
.cc-links a:hover { text-decoration: none; background: var(--rose); border-color: var(--rose); color: #fff; }

/* home: info / dedication */
.info-section { margin: 44px 0 0; padding: 36px 26px 8px; text-align: center; border-top: 1px solid var(--line); }
.info-section h3 { margin: 0 0 16px; font-size: 1.3rem; color: var(--rose-2); letter-spacing: 1px; }
.info-section p { margin: .3em 0; color: var(--ink); }
.info-section .blessing { color: var(--muted); font-style: italic; margin-top: 1em; }
.home-results { max-width: 820px; margin: 0 auto; padding: 0 4px; }
.home-results.active { min-height: 65vh; margin: 4px auto 40px; }

/* search page */
.search-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.live-search { flex: 1; min-width: 220px; padding: 13px 18px; border: 1px solid var(--line); border-radius: 26px; font-size: 1.05rem; background: #fff; color: var(--ink); }
.live-search:focus { outline: none; border-color: var(--rose); }
.search-controls select { padding: 11px 12px; border: 1px solid var(--line); border-radius: 22px; background: #fff; color: var(--ink); font-size: .95rem; }

/* results */
.result-meta { margin: 14px 0; color: var(--muted); }
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.result { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); }
.r-title { font-size: 1.15rem; font-weight: 700; color: var(--ink); }
.r-title:hover { color: var(--rose-2); }
.r-sub { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; align-items: center; font-size: .85rem; }
.chip { background: var(--chip); padding: 2px 10px; border-radius: 12px; color: var(--ink); }
.r-book { color: var(--muted); }
.chip-link:hover { background: var(--rose); color: #fff; text-decoration: none; }
.r-book-link { color: var(--rose-2); font-weight: 600; }
.r-book-link:hover { text-decoration: underline; }
.r-snip { margin: 6px 0 0; color: #55403f; line-height: 1.75; }
/* :not(.nav-menu-search-hl) — ไม่ทับไฮไลต์เหลืองของ framework (ใช้ที่ชื่อหนังสือ) */
.dm-wrap mark:not(.nav-menu-search-hl), .home-results mark:not(.nav-menu-search-hl) {
  background: var(--mark); color: inherit; padding: 0 2px; border-radius: 3px;
}
@keyframes hlflash { 0%, 60% { background: #ffaebc; } 100% { background: var(--mark); } }
.reader-body mark.flash { animation: hlflash 1.4s ease-out 1; }
.r-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.act { font-size: .85rem; padding: 4px 12px; border-radius: 16px; border: 1px solid var(--line); background: #fff; color: var(--rose-2); }
.act:hover { text-decoration: none; background: var(--rose); color: #fff; border-color: var(--rose); }
.act.read { background: var(--chip); color: var(--ink); border-color: var(--chip); }
.act.yt { color: #b23b2a; }
.act.pdf { color: #b04a54; }

/* search: card result row */
.result-card { padding: 0; }
.result-card .rc { display: flex; gap: 14px; align-items: flex-start; text-decoration: none; color: inherit; padding: 12px; }
.result-card .rc:hover { background: var(--bg); border-radius: 14px; }
.rc-thumb { flex: none; width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.rc-body { flex: 1; min-width: 0; }
.rc-badge { display: inline-block; font-size: .78rem; color: var(--rose-2); background: var(--rose-soft); padding: 1px 9px; border-radius: 20px; margin-left: 6px; }
.result-card.rc-hidden { display: none; }
.more-cards { margin: 14px 0 26px; text-align: center; }
.more-cards-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--rose-2);
  font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer;
  padding: 8px 22px; border-radius: 22px;
}
.more-cards-btn .bi-chevron-down { font-size: .8em; }
.more-cards-btn:hover { background: var(--rose); border-color: var(--rose); color: #fff; }

/* copy content button */
.ch-tools { display: flex; justify-content: flex-end; margin: 0 0 6px; }
.copybtn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 6px 14px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--surface); color: var(--rose-2); font: inherit; font-size: .9rem; font-weight: 600;
}
.copybtn:hover { background: var(--rose); color: #fff; border-color: var(--rose); }
.copybtn.done { background: #e4f3e7; color: #2f7d43; border-color: #a9d7b6; }
.copybtn .ci { font-size: 1.05em; line-height: 1; }

/* library: teacher tabs, book & card grids */
.library h1 { margin-bottom: 6px; }
.teacher-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 24px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.teacher-tabs a { padding: 8px 16px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.teacher-tabs a.on { background: var(--rose); color: #fff; border-color: var(--rose); }
.teacher-tabs a:hover { text-decoration: none; }
.lib-intro h1 { margin-bottom: 4px; }
/* แถวตัวกรองที่มา (chips แบบเดียวกับหน้าค้นหา) */
.lib-filters {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem;
  margin: 12px 0 20px; border-bottom: 1px solid var(--line); padding-bottom: 16px;
}
.book-filter { margin: 18px 0 22px; }
/* แถวค้นชื่อ (ซ้าย) + ปุ่ม Filter เปิด popup (ขวา) */
.bf-row { display: flex; gap: 10px; }
.bf-row .form-control {
  flex: 1; min-width: 0; border-color: var(--line); color: var(--ink); font-size: 16px;
  padding: 10px 18px; border-radius: 22px;
}
.bf-row .form-control:focus { border-color: var(--rose); box-shadow: 0 0 0 .2rem rgba(221, 119, 135, .15); }
.bf-filter-btn {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; padding: 10px 20px;
  border-radius: 22px; border: 1px solid #f5ccd3; background: var(--rose-soft);
  color: var(--rose-2); font-weight: 700; font-size: .95rem; cursor: pointer;
}
.bf-filter-btn:hover { background: #f8d6db; }
.bf-count {
  min-width: 21px; height: 21px; padding: 0 6px; border-radius: 11px;
  background: var(--rose-2); color: #fff; font-size: .78rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
/* แถบสรุปตัวกรองที่กำลังใช้ */
.bf-active { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.bf-active-label { color: var(--muted); font-size: .9rem; flex: 0 0 auto; }
.bf-chips { display: contents; }
.bf-chip {
  display: inline-flex; align-items: center; gap: 3px; padding: 4px 6px 4px 13px;
  border-radius: 15px; background: rgba(192, 80, 100, .92); color: #fff; font-size: .85rem;
}
.bf-chip-x {
  border: 0; background: transparent; color: #fff; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; font-size: 1.05rem; opacity: .85;
}
.bf-chip-x:hover { opacity: 1; }
.bf-clear { border: 0; background: transparent; color: var(--rose-2); font-size: .88rem; text-decoration: underline; cursor: pointer; padding: 0; }
/* popup ตัวกรอง */
.bf-modal { border: 0; border-radius: 16px; background: #fdf3f4; }
.bf-modal .modal-header { border-bottom: 1px solid var(--line); }
.bf-modal .modal-title { color: var(--rose-2); font-weight: 700; font-size: 1.05rem; }
.bf-modal .modal-footer { border-top: 1px solid var(--line); }
.bf-group-label { margin: 0 0 10px; font-weight: 700; color: var(--ink); }
.bf-options { display: flex; flex-wrap: wrap; gap: 8px; }
.bf-reset { border: 0; background: transparent; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 8px 10px; }
.bf-submit {
  border: 0; border-radius: 20px; padding: 10px 22px; background: var(--rose);
  color: #fff; font-weight: 700; cursor: pointer;
}
.bf-submit:hover { background: var(--rose-2); }
.book-filter .count { margin: 10px 0 0; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px; }
.book-card { display: flex; flex-direction: column; gap: 8px; color: var(--ink); }
.cover-wrap { position: relative; }
.book-card img {
  width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px;
  box-shadow: var(--shadow); background: var(--chip); display: block;
}
.book-card .cover-draft { width: 100%; }
/* ปก draft สำหรับเล่มที่ยังไม่มีรูปปก (ใช้ทั้งหน้ารายการและหน้ารายละเอียด) */
.cover-draft {
  aspect-ratio: 3/4; border-radius: 10px; box-shadow: var(--shadow); flex: 0 0 auto;
  background: linear-gradient(165deg, #fdf3f4, #fbe4e7 55%, #f6d3da);
  display: flex; padding: 11px;
}
.cover-draft .cd-inner {
  flex: 1; min-width: 0; border: 1.5px solid rgba(221, 119, 135, .45); border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 12px; text-align: center;
}
.cover-draft .cd-inner::before {
  content: ""; width: 38px; height: 38px; flex: 0 0 auto;
  background: url(../img/logo_dm01.png) center/contain no-repeat; opacity: .9;
}
.cover-draft .cd-name {
  color: var(--rose-2); font-weight: 600; font-size: .95rem; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.cat-badge { position: absolute; top: 8px; right: 8px; background: rgba(192, 80, 100, .92); color: #fff; font-size: .72rem; padding: 3px 9px; border-radius: 12px; max-width: 80%; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
.book-card:hover { text-decoration: none; }
.book-card:hover .book-name { color: var(--rose-2); }
.book-name { font-size: .92rem; line-height: 1.4; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.dcard { margin: 0; cursor: pointer; }
.dcard img { width: 100%; border-radius: 10px; box-shadow: var(--shadow); display: block; }
.dcard:hover img { outline: 3px solid var(--rose); }
.pager { display: flex; gap: 16px; align-items: center; justify-content: center; margin: 28px 0; }
/* pagination แบบเลขหน้า (โครงตาม sila5school .pagination-2 ปรับสีตามธีม) */
.pagination-2 { margin: 28px 0 8px; }
.pagination-2 ul { display: flex; flex-wrap: wrap; justify-content: center; padding: 0; margin: 0; list-style: none; }
.pagination-2 li { margin: 0 5px; transition: .3s; }
.pagination-2 li a {
  height: 100%; color: var(--muted); padding: 7px 16px;
  display: flex; align-items: center; justify-content: center; border-radius: 8px;
}
.pagination-2 li a:hover { background: var(--rose-soft); color: var(--rose-2); text-decoration: none; }
.pagination-2 li a.active { background: var(--rose); color: #fff; }
.pagination-2 li.disabled span { padding: 7px 4px; display: flex; align-items: center; color: var(--muted); }

/* book detail */
.book-detail .back { display: inline-block; margin-bottom: 12px; }
.book-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.book-cover { width: 160px; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px; box-shadow: var(--shadow); }
.book-head h1 { margin: .1em 0 .3em; }
.book-meta { margin: 8px 0 14px; }
.book-meta p { margin: 4px 0; color: var(--ink); }
.book-meta b { color: var(--muted); font-weight: 600; }
.book-meta .bm-val { color: var(--rose-2); font-weight: 700; }
.book-files { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.book-files .bf {
  display: inline-flex; align-items: center; gap: 7px; padding: 11px 18px;
  border-radius: 12px; text-decoration: none; font-weight: 700; font-size: .95rem;
  background: var(--rose-soft); color: var(--rose-2); border: 1px solid #f5ccd3;
}
.book-files .bf:hover { background: #f8d6db; }
.book-files .bf.pdf { background: #fbe6e8; color: #c14a54; border-color: #f3ccd0; }
.book-files .bf.pdf:hover { background: #f6d5d9; }
.book-detail h2 { margin-top: 38px; }
.chapters { list-style: none; padding: 0; margin: 14px 0; }
.chapter { border-bottom: 1px solid var(--line); }
.ch-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 8px 4px; }
.ch-num {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 7px; border-radius: 8px;
  background: #7a4a52; color: #fff; font-weight: 700; font-size: .95rem;
}
.ch-name { flex: 1; text-align: left; background: none; border: 0; font: inherit; color: var(--ink); cursor: pointer; padding: 8px 0; }
.ch-name:hover { color: var(--rose-2); }
.ch-name .tw { display: inline-block; transition: transform .15s; color: var(--rose); margin-right: 4px; }
.chapter.open .ch-name .tw { transform: rotate(90deg); }
.ch-icons { display: flex; gap: 8px; white-space: nowrap; align-items: center; }
.ch-icons .ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: transparent; text-decoration: none; transition: background .15s;
}
.ch-icons .ic .bi { font-size: 20px; line-height: 1; }
.ch-icons .ic.eye { color: var(--rose-2); background: var(--rose-soft); }
.ch-icons .ic.eye:hover { background: #f6ccd4; }
.ch-icons .ic.pdf { color: #e0555f; background: #fbe6e8; }
.ch-icons .ic.pdf:hover { background: #f6d3d7; }
.ch-body { display: none; }
.chapter.open .ch-body { display: block; }
.chapter-content { padding: 6px 4px 18px; }
.chapter-content .ch-text { white-space: pre-wrap; line-height: 1.9; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 10px; }

/* reader */
.reader .back { display: inline-block; margin-bottom: 12px; }
.reader h1 { font-size: 1.7rem; margin: .2em 0; }
.reader-meta { display: flex; gap: 8px; margin-bottom: 16px; font-size: .9rem; align-items: center; flex-wrap: wrap; }
.reader-hint { font-size: .85rem; margin: .2em 0 1em; }
.reader-body { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); line-height: 1.9; }
.reader-body mark { padding: 1px 2px; }

/* cards: แถวค้นหา + ปุ่ม Filter (โครงเดียวกับหน้าหนังสือ ใช้ .bf-* ร่วมกัน) */
.card-filter { margin: 16px 0 0; }
.cm-actions .btn {
  border: 0; border-radius: 12px; padding: 11px 20px; font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.result-line { margin: 14px 0 12px; }
.bf-modal .tag-search { border-color: var(--line); border-radius: 18px; padding: 8px 16px; margin-bottom: 12px; font-size: 16px; }
.bf-modal .tag-search:focus { border-color: var(--rose); box-shadow: 0 0 0 .2rem rgba(221, 119, 135, .15); }
.bf-tag-options { max-height: 45vh; overflow-y: auto; }
.tag-chip .tag-name { cursor: pointer; }
.tag-chip .tag-count { font-size: .78rem; color: var(--muted); background: var(--chip); padding: 1px 8px; border-radius: 12px; }
a.bf-chip-x, a.bf-clear { text-decoration: none; }
a.bf-chip-x:hover { color: #fff; }
a.bf-clear { text-decoration: underline; }

/* card lightbox */
.card-modal { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card-modal[hidden] { display: none; }
.cm-backdrop { position: absolute; inset: 0; background: rgba(40, 22, 30, .6); }
.cm-box {
  position: relative; z-index: 1; width: min(560px, 94vw); max-height: 92vh; overflow: auto;
  background: var(--surface); border-radius: 20px; padding: 18px 20px 22px; box-shadow: 0 20px 60px rgba(30, 10, 20, .4);
}
.cm-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cm-count { font-weight: 700; color: var(--ink); }
.cm-x { border: 0; background: var(--chip); width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 1rem; color: var(--ink); }
.cm-x:hover { background: var(--line); }
.cm-stage { position: relative; display: flex; align-items: center; justify-content: center; margin: 4px 0 12px; }
.cm-img { max-width: 100%; max-height: 56vh; border-radius: 12px; display: block; }
.cm-nav {
  position: absolute; top: 50%; transform: translateY(-50%); border: 0; cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .85); color: var(--rose-2);
  font-size: 1.6rem; line-height: 1; box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.cm-nav:hover { background: #fff; }
.cm-nav.prev { left: 6px; }
.cm-nav.next { right: 6px; }
.cm-content { white-space: pre-wrap; color: var(--ink); font-size: 1.12rem; line-height: 1.7; text-align: center; margin: 4px 0 10px; }
.cm-tags { color: var(--rose-2); font-size: .9rem; text-align: center; margin-bottom: 14px; }
.cm-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.cm-actions .btn { border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
.cm-actions .btn.copy { border-color: var(--rose); color: var(--rose-2); }
.cm-actions .btn.share { border-color: var(--gold); color: #a5843e; }
.cm-actions .btn.dl { border-color: #4a86c5; color: #356ea8; }
.cm-actions .btn:hover { filter: brightness(.97); text-decoration: none; }
.cm-toast { margin-top: 12px; text-align: center; color: #2f7d43; font-weight: 700; }

/* stats: usage + chart */
.stat-sec { margin: 26px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.usage-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.ucard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px; text-align: center; }
.ucard.all { background: linear-gradient(135deg, #fdeff1, #f9d6db); border-color: var(--rose); }
.ucard .ut { display: block; font-size: .85rem; color: var(--muted); }
.ucard b { display: block; font-size: 1.7rem; color: var(--rose-2); line-height: 1.2; }
.ucard em { font-style: normal; font-size: .78rem; color: var(--muted); }
.ucard i { display: block; font-style: normal; font-size: .82rem; color: var(--ink); margin-top: 3px; }
.chart-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; margin-bottom: 8px; }
.chart-top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.chart-legend { display: flex; gap: 16px; font-size: .85rem; color: var(--muted); }
.chart-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.sw.views { background: var(--rose); }
.sw.vis { background: var(--gold); }
.grain-tabs { display: flex; gap: 6px; }
.gt { border: 1.5px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 20px; padding: 6px 14px; font: inherit; font-size: .85rem; cursor: pointer; }
.gt.on { background: var(--rose); border-color: var(--rose); color: #fff; }
.chart { display: flex; align-items: flex-end; gap: 8px; height: 180px; overflow-x: auto; padding-top: 8px; }
.bar-group { flex: 1 0 26px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-group .bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; }
.bar { width: 11px; border-radius: 4px 4px 0 0; transition: height .2s; }
.bar.views { background: var(--rose); }
.bar.vis { background: var(--gold); }
.bar-group .bl { font-size: .72rem; color: var(--muted); margin-top: 6px; white-space: nowrap; }

/* stats: search (two topics) */
.stat-cards { display: flex; gap: 14px; flex-wrap: wrap; margin: 18px 0 30px; }
.stat-card { flex: 1; min-width: 150px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; text-align: center; box-shadow: var(--shadow); }
.stat-card b { display: block; font-size: 2rem; color: var(--rose-2); }
.stat-card span { color: var(--muted); font-size: .9rem; }
.search-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.ss-head { margin: 0 0 12px; padding: 8px 12px; border-radius: 10px; font-size: 1.05rem; background: #f1eaf6; color: #7d5a8a; }
.ss-head.card { background: var(--rose-soft); color: var(--rose-2); }
.ss-col h4 { margin: 16px 0 8px; font-size: .95rem; color: var(--ink); }
.rank { margin: 0; padding-left: 1.4em; }
.rank li { margin: 6px 0; display: flex; justify-content: space-between; gap: 10px; }
.rank .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.rank.zero li span:first-child { color: var(--ink); }

/* หน้า 404 */
.nf-wrap { display: flex; align-items: center; justify-content: center; }
.nf-card { text-align: center; padding: 48px 20px; }
.nf-card img { width: 72px; height: 72px; object-fit: contain; opacity: .9; margin-bottom: 6px; }
.nf-card h1 { font-size: 1.6rem; margin: 10px 0 6px; }
.nf-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.nf-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 24px;
  border-radius: 24px; border: 1px solid var(--line); background: var(--surface);
  color: var(--rose-2); font-weight: 600;
}
.nf-btn:hover { background: var(--rose); border-color: var(--rose); color: #fff; text-decoration: none; }
.nf-btn.primary { background: var(--rose); border-color: var(--rose); color: #fff; }
.nf-btn.primary:hover { background: var(--rose-2); }

/* หน้า login */
.login-wrap { display: flex; align-items: center; justify-content: center; padding-top: 8vh; }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow); padding: 40px 36px 32px; width: min(430px, 100%); text-align: center;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.login-brand:hover { text-decoration: none; }
.login-brand img { width: 64px; height: 64px; object-fit: contain; }
.lb-text { font-size: 1.5rem; font-weight: 800; color: var(--ink); letter-spacing: .5px; }
.lb-text b { color: var(--rose); }
.login-card h1 { font-size: 1.35rem; margin: 14px 0 2px; }
.login-sub { margin: 0 0 24px; }
.g-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  padding: 11px 0; border: 1px solid var(--line); border-radius: 24px;
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.g-btn:hover { text-decoration: none; color: var(--ink); border-color: #e8b6c0; box-shadow: var(--shadow); }

/* footer */
.site-foot {
  text-align: center; padding: 30px 20px; color: #8c5560;
  border-top: 1px solid #eeb6bf;
  background: linear-gradient(180deg, #fbe4e7 0%, #f7d0d6 100%);
}
.site-foot p { margin: 4px 0; font-size: .9rem; }
.foot-brand { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.foot-brand:hover { text-decoration: none; }
.foot-brand img { width: 40px; height: 40px; object-fit: contain; }
.foot-brand span { font-weight: 800; font-size: 1.1rem; color: var(--ink); letter-spacing: .5px; }
.foot-brand b { color: var(--rose); }
.foot-nav { display: flex; align-items: center; justify-content: center; gap: 10px 28px; margin-bottom: 14px; flex-wrap: wrap; }
.foot-nav a { color: #8c4350; font-weight: 600; }
.foot-nav a:hover { color: var(--rose-2); }
.foot-fb { display: inline-flex; font-size: 1.35rem; color: var(--rose-2); line-height: 1; margin-bottom: 6px; }
.foot-fb:hover { color: var(--rose); text-decoration: none; }

/* responsive */
@media (max-width: 799px) {
  .creators-grid { grid-template-columns: 1fr; }
  .creator-col { padding: 22px 8px; }
  .creators-strip { padding: 32px 18px 34px; }
}
@media (max-width: 799px) {
  .search-top { padding: 13px 14px; }
  .search-filters { padding: 10px 14px 0; }
  .st-row { gap: 8px 10px; }
  .st-brand span { display: none; }
  .st-search { min-width: 0; max-width: none; }
  .st-search input { padding: 8px 12px; font-size: 16px; }
  .st-search button { padding: 8px 14px; font-size: .95rem; }
  .search-top .home-top-links { gap: 10px; font-size: .9rem; }
  .search-top .login-btn { padding: 5px 14px; }
  /* ยุบเมนูเป็นปุ่ม ☰ กดแล้วกางรายการ (login ยังโชว์เสมอ) */
  .st-menu-toggle { display: inline-flex; }
  .st-menu {
    display: none; position: absolute; top: calc(100% + 10px); right: 0; z-index: 30;
    flex-direction: column; align-items: stretch; gap: 0; min-width: 170px;
    background: #fff; border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 12px 30px rgba(140, 55, 70, .18); padding: 6px 0;
  }
  .st-links.open .st-menu { display: flex; }
  .st-menu a { padding: 10px 18px; }
  .st-menu a:hover { background: var(--rose-soft); text-decoration: none; }
  .search-filters { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .search-filters .creator-chip span { white-space: nowrap; }
}
@media (max-width: 720px) {
  .usage-cards { grid-template-columns: repeat(2, 1fr); }
  .search-stats { grid-template-columns: 1fr; }
}
