/* ============================== 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;
  min-height: 100vh;
  position: relative;
}

/* -------------------------------- sidebar ------------------------------- */
.sidebar {
  border-right: 1px solid var(--line-strong);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.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 {
  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; }

.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; }

.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: 26px; transform: translateX(-50%);
  background: rgba(0,0,0,.85); color: #fff; font-size: 13px; font-weight: 600;
  padding: 3px 9px; border-radius: 7px; pointer-events: none; white-space: nowrap;
  font-family: 'Kanit', sans-serif; font-variant-numeric: tabular-nums;
}
.vp-tip[hidden] { display: none; }

.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; }

@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: 5;
  line-clamp: 5;
  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; }

.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); }

/* -------------------------------- 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 { 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 .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; }
.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; }
}
