/* ============================== Night Witch ============================== */
:root {
  --bg: #eceef3;
  --shell: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f5f8;
  --hover: #f3f1fb;
  --ink: #15171c;
  --muted: #6b7280;
  --muted-2: #c2c6d2;
  --line: #e7e9ef;
  --line-strong: #d7dae3;
  --outline: #15171c;
  --brand: #6d28d9;
  --brand-soft: #f3edff;
  --brand-ink: #5b21b6;
  --on-brand: #ffffff;
  --link: #2563eb;
  --danger: #e11d48;
  --ok-bg: #e7f8ee; --ok-ink: #137a43; --ok-line: #b7e6c9;
  --err-bg: #fdeaee; --err-ink: #b21d3a; --err-line: #f4c2cd;
  --thumb-bg: #eef0f4;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(20, 23, 40, .08);
  --shadow-sm: 0 4px 14px rgba(20, 23, 40, .07);
}

:root[data-theme="dark"] {
  --bg: #2b2e34;
  --shell: #32353c;
  --surface: #3b3e46;
  --surface-2: #44474f;
  --hover: #4a4753;
  --ink: #edeff3;
  --muted: #aeb4be;
  --muted-2: #757b86;
  --line: #4a4e56;
  --line-strong: #565b64;
  --outline: #61656f;
  --brand: #8b5cff;
  --brand-soft: #443d5e;
  --brand-ink: #bda6ff;
  --on-brand: #ffffff;
  --link: #88b6ff;
  --danger: #ff6b85;
  --ok-bg: #29402f; --ok-ink: #84e2a8; --ok-line: #3a5a45;
  --err-bg: #452730; --err-ink: #ffa3b3; --err-line: #5f3a44;
  --thumb-bg: #44474f;
  --shadow: 0 12px 30px rgba(0, 0, 0, .35);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, .28);
}

:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Sarabun', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--shell);
  line-height: 1.55;
}

body, .sidebar, .topbar, .panel, .side-block, .details, .card, .nav-item,
.search, .btn, .field input, .field textarea, .list-row {
  transition: background-color .25s ease, border-color .25s ease, color .25s ease;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
svg { width: 100%; height: 100%; }

/* -------------------------------- shell --------------------------------- */
.app-shell {
  background: var(--shell);
  display: grid;
  grid-template-columns: 268px 1fr;
  overflow: hidden;
  height: 100vh;
  height: 100dvh; /* ล็อกความสูงเท่าหน้าจอ — แถบซ้ายอยู่กับที่ เนื้อหาเลื่อนในตัวเอง */
  position: relative;
}

/* -------------------------------- sidebar ------------------------------- */
/* แถบซ้ายล็อกไว้เต็มความสูงจอ ไม่เลื่อนตามเนื้อหา; ถ้าเมนูยาวเกินจะเลื่อนภายในตัวเอง */
.sidebar {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line-strong);
}
.sidebar-scroll {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.sidebar-scroll::-webkit-scrollbar { width: 8px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
/* เผื่อที่ว่างด้านล่างตอนมีลูกศรเลื่อน เพื่อไม่ให้ปุ่มลูกศรบังเนื้อหาที่กำลังเลื่อน */
.sidebar-scroll.pad-for-hint { padding-bottom: 56px; }

/* ลูกศรบอกว่าเลื่อนลงดูเมนูเพิ่มได้ (โผล่เฉพาะตอนแถบยาวเกินและยังเลื่อนลงได้) */
.side-scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: none; border-radius: 50%;
  background: var(--brand); color: var(--on-brand);
  box-shadow: var(--shadow-sm);
  cursor: pointer; z-index: 5;
  animation: side-hint-bounce 1.5s ease-in-out infinite;
}
.side-scroll-hint[hidden] { display: none; }
.side-scroll-hint svg { width: 20px; height: 20px; }
@keyframes side-hint-bounce {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, 4px); }
}
@media (prefers-reduced-motion: reduce) {
  .side-scroll-hint { animation: none; }
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.brand {
  font-family: 'Kanit', sans-serif;
  font-weight: 700;
  font-size: 24px;
  letter-spacing: .3px;
}
.icon-btn {
  width: 40px; height: 40px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--ink);
  cursor: pointer;
  padding: 8px;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 24px; height: 24px; }

.nav { display: flex; flex-direction: column; gap: 10px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border: 1.6px solid var(--outline);
  border-radius: 14px;
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  font-size: 17px;
  background: var(--surface);
}
.nav-item:hover { background: var(--hover); }
.nav-item:active { transform: translateY(1px); }
.nav-item.is-active { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.nav-ic { width: 26px; height: 26px; flex: 0 0 auto; }
/* จุดแดง "มีของใหม่" มุมขวาบนของเมนู */
.nav-dot {
  position: absolute; top: 7px; right: 9px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 2px var(--surface);
  animation: nav-dot-pop .25s ease;
}
@keyframes nav-dot-pop { from { transform: scale(0); } to { transform: scale(1); } }

/* ปุ่มติดตาม (รับแจ้งเตือนคอนเทนต์ใหม่) */
.follow-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 11px 14px;
  border: 1.6px solid var(--brand); border-radius: 14px;
  background: var(--brand); color: var(--on-brand);
  font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 16px; cursor: pointer;
  transition: filter .15s ease, background-color .2s ease, color .2s ease;
}
.follow-btn:hover { filter: brightness(1.06); }
.follow-btn[hidden] { display: none; }
.follow-btn.busy { opacity: .6; pointer-events: none; }
.follow-btn .follow-ic { width: 22px; height: 22px; flex: 0 0 auto; display: grid; place-items: center; }
.follow-btn .follow-ic svg { width: 22px; height: 22px; }
.follow-btn.is-following { background: var(--surface); color: var(--brand-ink); }

/* ---- ปุ่มบัญชี / โปรไฟล์ ในเมนู ---- */
.auth-box[data-loading] { opacity: .55; }
.auth-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 11px 14px;
  border: 1.6px solid var(--brand); border-radius: 14px;
  background: var(--brand); color: var(--on-brand);
  font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 15px;
}
.auth-btn:hover { filter: brightness(1.06); }
.auth-btn svg { width: 22px; height: 22px; flex: 0 0 auto; }
.auth-profile {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1.4px solid var(--line-strong); border-radius: 14px;
}
.auth-profile:hover { background: var(--hover); }
.auth-ava { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; background: var(--brand-soft); flex: 0 0 auto; display: grid; place-items: center; }
.auth-ava img { width: 100%; height: 100%; object-fit: cover; }
.auth-uname { font-family: 'Kanit', sans-serif; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-stat { font-size: 12.5px; color: var(--muted); text-align: center; }
.member-stat[hidden] { display: none; }
/* ปุ่มเข้าหลังบ้านในเมนู (โชว์เฉพาะแอดมิน) */
.auth-admin { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; padding: 9px 12px;
  border-radius: 12px; border: 1.4px solid var(--brand); color: var(--brand); font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 14px; text-decoration: none; }
.auth-admin:hover { background: var(--brand); color: var(--on-brand); }
.auth-admin svg { width: 18px; height: 18px; flex: none; }
.app-shell.collapsed .auth-label, .app-shell.collapsed .auth-uname, .app-shell.collapsed .member-stat, .app-shell.collapsed .auth-admin span { display: none; }
.app-shell.collapsed .auth-btn, .app-shell.collapsed .auth-profile, .app-shell.collapsed .auth-admin { padding: 9px; justify-content: center; }
/* ปุ่มเข้าหลังบ้านในหน้าบัญชี */
.admin-enter { gap: 8px; margin: 2px 0 4px; }
.admin-enter svg { width: 18px; height: 18px; }

/* ---- หน้า /join, /account ---- */
body.auth-page .content-body { display: flex; align-items: flex-start; justify-content: center; }
.auth-card {
  width: 100%; max-width: 420px; margin: 10px auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.auth-head { display: flex; align-items: center; gap: 10px; }
.auth-head svg { width: 30px; height: 30px; color: var(--brand); flex: 0 0 auto; }
.auth-head h2 { margin: 0; font-family: 'Kanit', sans-serif; font-size: 21px; }
.auth-tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.auth-tab { flex: 1; padding: 9px; border: none; background: none; border-radius: 9px; font-family: 'Kanit', sans-serif; font-weight: 600; cursor: pointer; color: var(--muted); }
.auth-tab.is-active { background: var(--surface); color: var(--brand-ink); box-shadow: var(--shadow-sm); }
.auth-panel { display: none; flex-direction: column; gap: 12px; }
.auth-panel.is-active { display: flex; }
.reg-step { display: flex; flex-direction: column; gap: 12px; }
.reg-step[hidden] { display: none; }
.uname-wrap { display: flex; align-items: center; border: 1.6px solid var(--outline); border-radius: 12px; overflow: hidden; background: var(--surface); }
.uname-at { padding: 0 2px 0 12px; color: var(--muted); font-weight: 700; }
.uname-wrap input { border: none; flex: 1; padding: 11px 12px 11px 4px; background: none; color: var(--ink); font-family: inherit; }
.uname-wrap input:focus { outline: none; }
.uname-hint { font-size: 13px; min-height: 16px; }
.uname-hint.ok { color: #16a34a; }
.uname-hint.err { color: var(--danger); }
.auth-warn { font-size: 13px; background: var(--err-bg); color: var(--err-ink); border: 1px solid var(--err-line); border-radius: 10px; padding: 8px 10px; }
.auth-msg { font-size: 14px; min-height: 18px; }
.auth-msg.err { color: var(--danger); }
.auth-msg.ok { color: #16a34a; }
.btn-block { width: 100%; justify-content: center; }
.account-top { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 6px; }
.account-avatar { width: 90px; height: 90px; border-radius: 50%; overflow: hidden; background: var(--brand-soft); display: grid; place-items: center; }
.account-avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-avatar svg { width: 44px; height: 44px; color: var(--muted-2); }
.account-name { font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 20px; }
.account-email { color: var(--muted); font-size: 14px; }
.account-since { color: var(--muted); font-size: 13px; }

.side-block {
  border: 1.4px solid var(--line-strong);
  border-radius: 14px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.side-head {
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  text-align: center;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 2px;
}
.social-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.social-item:hover { background: var(--hover); }
.social-ic { width: 26px; height: 26px; flex: 0 0 auto; }

.side-spacer { flex: 1 1 auto; min-height: 10px; }

/* backdrop ของลิ้นชักมือถือ — อยู่นอก grid flow เสมอ (กันไปแย่งคอลัมน์เนื้อหา) */
.backdrop {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(10, 11, 18, .4);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .2s;
}
.backdrop.show { opacity: 1; visibility: visible; pointer-events: auto; }

/* -------------------------------- content ------------------------------- */
/* พื้นที่เนื้อหาเลื่อนภายในตัวเอง (แถบซ้ายจึงอยู่นิ่ง ไม่เลื่อนตาม) */
.content {
  display: flex; flex-direction: column; min-width: 0;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px clamp(16px, 2.5vw, 30px);
  border-bottom: 1px solid var(--line);
}
.menu-toggle { display: none; }

.search {
  position: relative;
  flex: 1 1 auto;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.6px solid var(--outline);
  border-radius: 999px;
  padding: 6px 14px 6px 8px;
}

/* กล่องผลค้นหา (ชื่อ + รูปปกเล็ก) */
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 40;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden auto;
  max-height: min(70vh, 460px);
  padding: 6px;
}
.search-results[hidden] { display: none; }
.search-result {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; border-radius: 10px; color: var(--ink);
}
.search-result:hover, .search-result.is-active { background: var(--hover); }
.sr-thumb {
  width: 92px; aspect-ratio: 16 / 9; flex: 0 0 auto;
  border-radius: 8px; overflow: hidden; background: var(--thumb-bg);
  display: grid; place-items: center; color: var(--muted-2);
}
.sr-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sr-thumb svg { width: 26px; height: 26px; }
.sr-title {
  font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 15px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.search-empty { padding: 16px 12px; color: var(--muted); text-align: center; font-size: 14px; }
.search-ic {
  width: 34px; height: 34px;
  border: none; background: transparent; cursor: pointer;
  color: var(--ink); padding: 6px; order: 2;
  display: grid; place-items: center; flex: 0 0 auto;
}
.search input {
  order: 1;
  flex: 1 1 auto;
  border: none; outline: none; background: transparent;
  font-family: 'Sarabun', sans-serif; font-size: 16px; color: var(--ink);
  min-width: 0;
}
.contact-note {
  flex: 0 0 auto;
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.content-body { padding: clamp(16px, 2.5vw, 28px); flex: 1 1 auto; }

/* --------------------------------- grid --------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: clamp(14px, 1.8vw, 22px);
}

.card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  font: inherit; color: inherit;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s;
  padding: 0;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--brand); }
.card:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 2px; }

.thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--thumb-bg);
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-fallback {
  width: 100%; height: 100%;
  display: grid; place-items: center; color: var(--muted-2);
}
.thumb-fallback svg { width: 46px; height: 46px; }

.play-badge {
  position: absolute; inset: 0; margin: auto;
  width: 60px; height: 60px;
  display: grid; place-items: center;
  background: rgba(0,0,0,.45);
  color: #fff;
  border-radius: 50%;
  border: 3px solid #fff;
  backdrop-filter: blur(1px);
  transition: transform .15s, background .15s;
}
.play-badge svg { width: 28px; height: 28px; margin-left: 3px; }
.play-badge.sm { width: 38px; height: 38px; border-width: 2px; }
.play-badge.sm svg { width: 18px; height: 18px; }
.video-card:hover .play-badge { transform: scale(1.07); background: var(--brand); }

.card-body { padding: 12px 14px; }
.card-title {
  margin: 0;
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { color: var(--muted); font-size: 12.5px; margin-top: 5px; }

/* ============================ posts feed (FB style) ===================== */
.feed { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.post {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.post-author { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.post-avatar {
  width: 46px; height: 46px; border-radius: 50%; overflow: hidden; flex: 0 0 auto;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; border: 1px solid var(--line-strong);
}
.post-avatar img { width: 100%; height: 100%; object-fit: cover; }
.post-avatar svg { width: 24px; height: 24px; }
.post-author-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.post-author-name { font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 16px; color: var(--ink); }
.post-author-date { color: var(--muted); font-size: 12.5px; }
.logo-preview { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: -4px 0 4px; }
.logo-preview img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line-strong); }
.post-text { white-space: normal; word-break: break-word; font-size: 16px; line-height: 1.55; }
.post-text.clamp {
  display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: 5; line-clamp: 5; overflow: hidden;
}
.post-toggle {
  margin-top: 6px; background: none; border: none; padding: 0;
  color: var(--brand-ink); font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 14px; cursor: pointer;
}
.post-toggle:hover { text-decoration: underline; }

.post-images { display: grid; gap: 3px; margin-top: 12px; border-radius: 12px; overflow: hidden; }
.post-images .post-img {
  padding: 0; border: none; cursor: pointer; position: relative;
  background: var(--thumb-bg); overflow: hidden;
}
.post-images .post-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-img-more {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0, 0, 0, .5); color: #fff;
  font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 30px;
}
.post-images.n1 { grid-template-columns: 1fr; }
.post-images.n1 .post-img { max-height: 600px; }
.post-images.n1 .post-img img { height: auto; max-height: 600px; }
.post-images.n2 { grid-template-columns: 1fr 1fr; }
.post-images.n2 .post-img { aspect-ratio: 1 / 1; }
.post-images.n3 { grid-template-columns: 1fr 1fr; }
.post-images.n3 .post-img:first-child { grid-column: 1 / -1; aspect-ratio: 16 / 9; }
.post-images.n3 .post-img:not(:first-child) { aspect-ratio: 1 / 1; }
.post-images.n4 { grid-template-columns: 1fr 1fr; }
.post-images.n4 .post-img { aspect-ratio: 1 / 1; }

.image-card .thumb { aspect-ratio: 4 / 3; }

.no-result {
  text-align: center;
  color: var(--muted);
  padding: 50px 10px;
  font-size: 18px;
}

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 56px 18px; text-align: center; color: var(--muted);
}
.empty-ic { width: 64px; height: 64px; color: var(--muted-2); }
.empty-title { font-family: 'Kanit', sans-serif; font-size: 20px; color: var(--ink); }
.empty-sub { font-size: 15px; }
.empty .btn { margin-top: 8px; }

/* --------------------------------- watch -------------------------------- */
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-weight: 600; margin-bottom: 14px;
}
.back-link:hover { color: var(--brand); }
.back-link svg { width: 20px; height: 20px; }

.watch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: clamp(18px, 2.4vw, 28px);
  align-items: start;
}
.watch.solo { grid-template-columns: 1fr; }
.watch.solo .watch-main { max-width: 920px; }
.watch-main { min-width: 0; }
.player {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  box-shadow: var(--shadow);
}
.player video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }

/* ===== ตัวเล่นวิดีโอแบบกำหนดเอง ===== */
.vplayer { position: relative; }
.vplayer video { cursor: pointer; }
.vplayer:fullscreen, .vplayer:-webkit-full-screen { aspect-ratio: auto; width: 100%; height: 100%; border-radius: 0; }
.vplayer:fullscreen video, .vplayer:-webkit-full-screen video { width: 100%; height: 100%; }

.vp-bigplay {
  position: absolute; inset: 0; margin: auto;
  width: 76px; height: 76px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.5); color: #fff;
  display: grid; place-items: center; cursor: pointer;
  transition: opacity .2s, transform .15s, background .15s;
}
.vp-bigplay svg { width: 36px; height: 36px; margin-left: 4px; }
.vp-bigplay:hover { background: var(--brand); transform: scale(1.06); }
.vplayer[data-state="playing"] .vp-bigplay,
.vplayer[data-state="ended"] .vp-bigplay { opacity: 0; pointer-events: none; transform: scale(.8); }
.vplayer[data-state="ended"] .vp-bigplay { opacity: 1; pointer-events: auto; transform: none; }

.vp-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 26px 12px 8px;
  background: linear-gradient(to top, rgba(0,0,0,.78), rgba(0,0,0,0));
  opacity: 1; transition: opacity .25s;
  display: flex; flex-direction: column; gap: 4px;
}
.vplayer.vp-idle[data-state="playing"] .vp-controls { opacity: 0; pointer-events: none; }
.vplayer.vp-idle[data-state="playing"] { cursor: none; }

.vp-seek { position: relative; padding: 9px 0; cursor: pointer; touch-action: none; }
.vp-track { position: relative; height: 5px; border-radius: 3px; background: rgba(255,255,255,.3); transition: height .1s; }
.vp-buffered { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255,255,255,.4); border-radius: 3px; }
.vp-played { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--brand); border-radius: 3px; }
.vp-knob {
  position: absolute; right: -7px; top: 50%; transform: translate(0, -50%) scale(0);
  width: 14px; height: 14px; border-radius: 50%; background: var(--brand); transition: transform .12s;
}
.vp-seek:hover .vp-track, .vp-seek.dragging .vp-track { height: 7px; }
.vp-seek:hover .vp-knob, .vp-seek.dragging .vp-knob { transform: translate(0, -50%) scale(1); }

.vp-tip {
  position: absolute; bottom: 30px; transform: translateX(-50%);
  background: rgba(0,0,0,.85); color: #fff; pointer-events: none;
  padding: 5px; border-radius: 10px; box-shadow: 0 4px 14px rgba(0,0,0,.45);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.vp-tip[hidden] { display: none; }
.vp-tip-thumb { display: block; width: 150px; height: 84px; border-radius: 6px; background: #000; object-fit: cover; }
.vp-tip-thumb[hidden] { display: none; }
.vp-tip-time {
  font-size: 12px; font-weight: 600; white-space: nowrap;
  font-family: 'Kanit', sans-serif; font-variant-numeric: tabular-nums;
}

.vp-row { display: flex; align-items: center; gap: 6px; color: #fff; }
.vp-btn { width: 38px; height: 38px; border: none; background: none; color: #fff; cursor: pointer; display: grid; place-items: center; border-radius: 8px; padding: 7px; flex: 0 0 auto; }
.vp-btn:hover { background: rgba(255,255,255,.16); }
.vp-btn svg { width: 24px; height: 24px; }
.vp-time { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; margin-left: 2px; }
.vp-spacer { flex: 1 1 auto; }
.vp-vol { width: 78px; height: 4px; -webkit-appearance: none; appearance: none; background: rgba(255,255,255,.35); border-radius: 3px; cursor: pointer; flex: 0 0 auto; }
.vp-vol::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: #fff; cursor: pointer; }
.vp-vol::-moz-range-thumb { width: 13px; height: 13px; border: none; border-radius: 50%; background: #fff; cursor: pointer; }

/* ===== เจสเจอร์บนมือถือ + แอนิเมชัน ===== */
/* วิดีโอสำรองสำหรับสร้างภาพตัวอย่างตอนลากแถบเวลา (ซ่อนไว้นอกจอ) */
.vp-thumb-src { position: absolute; left: -9999px; top: 0; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
/* ชั้นรับสัมผัส คลุมพื้นที่วิดีโอ (อยู่ใต้ปุ่มควบคุม/ปุ่มเล่นใหญ่) */
.vp-gestures { position: absolute; inset: 0; z-index: 1; touch-action: manipulation; }
.vp-bigplay { z-index: 3; }
/* กันเมนูคัดลอก/เลือกข้อความตอนกดค้างบนมือถือ ให้กดค้าง = เร่งความเร็วแทน */
.vplayer, .vp-gestures, .vplayer video {
  -webkit-user-select: none; -moz-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}

/* ภาพเคลื่อนไหว ±5 วินาที เวลาแตะ 2 ครั้งซ้าย/ขวา */
.vp-seekfx {
  position: absolute; top: 0; bottom: 0; width: 42%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: #fff; opacity: 0; pointer-events: none; transition: opacity .2s ease;
  background: radial-gradient(circle at center, rgba(255,255,255,.16), rgba(255,255,255,0) 72%);
}
.vp-seekfx-l { left: 0; border-radius: 0 60% 60% 0 / 0 50% 50% 0; --dir: -8px; }
.vp-seekfx-r { right: 0; border-radius: 60% 0 0 60% / 50% 0 0 50%; --dir: 8px; }
.vp-seekfx.show { opacity: 1; }
.vp-seekfx-ic svg { width: 40px; height: 40px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.vp-seekfx.show .vp-seekfx-ic { animation: vp-seekfx-pulse .5s ease; }
@keyframes vp-seekfx-pulse { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(var(--dir, 0)); } }
.vp-seekfx-tx { font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,.7); font-variant-numeric: tabular-nums; }

/* วงกลมกลางจอ เวลากด เล่น/หยุด */
.vp-tapfx {
  position: absolute; inset: 0; margin: auto; width: 74px; height: 74px; border-radius: 50%;
  background: rgba(0,0,0,.52); color: #fff; display: grid; place-items: center;
  opacity: 0; pointer-events: none; z-index: 4;
}
.vp-tapfx svg { width: 34px; height: 34px; }
.vp-tapfx.show { animation: vp-tapfx-anim .5s ease forwards; }
@keyframes vp-tapfx-anim { 0% { opacity: .95; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.3); } }

/* วงกลมหมุนตอนเน็ตช้า/กำลังโหลด (บัฟเฟอร์) */
.vp-spinner {
  position: absolute; inset: 0; margin: auto; z-index: 3; pointer-events: none;
  width: 54px; height: 54px; border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, .28);
  border-top-color: #fff;
  animation: vp-spin .8s linear infinite;
}
.vp-spinner[hidden] { display: none; }
@keyframes vp-spin { to { transform: rotate(360deg); } }

/* ป้าย 2x ตอนกดค้าง */
.vp-speedfx {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.66); color: #fff; padding: 5px 13px; border-radius: 999px;
  display: flex; align-items: center; gap: 4px; z-index: 4;
  font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .15s ease;
}
.vp-speedfx svg { width: 15px; height: 15px; }
.vp-speedfx.show { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .vp-seekfx.show .vp-seekfx-ic, .vp-tapfx.show { animation: none; }
}

@media (max-width: 600px) {
  .vp-vol { display: none; }
  .vp-bigplay { width: 62px; height: 62px; }
  .vp-bigplay svg { width: 28px; height: 28px; }
  .vp-btn { width: 36px; height: 36px; }
}

.watch-meta { color: var(--muted); font-size: 14px; margin: -8px 0 16px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.watch-meta .meta-dot { opacity: .55; }

.watch-info { padding: 20px 2px 0; }
.watch-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 18px;
}
.watch-title { font-family: 'Kanit', sans-serif; font-weight: 700; font-size: clamp(21px, 2.6vw, 28px); margin: 0; flex: 1 1 auto; min-width: 0; }
.watch-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.share-hint { color: #16a34a; font-weight: 600; font-size: 14px; }

.details {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-size: 16px;
}
.details-text { white-space: normal; word-break: break-word; }
.details-text.clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.details-toggle {
  margin-top: 10px; background: none; border: none; padding: 0;
  color: var(--brand-ink); font-family: 'Kanit', sans-serif; font-weight: 600;
  font-size: 14px; cursor: pointer;
}
.details-toggle:hover { text-decoration: underline; }

.inline-link { color: var(--link); font-weight: 600; }
.inline-link:hover { text-decoration: underline; }

/* "Link" ที่ย่อจากลิงก์ยาว — ทำเป็นชิปเล็ก ๆ มีไอคอนต่อท้าย กดง่ายขึ้นบนมือถือ */
.link-tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 8px;
  background: var(--brand-soft);
  line-height: 1.35; white-space: nowrap;
  vertical-align: -0.18em; /* ให้จมลงเล็กน้อยเสมอกับบรรทัด */
}
.link-tag:hover { text-decoration: none; filter: brightness(0.97); }
.link-tag-ic { width: 14px; height: 14px; flex: 0 0 auto; }

.more { min-width: 0; }
.more-head { font-family: 'Kanit', sans-serif; font-size: 18px; margin: 0 0 14px; }
.more-list { display: flex; flex-direction: column; gap: 12px; }
.more-item { display: grid; grid-template-columns: 168px 1fr; gap: 12px; align-items: start; }
.more-thumb {
  position: relative; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden;
  background: var(--thumb-bg); border: 1px solid var(--line-strong);
}
.more-thumb img { width: 100%; height: 100%; object-fit: cover; }
.more-thumb .thumb-fallback svg { width: 30px; height: 30px; }
.more-cap {
  font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 15px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  padding-top: 2px;
}
.more-item:hover .more-cap { color: var(--brand); }
.more-info { min-width: 0; }
.more-meta { color: var(--muted); font-size: 12.5px; margin-top: 5px; }

/* -------------------------------- buttons ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 15px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1.6px solid var(--outline);
  background: var(--surface); color: var(--ink);
  cursor: pointer;
  transition: transform .05s, background .15s, box-shadow .15s;
}
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-ink); }
.btn-ghost { border-color: var(--line-strong); }
.btn-block { width: 100%; }

/* ปุ่มสลับธีมมืด/สว่าง */
.theme-toggle { flex: 0 0 auto; }
.theme-toggle svg { width: 22px; height: 22px; }
.theme-toggle .ic-sun { display: none; }
.theme-toggle .ic-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .ic-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .ic-moon { display: none; }

/* ------------------------------- lightbox ------------------------------- */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 11, 18, .86);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.lightbox[hidden] { display: none; }
.lightbox-fig { margin: 0; max-width: min(960px, 100%); max-height: 90vh; display: flex; flex-direction: column; gap: 12px; }
.lightbox-fig img {
  max-width: 100%; max-height: 72vh; object-fit: contain;
  margin: 0 auto; border-radius: 12px; background: #000;
}
.lightbox-fig figcaption { color: #fff; text-align: center; font-family: 'Kanit', sans-serif; font-size: 18px; }
.lightbox-details { color: #d7dae3; text-align: center; font-size: 15px; max-width: 700px; margin: 0 auto; }
.lightbox-details .inline-link { color: #7eb0ff; }
.lightbox-close {
  position: absolute; top: 16px; right: 22px;
  width: 46px; height: 46px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.14); color: #fff;
  font-size: 30px; line-height: 1; cursor: pointer;
}
.lightbox-close:hover { background: rgba(255,255,255,.28); }
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 50px; height: 50px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.14); color: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.lightbox-nav:hover { background: rgba(255,255,255,.28); }
.lightbox-nav svg { width: 26px; height: 26px; }
.lightbox-nav[disabled] { opacity: .25; cursor: default; }
.lb-prev { left: 18px; }
.lb-next { right: 18px; }
.lightbox-date { color: #aeb4be; text-align: center; font-size: 13px; }
.lightbox-count { color: #cfd3de; text-align: center; font-size: 13px; opacity: .8; }
@media (max-width: 600px) {
  .lightbox-nav { width: 42px; height: 42px; }
  .lb-prev { left: 6px; } .lb-next { right: 6px; }
}

/* จัดกล่อง "ยังไม่มี…" ให้อยู่กึ่งกลางจอแนวตั้งเมื่อยังไม่มีเนื้อหา */
.content-body:has(.empty) { display: flex; align-items: center; justify-content: center; }

/* ===================== responsive (sidebar / breakpoints) ============== */
/* โหมดย่อเมนูด้วยมือ — เฉพาะจอใหญ่ (กดปุ่มในแถบเมนูเพื่อเหลือแต่ไอคอน) */
@media (min-width: 1024px) {
  .app-shell.collapsed { grid-template-columns: 84px 1fr; }
  .app-shell.collapsed .sidebar-scroll { align-items: center; padding: 22px 12px; }
  .app-shell.collapsed .label,
  .app-shell.collapsed .side-head,
  .app-shell.collapsed .brand { display: none; }
  .app-shell.collapsed .brand-row { justify-content: center; }
  .app-shell.collapsed .nav-item { justify-content: center; padding: 11px; }
  .app-shell.collapsed .follow-label { display: none; }
  .app-shell.collapsed .follow-btn { padding: 11px; }
  .app-shell.collapsed .side-block { padding: 10px 6px; align-items: center; }
  .app-shell.collapsed .social-item { justify-content: center; padding: 6px; }
}

/* จอเล็ก-กลาง (มือถือ + แท็บเล็ต) — เมนูกลายเป็นลิ้นชักเลื่อนออกจากซ้าย พร้อมป้ายชื่อครบ */
@media (max-width: 1023px) {
  .app-shell { grid-template-columns: 1fr; }
  .menu-toggle { display: grid; }
  .sidebar {
    position: absolute; inset: 0 auto 0 0; z-index: 50;
    width: min(300px, 86vw);
    transform: translateX(-105%);
    transition: transform .25s ease;
    background: var(--surface);
    box-shadow: var(--shadow);
    border-right: 1px solid var(--line-strong);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .sidebar-toggle { display: none; }
  .contact-note { display: none; }
  .watch { grid-template-columns: 1fr; }
  .watch.solo .watch-main { max-width: none; }
}

/* มือถือ */
@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
  /* วิดีโอบนมือถือ: ฟีดคอลัมน์เดียว ภาพปกใหญ่เต็มกว้าง แบบแอป YouTube */
  .grid-videos { grid-template-columns: 1fr; gap: 22px; }
  .grid-videos .video-card { background: none; border: none; border-radius: 0; }
  .grid-videos .video-card:hover { transform: none; box-shadow: none; }
  .grid-videos .thumb { aspect-ratio: 16 / 9; border-radius: 16px; }
  .grid-videos .video-card:hover .thumb { border-color: var(--line-strong); }
  .grid-videos .card-body { padding: 11px 2px 0; }
  .grid-videos .card-title { font-size: 17px; -webkit-line-clamp: 2; }
  .grid-videos .play-badge { width: 54px; height: 54px; }
  .topbar { padding: 12px 14px; gap: 10px; }
  .content-body { padding: 16px 14px; }
  .more-item { grid-template-columns: 150px 1fr; gap: 11px; }
  .watch-info { padding: 16px 0 0; }
  .btn { padding: 10px 15px; }
}

/* มือถือเล็กมาก — รูปสินค้า 2 คอลัมน์ / วิดีโอยังคอลัมน์เดียวภาพใหญ่ */
@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid-videos { grid-template-columns: 1fr; gap: 20px; }
}

/* ============================== admin pages ============================= */
.admin-body { background: var(--bg); }

.login-wrap { min-height: 80vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 34px 30px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-brand { font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 28px; text-align: center; }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 6px; }
.login-hint { text-align: center; color: var(--muted); font-size: 14px; line-height: 1.6; margin: 2px 0 10px; }
.muted-link { text-align: center; color: var(--muted); font-size: 14px; }
.muted-link:hover { color: var(--brand); }
.locked-note {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted); font-size: 14px; padding: 6px 0 2px; text-align: center;
}
.locked-note svg { width: 20px; height: 20px; flex: 0 0 auto; }

.admin-shell { max-width: 1100px; margin: 0 auto; padding: 8px 4px 60px; }
.admin-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 4px 18px; flex-wrap: wrap;
}
.admin-brand { font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 22px; }
.admin-top-actions { display: flex; gap: 10px; align-items: center; }
.admin-top-actions form { margin: 0; }

/* แท็บแยกหมวด วิดีโอ / รูปสินค้า / ตั้งค่า */
.admin-tabs {
  display: flex; gap: 4px; margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.admin-tab {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 15px;
  padding: 11px 18px; border: none; background: none; color: var(--muted);
  cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1px;
  border-radius: 8px 8px 0 0;
}
.admin-tab svg { width: 20px; height: 20px; }
.admin-tab:hover { color: var(--ink); background: var(--hover); }
.admin-tab.is-active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.admin-tabpanel { display: none; }
.admin-tabpanel.is-active { display: block; }

.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 760px) { .admin-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 18px;
}
.panel-title {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 19px;
  margin: 0 0 16px;
}
.panel-title svg { width: 24px; height: 24px; color: var(--brand); }

.form { display: flex; flex-direction: column; gap: 14px; }
.or-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 13px; font-weight: 600;
  margin: -2px 0;
}
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.field-hint { color: var(--muted); font-size: 13px; margin: -8px 0 0; }

.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 760px) { .settings-grid { grid-template-columns: 1fr; } }
.field-ic { display: inline-flex; align-items: center; gap: 7px; }
.field-ic svg { width: 18px; height: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: 14px; }
.field .req { color: var(--danger); }
.field input, .field textarea {
  font-family: 'Sarabun', sans-serif; font-size: 15px;
  padding: 11px 13px;
  border: 1.5px solid var(--line-strong);
  border-radius: 11px;
  outline: none;
  background: var(--surface-2);
  color: var(--ink);
  width: 100%;
  resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.alert { padding: 12px 16px; border-radius: 12px; font-weight: 600; margin-bottom: 16px; }
.alert-ok { background: var(--ok-bg); color: var(--ok-ink); border: 1px solid var(--ok-line); }
.alert-error { background: var(--err-bg); color: var(--err-ink); border: 1px solid var(--err-line); }

.admin-list { display: flex; flex-direction: column; gap: 10px; }
.list-empty, .list-noresult { color: var(--muted); padding: 14px; text-align: center; }
.list-noresult { margin-top: 4px; }

.admin-search {
  display: flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--line-strong); border-radius: 11px;
  padding: 8px 12px; margin-bottom: 14px; background: var(--surface-2);
}
.admin-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.admin-search-ic { width: 20px; height: 20px; color: var(--muted); flex: 0 0 auto; display: grid; place-items: center; }
.admin-search-input {
  flex: 1 1 auto; border: none; outline: none; background: transparent;
  color: var(--ink); font-family: 'Sarabun', sans-serif; font-size: 15px; min-width: 0;
}

.row-actions { display: flex; align-items: center; gap: 4px; }
.row-actions form { margin: 0; }

.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.edit-img-preview { margin-bottom: 6px; }
.edit-img-preview img {
  max-width: 280px; width: 100%; border-radius: 12px;
  border: 1px solid var(--line-strong); display: block;
}
.list-row {
  display: grid; grid-template-columns: 96px 1fr auto; gap: 14px; align-items: center;
  border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px;
}
.row-thumb { width: 96px; aspect-ratio: 16/10; border-radius: 10px; overflow: hidden; background: var(--thumb-bg); }
.admin-list-img .row-thumb { aspect-ratio: 1/1; width: 72px; }
.row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-thumb-fallback { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted-2); }
.row-thumb-fallback svg { width: 28px; height: 28px; }
.row-info { min-width: 0; }
.row-title {
  font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-sub { font-size: 13px; }
.list-row form { margin: 0; }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: var(--err-bg); }

@media (max-width: 540px) {
  .list-row { grid-template-columns: 64px 1fr auto; gap: 10px; }
  .row-thumb { width: 64px; }
}

/* --------------------------- ad interstitial --------------------------- */
html.nw-iv-lock, html.nw-iv-lock body,
html.lb-lock, html.lb-lock body { overflow: hidden; }
/* .content เป็นตัวเลื่อนของหน้าเว็บ (ไม่ใช่ body) จึงต้องล็อกที่ .content ด้วย
   ตอนโฆษณา/ไลต์บ็อกซ์เปิดคลุมจอ ไม่งั้นเนื้อหาด้านหลังยังเลื่อนได้ */
html.nw-iv-lock .content, html.lb-lock .content { overflow: hidden; }
.nw-iv {
  position: fixed; inset: 0; z-index: 4000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(10, 12, 20, .82);
  backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden;
  transition: opacity .2s ease;
}
.nw-iv.show { opacity: 1; visibility: visible; }
.nw-iv-box {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transform: translateY(10px) scale(.98);
  transition: transform .2s ease;
}
.nw-iv.show .nw-iv-box { transform: none; }
.nw-iv-media {
  background: var(--thumb-bg);
  display: flex; align-items: center; justify-content: center;
  min-height: 160px; max-height: 70vh; overflow: hidden;
}
.nw-iv-pic { display: block; max-width: 100%; max-height: 70vh; object-fit: contain; }
.nw-iv-pic[hidden] { display: none; }
/* วงหมุนตอนกำลังโหลดรูปโฆษณา (เน็ตช้า) */
.nw-iv-spin {
  width: 46px; height: 46px; margin: 34px auto; border-radius: 50%;
  border: 4px solid rgba(140, 140, 150, .3); border-top-color: var(--brand);
  animation: vp-spin .8s linear infinite;
}
.nw-iv-spin[hidden] { display: none; }
.nw-iv-cap {
  padding: 14px 18px 2px;
  font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 17px;
  color: var(--ink); line-height: 1.45;
}
.nw-iv-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; min-height: 30px;
}
.nw-iv-time { font-size: 14px; color: var(--muted); }
.nw-iv-x {
  margin-left: auto;
  border: 0; cursor: pointer;
  background: var(--brand); color: var(--on-brand);
  font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 15px;
  padding: 10px 18px; border-radius: 999px;
  transition: filter .15s ease;
}
.nw-iv-x:hover { filter: brightness(1.06); }

@media (max-width: 540px) {
  .nw-iv { padding: 12px; }
  .nw-iv-cap { font-size: 16px; }
}

/* ===================== คลิป Reels (วิดีโอสั้นแนวตั้ง เลื่อนดูได้) ===================== */
body.reels-page .content-body { padding: 0; min-height: 0; display: flex; }
.reels-feed {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: #000;
}
.reels-feed::-webkit-scrollbar { display: none; }
.reel {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex; align-items: center; justify-content: center;
  background: #000; overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
/* ป้าย 2x ตอนกดค้างเร่งความเร็ว */
.reel-speed {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: 5px;
  background: rgba(0, 0, 0, .62); color: #fff; padding: 6px 14px; border-radius: 999px;
  font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .15s ease;
}
.reel-speed svg { width: 15px; height: 15px; }
.reel-speed.show { opacity: 1; }
.reel-video {
  width: auto; height: 100%;
  max-width: 100%; max-height: 100%;
  object-fit: contain; background: #000;
  cursor: pointer;
}
/* ไอคอนเล่นกลางจอ ตอนกดหยุด */
.reel-play {
  position: absolute; inset: 0; margin: auto;
  width: 78px; height: 78px; border-radius: 50%;
  background: rgba(0, 0, 0, .45); color: #fff;
  display: grid; place-items: center;
  pointer-events: none; opacity: 0; transition: opacity .2s;
}
.reel-play svg { width: 38px; height: 38px; margin-left: 4px; }
.reel.paused .reel-play { opacity: 1; }
/* กล่องควบคุมเสียง (มุมขวาบน) — มือถือเห็นแค่ปุ่มเปิด/ปิด, PC มีแถบปรับระดับเสียงด้วย */
.reel-audio {
  position: absolute; top: 16px; right: 16px; z-index: 3;
  display: flex; align-items: center; gap: 10px;
}
.reel-mute {
  width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto;
  border: none; background: rgba(0, 0, 0, .5); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.reel-mute svg { width: 22px; height: 22px; }
.reel-mute:hover { background: rgba(0, 0, 0, .7); }
/* แถบปรับระดับเสียง — ซ่อนบนจอสัมผัส (มือถือ), แสดงเฉพาะเครื่องที่มีเมาส์ (PC) */
.reel-vol {
  display: none;
  width: 96px; height: 6px; -webkit-appearance: none; appearance: none;
  background: rgba(255, 255, 255, .45); border-radius: 3px; cursor: pointer;
}
.reel-vol::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; cursor: pointer; }
.reel-vol::-moz-range-thumb { width: 14px; height: 14px; border: none; border-radius: 50%; background: #fff; cursor: pointer; }
@media (hover: hover) and (pointer: fine) {
  .reel-vol { display: block; }
}
/* แคปชั่นด้านล่าง */
.reel-info {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 44px 84px 22px 18px; /* เว้นขวาให้พ้นแถบปุ่มหัวใจ/คอมเมนต์ */
  background: linear-gradient(to top, rgba(0, 0, 0, .78), rgba(0, 0, 0, 0));
  color: #fff; pointer-events: none;
}
.reel-cap {
  font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 16px; line-height: 1.45;
  max-width: 620px; margin: 0 auto;
}
.reel-cap .inline-link { color: #9ec5ff; pointer-events: auto; }

/* แถบปุ่มด้านขวา (หัวใจ + คอมเมนต์) แบบ TikTok */
.reel-rail {
  position: absolute; right: 10px; bottom: 92px; z-index: 4;
  display: flex; flex-direction: column; align-items: center; gap: 22px;
}
.reel-act {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: none; background: none; color: #fff; cursor: pointer; padding: 0; font: inherit;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, .55));
  transition: transform .1s ease;
}
.reel-act svg { width: 34px; height: 34px; }
.reel-act .reel-act-n { font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 13px; color: #fff; }
.reel-act:active { transform: scale(.88); }
.reel-act.busy { opacity: .6; pointer-events: none; }
.reel-like.liked svg { fill: var(--danger); stroke: var(--danger); }
.reel-like.pop { animation: likePop .32s ease; }

/* กล่องคอมเมนต์คลิป Reels (bottom sheet) — ใช้ธีมเว็บ (สว่าง/มืด) */
body.reel-sheet-lock { overflow: hidden; }
.reel-sheet {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.reel-sheet.show { opacity: 1; pointer-events: auto; }
.reel-sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); }
.reel-sheet-panel {
  position: relative; z-index: 1;
  width: 100%; max-width: 560px; height: 68vh; max-height: 100%; /* คุมไม่ให้สูงเกินพื้นที่ที่เห็น (เหนือคีย์บอร์ด) */
  background: var(--surface); color: var(--ink);
  border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(100%); transition: transform .28s cubic-bezier(.22, .61, .36, 1);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .32);
}
.reel-sheet.show .reel-sheet-panel { transform: none; }
.reel-sheet-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.reel-sheet-title { font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 15px; }
.reel-sheet-x { border: none; background: none; color: var(--muted); cursor: pointer; padding: 4px; display: grid; place-items: center; border-radius: 8px; }
.reel-sheet-x svg { width: 22px; height: 22px; }
.reel-sheet-x:hover { background: var(--hover); color: var(--ink); }
.reel-sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 4px 16px 10px; }
.reel-sheet-body .comment-list { margin-top: 10px; }
.reel-sheet-body .comment-empty { padding: 30px 0; text-align: center; color: var(--muted); }
.reel-sheet-compose { flex: none; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }

/* ===================== สมาชิก: แจ้งเตือน + กล่องข้อความ ===================== */
.acc-section { margin-top: 18px; text-align: left; }
.acc-head { display: flex; align-items: center; gap: 8px; font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 15px; margin-bottom: 10px; }
.acc-head svg { width: 20px; height: 20px; }
.acc-more { border-top: 1px solid var(--line); padding-top: 8px; }
.acc-more > summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 8px 0; list-style: none; }
.acc-more > summary::-webkit-details-marker { display: none; }
.acc-more[open] > summary { color: var(--ink); }

/* แท็บหมวดหมู่หน้าบัญชี (แจ้งเตือน / ข้อความ / ตั้งค่า) */
.acc-tabs { display: flex; gap: 2px; margin: 20px 0 16px; border-bottom: 1px solid var(--line); }
.acc-tab { flex: 1; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 13.5px; padding: 10px 6px; border: none; background: none; color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1px; border-radius: 8px 8px 0 0; }
.acc-tab svg { width: 18px; height: 18px; flex: none; }
.acc-tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-tab:hover { color: var(--ink); background: var(--hover); }
.acc-tab.is-active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.acc-tab .tab-badge { flex: none; min-width: 16px; height: 16px; font-size: 10px; }
.acc-tabpanel { display: none; text-align: left; }
.acc-tabpanel.is-active { display: block; }
.acc-sublabel { font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 16px 0 8px; }
@media (max-width: 400px) { .acc-tab span { font-size: 12.5px; } }

/* สวิตช์เปิด/ปิด */
.notify-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.notify-txt { display: flex; align-items: center; gap: 10px; min-width: 0; }
.notify-ic { display: inline-flex; color: var(--brand); }
.notify-ic svg { width: 22px; height: 22px; }
.notify-txt b { display: block; font-size: 14px; }
.notify-txt small { display: block; color: var(--muted); font-size: 12px; line-height: 1.4; margin-top: 2px; }
.switch { flex: none; width: 48px; height: 28px; border-radius: 999px; border: none; background: var(--muted-2); position: relative; cursor: pointer; transition: background .18s; padding: 0; }
.switch.on { background: var(--brand); }
.switch.busy { opacity: .6; pointer-events: none; }
.switch-dot { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch.on .switch-dot { transform: translateX(20px); }

/* กล่องแชท (ฝั่งสมาชิก) */
.chat-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.chat-loading, .chat-empty { color: var(--muted); font-size: 13px; text-align: center; margin: auto; }
.bubble { max-width: 82%; padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.5; word-break: break-word; }
.bubble-text { white-space: pre-wrap; }
.bubble-time { font-size: 10.5px; opacity: .7; margin-top: 3px; }
.bubble.from-me, .bubble.from-member { align-self: flex-end; background: var(--brand); color: var(--on-brand); border-bottom-right-radius: 4px; }
.bubble.from-admin { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 4px; }
.bubble .inline-link { color: inherit; text-decoration: underline; }
.chat-compose { display: flex; gap: 8px; margin-top: 10px; }
.chat-compose input { flex: 1; min-width: 0; padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 14px; font-family: inherit; }
.chat-compose input:focus { outline: none; border-color: var(--brand); }
.chat-compose .btn { flex: none; padding: 0 16px; border-radius: 999px; }
.chat-compose .btn svg { width: 18px; height: 18px; }
.chat-compose .btn.busy { opacity: .55; pointer-events: none; }
/* ปุ่มแนบรูปในช่องพิมพ์ */
.chat-attach { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); cursor: pointer; }
.chat-attach:hover { color: var(--brand); border-color: var(--brand); }
.chat-attach svg { width: 20px; height: 20px; }
.chat-attach.has-file { color: var(--brand); border-color: var(--brand); background: var(--hover); }
/* พรีวิวรูปที่เลือกก่อนส่ง (ฝั่งสมาชิก) */
.chat-preview { margin-top: 8px; }
.chat-prev { position: relative; display: inline-block; }
.chat-prev img { max-width: 120px; max-height: 120px; border-radius: 10px; border: 1px solid var(--line); display: block; }
.chat-prev-x { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; border: none; background: var(--danger); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
/* รูปในบับเบิลข้อความ */
.bubble-img { display: block; margin-bottom: 4px; }
.bubble-img img { max-width: 220px; max-height: 300px; width: 100%; border-radius: 12px; display: block; }

/* กล่องแจ้งเตือน (รายการ กดไปที่เนื้อหาได้) */
.notif-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; }
.notif-item { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; transition: background .15s; }
.notif-item:last-child { border-bottom: none; }
a.notif-item:hover { background: var(--hover); }
.notif-item.unread { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.notif-item.unread .notif-text::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); margin-right: 7px; vertical-align: middle; }
.notif-text { font-size: 14px; line-height: 1.5; word-break: break-word; }
.notif-time { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* จุด/ตัวเลขแจ้งเตือน */
.auth-ava { position: relative; }
.auth-dot { position: absolute; top: -2px; right: -2px; width: 11px; height: 11px; border-radius: 50%; background: var(--danger); border: 2px solid var(--shell); }
.msg-badge, .tab-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; font-family: 'Kanit', sans-serif; }
/* [hidden] ต้องซ่อนจริง — display ของคลาสข้างบนจะทับ [hidden] ของ UA ไม่งั้นป้ายจะโชว์ "0" ตลอด */
.msg-badge[hidden], .tab-badge[hidden] { display: none; }

/* แท็บข้อความ (ฝั่งแอดมิน) */
.conv-row { text-decoration: none; color: inherit; cursor: pointer; align-items: center; }
.conv-ava { display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.conv-ava img { width: 100%; height: 100%; object-fit: cover; }
.conv-ava svg { width: 22px; height: 22px; }
.conv-time { color: var(--muted); font-size: 12px; flex: none; }
.thread-head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.thread-head .conv-ava { width: 44px; height: 44px; }
.thread-box { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; padding: 4px 2px 12px; }

/* ป้าย "ใหม่" บนโพสต์ที่ยังไม่ได้ดู (หายเมื่อเลื่อนเห็น) */
.post { position: relative; }
.post-new {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  background: var(--danger); color: #fff; font-family: 'Kanit', sans-serif; font-weight: 700;
  font-size: 11px; line-height: 1; padding: 4px 9px; border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18); letter-spacing: .3px;
  animation: nwNewPop .25s ease; transition: opacity .3s;
}
@keyframes nwNewPop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* แถวเดียว: หัวใจ · ยอดวิว · แชร์ (หน้าเล่นวิดีโอ) */
.watch-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.watch-bar .stat { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.watch-bar .stat svg { width: 18px; height: 18px; }
.watch-bar .stat b { color: var(--ink); font-family: 'Kanit', sans-serif; font-weight: 600; }
/* หัวใจ + แชร์ = ปุ่มทรงกลมโครงเส้นชุดเดียวกัน (แชร์เน้นสีแบรนด์, หัวใจเน้นสีแดง) */
.stat-like, .stat-share {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font: inherit; transition: transform .12s, background .15s, color .15s, border-color .15s;
}
.stat-like:hover { border-color: var(--danger); color: var(--danger); }
.stat-like.liked { background: var(--danger); border-color: var(--danger); color: #fff; }
.stat-like.liked svg { fill: #fff; stroke: #fff; }
.stat-like.liked b { color: #fff; }
.stat-like.busy { opacity: .6; pointer-events: none; }
.stat-like.pop { animation: likePop .32s ease; }
.stat-share:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.stat-share:active { transform: scale(.96); }

/* กล่องยืนยันสวย ๆ เข้าธีม (แทน confirm ของเบราว์เซอร์) */
.nw-modal {
  position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(10, 12, 20, .58); opacity: 0; transition: opacity .18s ease;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.nw-modal.show { opacity: 1; }
.nw-modal-card {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 20px;
  padding: 28px 24px 20px; max-width: 350px; width: 100%; text-align: center; box-shadow: var(--shadow);
  transform: translateY(8px) scale(.94); transition: transform .2s cubic-bezier(.2,.8,.3,1.1);
}
.nw-modal.show .nw-modal-card { transform: none; }
.nw-modal-ic {
  width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center;
}
.nw-modal-ic svg { width: 30px; height: 30px; }
.nw-modal-title { font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 19px; margin-bottom: 7px; }
.nw-modal-text { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 22px; }
.nw-modal-actions { display: flex; gap: 10px; }
.nw-modal-actions .btn { flex: 1; justify-content: center; }

/* ============================ คอมเมนต์วิดีโอ ============================ */
.comments { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.comments-head { display: flex; align-items: center; gap: 8px; font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 18px; margin: 0 0 16px; }
.comments-head svg { width: 20px; height: 20px; }
.comments-head b { color: var(--muted); font-weight: 600; }

/* การ์ดตัวอย่างคอมเมนต์ (ย่อ) + ปุ่มย่อ — ค่าเริ่มต้น = เดสก์ท็อป: โชว์เต็ม ไม่มีการ์ดย่อ */
.comments-preview { display: none; }
.comments-collapse { display: none; margin-left: auto; align-items: center; gap: 4px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.comments-collapse svg { width: 16px; height: 16px; transform: rotate(180deg); }
.comments-collapse:hover { color: var(--brand); border-color: var(--brand); }

@media (max-width: 768px) {
  .comments-preview {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 13px 16px;
    cursor: pointer; font: inherit; color: var(--ink); text-align: left; transition: border-color .15s;
  }
  .comments-preview:hover { border-color: var(--line-strong); }
  .cp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
  .cp-label { display: flex; align-items: center; gap: 8px; font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 15px; }
  .cp-label svg { width: 18px; height: 18px; }
  .cp-label b { color: var(--muted); font-weight: 600; }
  .cp-top { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cp-caret { flex: none; color: var(--muted); display: inline-flex; }
  .cp-caret svg { width: 22px; height: 22px; }
  .comments-full { display: none; }
  .comments.open .comments-preview { display: none; }
  .comments.open .comments-full { display: block; }
  .comments.open .comments-collapse { display: inline-flex; }
}

.cm-compose { display: flex; gap: 10px; align-items: flex-end; }
.cm-compose textarea, .cm-repinput {
  flex: 1; min-width: 0; resize: none; overflow: hidden; font: inherit; font-size: 14px;
  padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface); color: var(--ink); line-height: 1.5;
}
.cm-compose textarea:focus, .cm-repinput:focus { outline: none; border-color: var(--brand); }
.cm-compose .btn { flex: none; border-radius: 999px; padding: 10px 18px; align-self: flex-end; }
.cm-login { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); text-decoration: none; padding: 12px 16px; border: 1px dashed var(--line-strong); border-radius: 14px; font-size: 14px; }
.cm-login:hover { color: var(--brand); border-color: var(--brand); }
.cm-login svg { width: 20px; height: 20px; }

.comment-list { margin-top: 20px; display: flex; flex-direction: column; gap: 18px; }
.comment-loading, .comment-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 16px 0; }
.cm { display: flex; gap: 12px; align-items: flex-start; }
.cm-ava { flex: none; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: var(--surface-2); color: var(--muted); display: flex; align-items: center; justify-content: center; }
.cm-ava img { width: 100%; height: 100%; object-fit: cover; }
.cm-ava svg { width: 22px; height: 22px; }
.cm-reply .cm-ava { width: 32px; height: 32px; }
.cm-reply .cm-ava svg { width: 18px; height: 18px; }
.cm-main { flex: 1; min-width: 0; }
/* บับเบิลข้อความ (ชื่อ + ข้อความอยู่ในกล่องมน ๆ แบบ Facebook) */
.cm-bubble { position: relative; display: inline-block; max-width: 100%; background: var(--surface-2); border-radius: 16px; padding: 8px 14px 10px; }
.cm-namerow { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.cm-name { font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 13.5px; }
.cm-author { font-size: 10.5px; font-weight: 600; color: var(--brand); background: var(--brand-soft); padding: 1px 8px; border-radius: 999px; }
.cm-text { font-size: 14.5px; line-height: 1.5; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.cm-replyto { color: var(--brand); font-weight: 600; }
/* ป้ายจำนวนไลก์ลอยมุมล่างขวาของบับเบิล */
.cm-likebadge { position: absolute; right: -4px; bottom: -10px; display: inline-flex; align-items: center; gap: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px 2px 5px; box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }
.cm-likebadge svg { width: 12px; height: 12px; fill: var(--danger); stroke: var(--danger); }
.cm-likebadge b { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.cm-likebadge.is-empty { display: none; }
/* แถวปุ่ม: ถูกใจ · ตอบกลับ · เวลา (ใต้บับเบิล) */
.cm-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding-left: 12px; }
.cm-act { border: none; background: none; color: var(--muted); cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 700; padding: 0; }
.cm-act:hover { text-decoration: underline; }
.cm-like.liked { color: var(--danger); }
.cm-del:hover { color: var(--danger); }
.cm-dot { color: var(--muted); font-size: 12px; }
.cm-time { color: var(--muted); font-size: 12px; font-weight: 400; }
.cm-replybox { margin-top: 10px; }
.cm-repbtns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.cm-repbtns .btn { border-radius: 999px; padding: 7px 16px; font-size: 13px; }
.cm-replies { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }

/* แจ้งเตือนระบบในกล่องข้อความ (เช่น มีคนตอบคอมเมนต์) */
.bubble.bubble-sys {
  align-self: center; max-width: 92%; text-align: center; background: var(--brand-soft); color: var(--brand-ink);
  border: 1px solid transparent; border-radius: 12px; text-decoration: none; display: block;
}
a.bubble.bubble-sys:hover { border-color: var(--brand); }

/* toast แจ้งเตือนสั้น ๆ */
.cm-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px); z-index: 4200;
  background: #23252b; color: #fff; padding: 11px 20px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3); opacity: 0; transition: opacity .22s, transform .22s; pointer-events: none; max-width: 88vw;
}
.cm-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* โพสต์: แถบหัวใจ + คอมเมนต์ (Facebook-style) */
.post-actbar { display: flex; gap: 6px; margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.post-act { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 10px; border: none; background: none; border-radius: 10px; color: var(--muted); cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; transition: background .15s, color .15s; }
.post-act svg { width: 19px; height: 19px; flex: none; }
.post-act b { font-weight: 700; }
.post-act:hover { background: var(--hover); }
.post-act:active { transform: scale(.97); }
.post-like-btn.liked { color: var(--danger); }
.post-like-btn.liked svg { fill: var(--danger); }
.post-cmt-btn.open { color: var(--brand); }
.post-act.busy { opacity: .6; pointer-events: none; }
.post-comments { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.post-comments .comment-list { margin-top: 14px; }
@keyframes likePop { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
