:root {
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-card: #1c1f28;
  --border: #2a2e38;
  --text: #e8e9ec;
  --text-dim: #9aa0ab;
  --accent: #4bdd9e;
  --accent-dark: #2f9e6e;
  --new-badge: #ff5c5c;
  --danger: #ff5c5c;
  --img-bg: #0a0c10; /* พื้นหลังระหว่างรอรูปโหลด */
  color-scheme: dark;
}

/* ธีม: ตั้งที่ <html data-theme="dark|light|system"> (สคริปต์ใน <head> ใส่ให้ก่อนหน้าเว็บแสดง จะได้ไม่กระพริบ)
   ชุดสีสว่างต้องเขียน 2 ที่ — เลือกเองกับตามเครื่อง — CSS ยังรวม selector กับ media query เป็นก้อนเดียวไม่ได้ */
:root[data-theme="light"] {
  --bg: #f3f4f7;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --border: #dde0e7;
  --text: #16181d;
  --text-dim: #5f6775;
  --accent: #16a066;
  --accent-dark: #0f7d4f;
  --new-badge: #e5484d;
  --danger: #d93036;
  --img-bg: #e6e8ee;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    --bg: #f3f4f7;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --border: #dde0e7;
    --text: #16181d;
    --text-dim: #5f6775;
    --accent: #16a066;
    --accent-dark: #0f7d4f;
    --new-badge: #e5484d;
    --danger: #d93036;
    --img-bg: #e6e8ee;
    color-scheme: light;
  }
}

/* หน้าอ่านมังงะ: โทนมืดเสมอแม้เลือกธีมสว่าง (อ่านสบายตา) — ใช้สีชุดเดียวกับธีมมืด */
#reader {
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-card: #1c1f28;
  --border: #2a2e38;
  --text: #e8e9ec;
  --text-dim: #9aa0ab;
  --accent: #4bdd9e;
  --accent-dark: #2f9e6e;
  --img-bg: #0a0c10;
  color-scheme: dark;
  color: var(--text);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans Thai", system-ui, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 1.2rem;
  margin: 0;
  margin-right: auto;
}

/* login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-box h1 { font-size: 1.2rem; margin: 0 0 8px; text-align: center; }

.login-box input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.login-box .btn { margin-top: 4px; }

.tabs {
  display: flex;
  gap: 8px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.tab-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.tab-btn.active {
  background: var(--accent);
  color: #0a0f0c;
  border-color: var(--accent);
  font-weight: 600;
}

.btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn.primary {
  background: var(--accent);
  color: #0a0f0c;
  border-color: var(--accent);
  font-weight: 600;
}

.btn.danger { color: var(--danger); border-color: var(--danger); }

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn:disabled:hover { border-color: var(--border); color: var(--text); }
.icon-btn.danger { color: var(--danger); border-color: var(--danger); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); opacity: 0.8; }
.icon-btn[hidden], .tab-btn[hidden] { display: none; }

.tab-btn.icon-btn.active { background: var(--accent); color: #0a0f0c; border-color: var(--accent); }

.icon-btn.spinning svg { animation: spin 0.9s linear infinite; }

/* กระดิ่งแจ้งเตือน: ปิดอยู่ = มีขีดทับ, เปิดอยู่ = สีหลัก ไม่มีขีด */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

main { padding: 20px; max-width: 1200px; margin: 0 auto; }

.view { display: none; }
.view.active { display: block; animation: fade-in 0.16s ease-out; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ปิดอนิเมชันทั้งหมดให้คนที่ตั้งค่าเครื่องว่าไม่อยากเห็นการเคลื่อนไหว */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.sub-tabs { display: flex; gap: 8px; margin-bottom: 16px; }

.sub-tab-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.sub-tab-btn.active {
  background: var(--accent);
  color: #0a0f0c;
  border-color: var(--accent);
  font-weight: 600;
}

.subview { display: none; }
.subview.active { display: block; }

.status-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.manga-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.video-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; text-align: left; color: var(--text); padding: 0; cursor: pointer; }
.video-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.video-thumb { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--img-bg); }
.video-placeholder { display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 9; background: linear-gradient(135deg, #29313d, #15191f); color: var(--accent); font-size: 2rem; }
.video-card-info { display: block; padding: 11px; }
.video-card-title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-card-meta { display: block; margin-top: 5px; color: var(--text-dim); font-size: 0.76rem; }
.video-form { display: flex; flex-direction: column; gap: 10px; }
.video-form input { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 9px 12px; border-radius: 8px; font-size: 0.9rem; }
.video-player-body { flex: 1; display: grid; place-items: center; overflow: auto; padding: 70px 16px 20px; }
.video-player-body { grid-template-columns: minmax(0, 1fr); align-content: center; }
.video-player-body .fb-video, .video-player-body .fb-video > span, .video-player-body iframe { max-width: 100% !important; }

.manga-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  /* ใบที่ยังไม่เลื่อนมาถึง browser ข้ามการ render ไปก่อน (กริดยาว ๆ จะขึ้นเร็วขึ้นมาก) */
  content-visibility: auto;
  contain-intrinsic-size: auto 280px;
}

.manga-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.manga-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--img-bg);
  display: block;
}

.manga-info { padding: 10px; flex: 1; display: flex; flex-direction: column; gap: 4px; }

.manga-name {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.manga-chapter { font-size: 0.8rem; color: var(--text-dim); }

.new-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--new-badge);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.follow-btn {
  margin-top: 4px;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
}

.follow-btn.subscribed {
  background: var(--accent);
  color: #0a0f0c;
  border-color: var(--accent);
  font-weight: 600;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 60px 20px;
}

/* settings */
.add-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 8px;
}

.add-form h2 { width: 100%; margin: 0 0 4px; font-size: 1rem; }

.add-form input {
  flex: 1;
  min-width: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.form-msg { min-height: 1.2em; font-size: 0.85rem; margin-bottom: 16px; }
.form-msg.error { color: var(--danger); }
.form-msg.success { color: var(--accent); }

/* แถวปุ่มในหน้าจัดการเรื่อง: เพิ่มเรื่องใหม่ (ซ้าย) / รีเฟรชทั้งหมด (ขวา) */
.manage-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.btn.with-icon { display: inline-flex; align-items: center; gap: 6px; }
.btn.with-icon svg { width: 16px; height: 16px; flex: none; }
.btn.spinning svg { animation: spin 0.9s linear infinite; }

.settings-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}

.settings-row img { width: 36px; height: 48px; object-fit: cover; border-radius: 4px; background: var(--img-bg); }
.settings-row .name { font-weight: 600; font-size: 0.9rem; }
.settings-row .meta { font-size: 0.75rem; color: var(--text-dim); }
.settings-row .grow { flex: 1; min-width: 0; }
.settings-row .name, .settings-row .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* manga add/edit modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal[hidden] { display: none; }
.modal:not([hidden]) { display: flex; }

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h2 { margin: 0 0 16px; font-size: 1.05rem; }

#mangaForm { display: flex; flex-direction: column; gap: 10px; }

#mangaForm input[type="text"],
#mangaForm input[type="url"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.form-label { font-size: 0.8rem; color: var(--text-dim); margin-top: 4px; }

.source-list { display: flex; flex-direction: column; gap: 8px; }

.source-row { display: flex; gap: 8px; align-items: center; }
.source-row input { flex: 1; min-width: 0; }
.source-row .remove-source-btn { flex: none; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* reader */
.reader {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  flex-direction: column;
}

.reader[hidden] { display: none; }
.reader:not([hidden]) { display: flex; animation: slide-up 0.18s ease-out; }

.reader-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

/* เฉพาะหน้าอ่านมังงะ (ไม่ใช่หน้าเลือกตอน) ให้ลอยทับเนื้อหาและซ่อนได้ตอนเลื่อนอ่าน */
#readerTopbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  transition: transform 0.25s ease;
  transform: translateY(0);
}

#readerTopbar.nav-hidden { transform: translateY(-100%); }

.reader-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reader-title span:first-child { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* แถบล่างของหน้าอ่าน: เลขตอนปัจจุบัน (ซ้าย) + ปุ่มตอนก่อนหน้า/ถัดไป (ขวา) */
#readerBottombar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  transition: transform 0.25s ease;
  transform: translateY(0);
}

#readerBottombar.nav-hidden { transform: translateY(100%); }

.reader-chapter { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.reader-nav { display: flex; gap: 8px; flex-shrink: 0; }

.reader-body {
  flex: 1;
  overflow-y: auto;
  /* เลื่อนสุดขอบแล้วไม่ให้ไปลากหน้าเว็บด้านหลังต่อ (มือถือจะรู้สึกลื่นกว่า ไม่มีจังหวะสะดุด) */
  overscroll-behavior: contain;
  /* ปิด scroll anchoring: ตอนเปลี่ยนตอน รูปชุดใหม่เริ่มจากความสูง 0 แล้วค่อยโตขึ้นตอนโหลดเสร็จ
     เบราว์เซอร์จะพยายาม "ตรึงเนื้อหาเดิมไว้ที่เดิม" ด้วยการเลื่อน scroll ตามความสูงที่เพิ่ม
     ทำให้หน้าใหม่ไม่ได้เริ่มที่บนสุดอย่างที่ควรเป็น */
  overflow-anchor: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #000;
}

.reader-body img {
  max-width: 100%;
  width: min(800px, 100%);
  display: block;
}

.reader-msg { color: var(--text-dim); padding: 40px; text-align: center; }

.next-hint {
  width: 100%;
  max-width: 800px;
  box-sizing: border-box;
  text-align: center;
  padding: 30px 16px;
  color: var(--text-dim);
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.25s ease, color 0.25s ease;
}

.next-hint.show { opacity: 1; color: var(--accent); font-weight: 600; }

/* chapter list */
#chapterListView { background: var(--bg); }

.chapter-search-bar {
  padding: 10px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.chapter-search-bar input {
  display: block;
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.chapter-search-bar input:focus { outline: none; border-color: var(--accent); }

.catalog-sort-row {
  max-width: 700px;
  margin: 8px auto 0;
  display: flex;
  justify-content: flex-end;
}

.catalog-sort-row select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.catalog-sort-row select:focus { outline: none; border-color: var(--accent); }

.chapter-list-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}


@media (max-width: 640px) {
  .topbar { gap: 8px; }
  main { padding: 12px; }
  /* มือถือ: แถวละ 3 เรื่องเสมอ (การ์ดแคบลง เลยย่อตัวหนังสือ/ระยะในการ์ดตาม) */
  .manga-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .manga-card { contain-intrinsic-size: auto 220px; }
  .manga-info { padding: 7px; gap: 2px; }
  .manga-name { font-size: 0.78rem; }
  .manga-chapter { font-size: 0.7rem; }
  .new-badge { top: 5px; right: 5px; font-size: 0.55rem; padding: 2px 6px; }
  .follow-btn { padding: 5px 4px; font-size: 0.68rem; }
}


/* ================= โครงแบบแอป: แถบบน + เมนูล่าง ================= */
:root { --nav-h: 60px; }
body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

.topbar { display: block; padding: 0; padding-top: env(safe-area-inset-top); }
.topbar-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 16px; }
.topbar-row .topbar-title { margin: 0 auto 0 0; font-size: 1.2rem; }
.topbar-title[hidden] { display: none !important; }
/* กระดิ่งแจ้งเตือนอยู่เฉพาะหน้าหลัก */
body:not([data-tab="list"]) #pushBtn, body:not([data-tab="list"]) #installBtn { display: none; }

/* "เรื่องทั้งหมด | หมวดหมู่" แบบตัวหนังสือใหญ่ ตัวที่ไม่ได้เลือกเป็นสีจาง */
.seg-tabs { display: flex; align-items: center; gap: 14px; }
.seg-btn { background: none; border: 0; padding: 4px 0; font: inherit; font-size: 1.2rem; font-weight: 700; color: var(--text-dim); opacity: 0.55; cursor: pointer; }
.seg-btn.active { color: var(--text); opacity: 1; }
.seg-sep { width: 1px; height: 18px; background: var(--border); }

/* แถบหมวดหมู่เลื่อนแนวนอน + ปุ่มกางทั้งหมด */
.category-bar { display: flex; align-items: stretch; border-top: 1px solid var(--border); }
.category-bar[hidden] { display: none; }
.category-chips { flex: 1; display: flex; gap: 22px; overflow-x: auto; padding: 0 16px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.category-chips::-webkit-scrollbar { display: none; }
.category-chips .chip { position: relative; flex: none; background: none; border: 0; padding: 12px 0; font: inherit; font-size: 0.95rem; color: var(--text-dim); cursor: pointer; white-space: nowrap; }
.category-chips .chip.active { color: var(--text); font-weight: 700; }
.category-chips .chip.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 2px; background: var(--accent); }
.chip-empty { padding: 12px 0; color: var(--text-dim); font-size: 0.85rem; white-space: nowrap; }
.category-expand { flex: none; width: 48px; background: none; border: 0; border-left: 1px solid var(--border); color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.category-expand svg { transition: transform 0.2s; }
.category-expand.open svg { transform: rotate(180deg); }
.category-expand[hidden] { display: none; }
.category-panel { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--border); max-height: 50vh; overflow-y: auto; }
.category-panel[hidden] { display: none; }
.category-panel .chip { background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 0.85rem; color: var(--text); cursor: pointer; }
.category-panel .chip.active { background: var(--accent); border-color: var(--accent); color: #0a0f0c; font-weight: 600; }

.catalog-sort-row { max-width: none; margin: 0 0 12px; }

/* เมนูล่าง */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-elevated); border-top: 1px solid var(--border);
}
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: none; border: 0; color: var(--text-dim); font: inherit; font-size: 0.72rem; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.nav-item svg { width: 24px; height: 24px; }
.nav-item.active { color: var(--accent); font-weight: 600; }
.nav-item.active svg path, .nav-item.active svg rect { fill: currentColor; fill-opacity: 0.18; }

/* ค้นหา */
.search-box { display: flex; align-items: center; gap: 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 0 14px; margin-bottom: 20px; color: var(--text-dim); }
.search-box:focus-within { border-color: var(--accent); }
.search-box svg { flex: none; width: 20px; height: 20px; }
.search-box input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); font: inherit; font-size: 0.95rem; padding: 13px 0; }
.section-title { font-size: 1.05rem; margin: 4px 0 12px; }
.cover-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 20px; scrollbar-width: none; scroll-snap-type: x proximity; }
.cover-row::-webkit-scrollbar { display: none; }
.cover-tile { flex: none; width: 118px; cursor: pointer; scroll-snap-align: start; }
.cover-tile img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; background: var(--img-bg); display: block; }
.cover-tile-name { font-size: 0.8rem; margin-top: 6px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-count { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 12px; }

/* ตั้งค่า */
.account-card { display: flex; align-items: center; gap: 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 20px; }
.account-avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--bg); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-dim); }
.account-name { font-weight: 700; }
.account-role { font-size: 0.8rem; color: var(--text-dim); }
.hint { font-size: 0.8rem; color: var(--text-dim); margin: 0 0 12px; }
.btn.small { padding: 6px 10px; font-size: 0.78rem; white-space: nowrap; }
.empty-state.small { padding: 20px; }

/* จัดการหมวดหมู่ */
.category-item { list-style: none; }
.category-item.open > .settings-row { border-color: var(--accent); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.category-item .settings-row { gap: 6px; }
.category-members { background: var(--bg); border: 1px solid var(--accent); border-top: 0; border-radius: 0 0 8px 8px; padding: 8px 12px 12px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; font-size: 0.88rem; }
.member-row input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.member-row img { width: 28px; height: 38px; object-fit: cover; border-radius: 3px; background: var(--img-bg); flex: none; }

/* หมวดหมู่ในหน้าแก้ไขเรื่อง */
.chip-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span { display: inline-block; border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font-size: 0.85rem; cursor: pointer; color: var(--text-dim); }
.chip-check input:checked + span { background: var(--accent); border-color: var(--accent); color: #0a0f0c; font-weight: 600; }
.chip-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 640px) {
  .topbar-row { padding: 0 12px; }
  .category-item .settings-row { flex-wrap: wrap; }
  .category-item .settings-row .grow { flex-basis: 100%; }
}
.account-card .grow { flex: 1; min-width: 0; }
a.btn { text-decoration: none; display: inline-block; }

/* หมวดพิเศษ */
.badge-special { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; background: rgba(255, 92, 92, 0.15); color: var(--danger); vertical-align: middle; }
.category-edit { flex-wrap: wrap; }
.category-edit input[type="text"] { flex: 1 1 180px; min-width: 0; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 8px; font-size: 0.9rem; }
.category-edit-actions { display: flex; gap: 6px; margin-left: auto; }
.pref-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 4px 16px; margin-bottom: 20px; }
.pref-card[hidden] { display: none; }
.pref-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; cursor: pointer; }
.pref-title { font-weight: 600; }
.pref-desc { font-size: 0.8rem; color: var(--text-dim); margin-top: 2px; }
/* สวิตช์เปิด/ปิด */
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 46px; height: 28px; border-radius: 999px; background: var(--border); position: relative; cursor: pointer; transition: background 0.2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.add-form .checkbox-label input, .category-edit .checkbox-label input { flex: none; min-width: 0; width: 18px; height: 18px; accent-color: var(--accent); }
.add-form .checkbox-label { white-space: nowrap; }
/* ปุ่มติดตามชิดล่างการ์ดเสมอ ให้ทุกการ์ดในแถวปุ่มอยู่ระดับเดียวกัน แม้ชื่อเรื่องยาวไม่เท่ากัน */
.manga-info .follow-btn { margin-top: auto; }

/* เมนูเลือกธีม (ป๊อปอัปแบบเมนูของ iOS) */
.pref-card .pref-row + .pref-row { border-top: 1px solid var(--border); }
.menu-anchor { position: relative; flex: none; }
.menu-btn { white-space: nowrap; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 250px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35); animation: fade-in 0.12s ease-out;
}
.menu[hidden] { display: none; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 0; border-radius: 9px;
  background: none; color: var(--text); font: inherit; font-size: 0.95rem; text-align: left; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--bg-card); outline: none; }
.menu-check { width: 16px; color: var(--accent); font-weight: 700; }
.pref-row .grow { flex: 1; min-width: 0; }

/* กันหน้าเว็บซูมเข้าเองตอนแตะช่องพิมพ์บน iPhone: Safari ซูมอัตโนมัติเมื่อตัวหนังสือในช่องเล็กกว่า 16px
   แก้ที่ขนาดตัวหนังสือแทนการปิดซูมทั้งหน้า (user-scalable=no) ผู้ใช้จะยังถ่างนิ้วซูมดูรูปมังงะได้ตามปกติ */
@media (pointer: coarse), (max-width: 640px) {
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea { font-size: 16px !important; }
}

/* หน้าหลัก: แถบ "หน้าหลัก | รายการอ่านล่าสุด" (แสดงเฉพาะแท็บหน้าหลัก) */
.home-tabs { display: flex; gap: 26px; padding: 0 16px; border-top: 1px solid var(--border); }
body:not([data-tab="list"]) .home-tabs { display: none; }
.home-tab { position: relative; background: none; border: 0; padding: 12px 0; font: inherit; font-size: 0.95rem; color: var(--text-dim); cursor: pointer; }
.home-tab.active { color: var(--text); font-weight: 700; }
.home-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 2px; background: var(--text); }
.manga-grid[hidden] { display: none; }

/* รายการอ่านล่าสุด (แบบ webtoon) */
.history-stats { display: flex; align-items: center; gap: 16px; padding: 2px 2px 12px; font-size: 0.9rem; }
.history-count { font-weight: 600; }
.history-unread { color: var(--text-dim); }
.history-list { list-style: none; margin: 0 -20px; padding: 0; border-top: 1px solid var(--border); }
.history-row { background: var(--bg-elevated); display: flex; align-items: center; gap: 14px; padding: 0 16px 0 0; border-bottom: 1px solid var(--border); cursor: pointer; content-visibility: auto; contain-intrinsic-size: auto 104px; }
.history-cover { width: 84px; height: 104px; object-fit: cover; flex: none; background: var(--img-bg); display: block; }
.history-info { flex: 1; min-width: 0; padding: 10px 0; }
.history-name { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.98rem; line-height: 1.3; min-width: 0; }
.history-name > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-up { flex: none; background: var(--new-badge); color: #fff; font-size: 0.62rem; font-weight: 700; padding: 2px 6px; border-radius: 999px; }
.history-chapter { font-size: 0.82rem; color: var(--text-dim); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-time { font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }
.resume-btn { flex: none; padding: 9px 12px; font-size: 0.82rem; line-height: 1.25; }
@media (max-width: 640px) {
  .history-list { margin: 0 -12px; }
}

/* หน้า login / สมัครสมาชิก */
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.auth-tab { flex: 1; text-align: center; padding: 10px 0; color: var(--text-dim); text-decoration: none; font-size: 0.95rem; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.auth-tab.active { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.login-box .form-msg { margin-bottom: 0; }

/* เปลี่ยนรหัสผ่าน / แจ้งเตือนรหัสถูกรีเซ็ต */
.notice-card { display: block; width: 100%; text-align: left; font: inherit; font-size: 0.88rem; background: rgba(255, 176, 32, 0.14); color: var(--text); border: 1px solid rgba(255, 176, 32, 0.5); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.notice-card[hidden] { display: none; }
.notice-btn { cursor: pointer; }
.collapsible > summary { list-style: none; cursor: pointer; }
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible .chev { color: var(--text-dim); font-size: 1.3rem; transition: transform 0.2s; }
.collapsible[open] .chev { transform: rotate(90deg); }
.password-form { display: flex; flex-direction: column; gap: 10px; padding: 0 0 16px; }
.password-form input { background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: 8px; font-size: 0.9rem; }
.password-form input:focus { outline: none; border-color: var(--accent); }
.password-form .form-msg { margin: 0; min-height: 0; }
.password-form .btn { align-self: flex-start; }

/* การ์ดวิดีโอ: ป้าย "ดูต่อ" มุมขวาบน + แถบหลอดความคืบหน้าใต้ภาพ */
.video-media { position: relative; display: block; }
.video-resume-badge { position: absolute; top: 8px; right: 8px; background: var(--accent); color: #0a0f0c; font-size: 0.7rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
.video-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, 0.28); }
.video-progress > span { display: block; height: 100%; background: var(--new-badge); }
.video-resume-hint { margin-top: 10px; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.12); color: #fff; font-size: 13px; justify-self: center; }
.video-time { position: absolute; right: 8px; bottom: 10px; background: rgba(0, 0, 0, 0.72); color: #fff; font-size: 0.72rem; font-weight: 600; padding: 2px 7px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.video-external-badge { background: #1877f2; color: #fff; }
a.video-card { display: block; text-decoration: none; }
.video-card-delete { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, 0.72); color: #ff8a8a; font-size: 0.72rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.video-item { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.video-save-btn { align-self: stretch; justify-content: center; font-size: 0.85rem; padding: 7px 10px; }
.video-save-btn.saved { color: var(--accent); border-color: var(--accent); }
.native-video { width: 100%; max-width: 900px; max-height: calc(100vh - 170px); background: #000; justify-self: center; border-radius: 6px; }
.video-quality { display: flex; gap: 6px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.video-quality-btn { background: rgba(255, 255, 255, 0.12); color: #fff; border: 1px solid transparent; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 0.8rem; cursor: pointer; }
.video-quality-btn.active { border-color: var(--accent); color: var(--accent); }
/* มือถือ: การ์ดคลิปแถวละ 2 — ย่อตัวอักษร/ป้ายให้พอดีการ์ดแคบ (~165px) */
@media (max-width: 640px) {
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .video-card-info { padding: 8px; }
  .video-card-title { font-size: 0.82rem; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .video-card-meta { font-size: 0.68rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .video-resume-badge { top: 6px; right: 6px; font-size: 0.62rem; padding: 2px 7px; }
  .video-card-delete { top: 6px; left: 6px; font-size: 0.62rem; padding: 2px 7px; }
  .video-time { right: 6px; bottom: 8px; font-size: 0.62rem; padding: 1px 5px; }
  .video-placeholder { font-size: 1.5rem; }
  .video-item { gap: 6px; }
  .video-save-btn { font-size: 0.76rem; padding: 5px 8px; }
}

/* ---------- ตัวเล่น: แตะสองครั้งข้าม / ความเร็ว / ตั้งเวลาปิด ---------- */
.native-wrap { position: relative; width: 100%; max-width: 900px; justify-self: center; }
.native-wrap .native-video { display: block; }
.tap-zone { position: absolute; top: 0; bottom: 56px; width: 32%; -webkit-tap-highlight-color: transparent; }
.tap-zone.left { left: 0; }
.tap-zone.right { right: 0; }
.seek-bubble { position: absolute; top: 40%; padding: 6px 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.65); color: #fff; font-size: 0.85rem; font-weight: 700; pointer-events: none; }
.seek-bubble.left { left: 12%; }
.seek-bubble.right { right: 12%; }
.seek-bubble[hidden] { display: none; }

/* ---------- คอมเมนต์ ---------- */
.comment-btn { position: relative; font-size: 1.05rem; }
.comment-count { position: absolute; top: -6px; right: -6px; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #0a0f0c; font-size: 0.65rem; font-weight: 700; line-height: 18px; }
.comment-count:empty { display: none; }
.comment-sheet { position: fixed; inset: 0; z-index: 300; }
.comment-sheet[hidden] { display: none; }
.comment-sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.comment-sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 75vh; display: flex; flex-direction: column; background: var(--bg-elevated); border-radius: 16px 16px 0 0; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); animation: slide-up 0.18s ease-out; }
.comment-sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.comment-sheet-title { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comment-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 80px; }
.comment-item { padding: 9px 2px; border-bottom: 1px solid var(--border); }
.comment-meta { font-size: 0.75rem; color: var(--text-dim); }
.comment-label { font-size: 0.75rem; color: var(--accent); margin-top: 2px; }
.comment-text { margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.comment-empty { padding: 18px 0; color: var(--text-dim); text-align: center; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.comment-form textarea { flex: 1; resize: none; font: inherit; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); }
.link-btn { background: none; border: 0; padding: 0; color: var(--text-dim); text-decoration: underline; font: inherit; font-size: inherit; cursor: pointer; }
.danger-text { color: #ff8a8a; }

/* ---------- หมวดคลิป ---------- */
.video-chip { flex: 0 0 auto; background: var(--bg-card); color: var(--text-dim); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 0.8rem; cursor: pointer; }
.video-chip.active { color: var(--accent); border-color: var(--accent); }

/* ---------- หน้าแอดมิน: คลิป / ระบบ ---------- */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: 0.85rem; }
.video-manage-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); list-style: none; }
.video-manage-row img, .video-manage-row .video-placeholder { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; font-size: 1rem; }
.video-title-input { width: 100%; font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); }
.video-manage-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; color: var(--text-dim); }
.video-manage-meta select { font: inherit; font-size: 0.85rem; padding: 4px 6px; border-radius: 8px; background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 8px; }
.stat-tile { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.stat-value { font-size: 1.15rem; font-weight: 700; }
.stat-label { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }
.daily-bars { grid-column: 1 / -1; display: flex; gap: 6px; align-items: flex-end; height: 70px; padding: 6px 4px 0; }
.daily-bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; }
.daily-bar span { width: 100%; min-height: 2px; background: var(--accent); border-radius: 4px 4px 0 0; }
.daily-bar em { font-style: normal; font-size: 0.65rem; color: var(--text-dim); }
.host-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); list-style: none; }
.host-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.host-dot.ok { background: #3ecf8e; }
.host-dot.stalled { background: #f5a524; }
.host-dot.down { background: #f31260; }
.top-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.top-list ol { margin: 6px 0 0; padding-left: 20px; }
.log-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 0.7rem; max-height: 240px; overflow: auto; white-space: pre-wrap; word-break: break-all; }

/* ---------- ทำงานแบบแอป ---------- */
.offline-banner { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px); z-index: 60; background: #f5a524; color: #1a1300; border-radius: 10px; padding: 8px 12px; font-size: 0.85rem; font-weight: 600; text-align: center; }
.offline-banner[hidden] { display: none; }
html { -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior-y: none; }
button, .nav-item, .home-tab { -webkit-user-select: none; user-select: none; touch-action: manipulation; }
/* แท็บย่อยแอดมินมี 6 อัน: เลื่อนแนวนอนแทนการบีบจนตัวหนังสือหัก */
.sub-tabs { overflow-x: auto; scrollbar-width: none; }
.sub-tabs::-webkit-scrollbar, .vcat-recent::-webkit-scrollbar, .mm-genres::-webkit-scrollbar { display: none; }
.sub-tab-btn { flex: 0 0 auto; white-space: nowrap; }
.vcat-recent, .mm-genres { scrollbar-width: none; }
.host-row .grow, .video-manage-row .grow { flex: 1; min-width: 0; }

/* ---------- แผงการแจ้งเตือน (กดกระดิ่ง) ---------- */
#pushBtn { position: relative; }
.notif-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; padding: 0 5px; border-radius: 999px; background: #f31260; color: #fff; font-size: 0.65rem; font-weight: 700; line-height: 18px; }
.notif-badge[hidden] { display: none; }
.notif-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, 0.35); }
.notif-backdrop[hidden], .notif-panel[hidden] { display: none; }
.notif-panel { position: fixed; z-index: 80; top: calc(env(safe-area-inset-top) + 60px); right: 8px; left: 8px; max-width: 420px; margin-left: auto; max-height: calc(100vh - env(safe-area-inset-top) - 150px); display: flex; flex-direction: column; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4); animation: slide-up 0.15s ease-out; }
.notif-head { display: flex; align-items: center; justify-content: space-between; }
.notif-head h2 { margin: 0; font-size: 1.3rem; }
.notif-tabs { display: flex; gap: 8px; margin: 10px 0; }
.notif-tab { background: none; border: 0; border-radius: 999px; padding: 6px 14px; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.notif-tab.active { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.push-card { display: flex; gap: 10px; align-items: center; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.push-card.on { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.push-card-title { font-weight: 700; }
.push-card-desc { font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }
.push-card .btn { flex: 0 0 auto; }
.push-card .grow { flex: 1; min-width: 0; }
.notif-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.notif-item { display: flex; gap: 10px; align-items: center; padding: 10px 6px; border-radius: 10px; cursor: pointer; }
.notif-item:hover { background: var(--bg-card); }
.notif-item .grow { flex: 1; min-width: 0; }
.notif-icon { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--bg-card); font-size: 1.1rem; }
.notif-text { display: block; font-size: 0.88rem; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.notif-item.unread .notif-text { font-weight: 600; }
.notif-time { display: block; font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; }
.notif-item.unread .notif-time { color: var(--accent); }
.notif-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.notif-empty { padding: 24px 0; text-align: center; color: var(--text-dim); }

/* ปัดขอบซ้ายย้อนกลับ: ลูกศรตามนิ้ว ถึงระยะแล้วเปลี่ยนสี */
.edge-back { position: fixed; left: -22px; z-index: 400; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); font-size: 1.6rem; line-height: 1; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); opacity: 0; pointer-events: none; transform: translate(0, -50%); transition: opacity 0.12s, background 0.12s; }
.edge-back.show { opacity: 1; }
.edge-back.ready { background: var(--accent); color: #0a0f0c; border-color: var(--accent); }

/* Playlist (เรื่องยาวหลายตอน) */
.playlist-card .video-card-info { padding: 8px 10px; }
.playlist-card .video-card-meta { margin-top: 3px; }
#videoSentinel { height: 1px; }
.playlist-view { background: var(--bg); }
.playlist-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.playlist-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.playlist-head p { margin: 0; color: var(--text-dim); }
.episode-list { display: flex; flex-direction: column; gap: 8px; }
.episode-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; color: var(--text); text-align: left; cursor: pointer; }
.episode-row.current { border-color: var(--accent); }
.episode-row.watched { opacity: 0.6; }
.episode-thumb { position: relative; flex: 0 0 96px; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: var(--img-bg); }
.episode-thumb img, .episode-thumb .video-placeholder { width: 100%; height: 100%; object-fit: cover; aspect-ratio: auto; font-size: 1.2rem; }
.episode-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.episode-info small { color: var(--text-dim); font-size: 0.78rem; }
.episode-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--bg-elevated); border-top: 1px solid var(--border); }
.episode-nav[hidden] { display: none; }
.episode-nav span { font-size: 0.9rem; font-weight: 600; }
.episode-sub { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-status { white-space: pre-line; }
.watch-url { font-size: 0.85rem; word-break: break-all; }
#addLinksText { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 9px 12px; border-radius: 8px; font-size: 0.9rem; font-family: inherit; resize: vertical; }
.form-select { font: inherit; font-size: 0.9rem; padding: 8px 10px; border-radius: 8px; background: var(--bg); color: var(--text); border: 1px solid var(--border); max-width: 100%; }
.admin-search { width: 100%; background: var(--bg-card); border: 1px solid var(--border); color: var(--text); padding: 11px 14px; border-radius: 10px; font-size: 1rem; margin-bottom: 8px; }
.admin-search:focus { outline: none; border-color: var(--accent); }
.admin-search-msg { margin: 0 0 8px; }
.sub-tab-count { margin-left: 4px; font-weight: 700; color: var(--accent); }
.search-miss { display: none !important; }
.sub-tab-btn.active .sub-tab-count { color: inherit; }
#adminPage.searching .subview > :not(ul) { display: none; }
.playlist-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.playlist-row::-webkit-scrollbar { display: none; }
.playlist-row > * { flex: 0 0 160px; scroll-snap-align: start; }
.playlist-more { display: grid; place-items: center; color: var(--accent); font-weight: 600; text-align: center; min-height: 140px; }
.playlist-head-actions { display: flex; gap: 8px; align-items: center; }
.playlist-head-actions .video-save-btn { align-self: auto; }
.playlist-head { flex-wrap: wrap; }
.episode-mid { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.episode-nav .btn, #autoNextBtn { white-space: nowrap; }

/* ===== MeeMovie แบบใหม่ ===== */
/* คลังของฉัน: ปุ่มสลับ บันทึกไว้ / ประวัติการดู */
.seg { display: flex; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 3px; margin: -6px 0 12px; }
.seg[hidden] { display: none; }
.seg button { flex: 1; background: none; border: 0; border-radius: 8px; padding: 7px; color: var(--text-dim); font: inherit; font-size: 0.88rem; cursor: pointer; }
.seg button.active { background: var(--bg-elevated); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.library-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.library-tools input { flex: 1; min-width: 0; background: var(--bg-card); border: 1px solid var(--border); color: var(--text); padding: 9px 12px; border-radius: 10px; font: inherit; font-size: 1rem; }
.library-tools input[hidden], .library-tools .btn[hidden] { display: none; }
.library-tools .btn { margin-left: auto; }

/* หน้าหลัก: แบนเนอร์ + แถวเลื่อนข้าง */
.mm-hero { position: relative; border-radius: 14px; overflow: hidden; margin-bottom: 18px; background: var(--img-bg); aspect-ratio: 16 / 9; max-height: 340px; width: 100%; cursor: pointer; }
.mm-hero > img, .mm-hero > .video-placeholder { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; aspect-ratio: auto; }
.mm-hero-info { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 14px 14px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.85)); color: #fff; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.mm-hero-badge { position: static; align-self: flex-start; }
.mm-hero-name { font-size: 1.15rem; font-weight: 700; }
.mm-hero-meta { font-size: 0.82rem; opacity: 0.85; }
.mm-hero .btn { margin-top: 6px; }
.mm-section { margin-bottom: 18px; }
.mm-row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mm-row-head .section-title { margin-bottom: 10px; }
.mm-more { color: var(--accent); font-size: 0.85rem; white-space: nowrap; }
.mm-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.mm-row::-webkit-scrollbar { display: none; }
.mm-row > * { flex: 0 0 150px; scroll-snap-align: start; }
.mm-tile { display: flex; flex-direction: column; gap: 3px; background: none; border: 0; padding: 0; text-align: left; color: var(--text); font: inherit; cursor: pointer; min-width: 0; }
.mm-thumb { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--img-bg); }
.mm-thumb img, .mm-thumb .video-placeholder { width: 100%; height: 100%; object-fit: cover; aspect-ratio: auto; display: grid; }
.mm-thumb .new-badge { top: 5px; right: 5px; }
.mm-name { font-size: 0.85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mm-meta { font-size: 0.75rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* หน้าหมวด MeeMovie: ตาราง "ทุกเรื่อง" ใช้การ์ดแบบเดียวกับแถวหน้าหลัก */
.mm-grid-head { flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.mm-grid-head .section-title { margin-bottom: 0; }
.mm-sort { display: flex; gap: 6px; }
.mm-sort button { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-dim); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 0.75rem; cursor: pointer; }
.mm-sort button.active { color: var(--accent); border-color: var(--accent); }
.mm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 10px; }
@media (max-width: 480px) { .mm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mm-grid .mm-name { font-size: 0.9rem; }
.mm-grid .lib-bar { height: 3px; margin-top: 2px; }
.mm-count { position: absolute; right: 5px; bottom: 5px; background: rgba(0, 0, 0, 0.75); color: #fff; font-size: 0.7rem; font-weight: 700; padding: 1px 6px; border-radius: 5px; }
.mm-save { position: absolute; top: 5px; left: 5px; width: 28px; height: 28px; border-radius: 50%; background: rgba(0, 0, 0, 0.55); color: #fff; display: grid; place-items: center; font-size: 14px; line-height: 1; }
.mm-save.on { background: var(--accent); color: #06281a; }
.mm-langs { display: flex; gap: 4px; font-size: 0.72rem; color: var(--text-dim); }
.mm-langs span { border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
a.mm-tile { text-decoration: none; }

/* คลังของฉัน: บันทึกไว้ */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.lib-card { display: flex; flex-direction: column; gap: 4px; background: none; border: 0; padding: 0; text-align: left; color: var(--text); font: inherit; cursor: pointer; min-width: 0; }
.lib-card.selected .mm-thumb, .lib-row.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.lib-bar { display: block; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.lib-bar > span { display: block; height: 100%; background: var(--accent); }
.lib-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.lib-row, .hist-row { display: flex; align-items: center; gap: 12px; background: none; border: 0; padding: 0; text-align: left; color: var(--text); font: inherit; cursor: pointer; width: 100%; border-radius: 8px; }
.lib-thumb { position: relative; flex: 0 0 112px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--img-bg); }
.lib-thumb img, .lib-thumb .video-placeholder { width: 100%; height: 100%; object-fit: cover; aspect-ratio: auto; display: grid; }
.lib-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.lib-play { color: var(--accent); padding: 0 6px; }
.lib-check { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; background: rgba(0, 0, 0, 0.55); color: transparent; border: 2px solid #fff; }
.lib-check.on { background: var(--accent); color: #0a0f0c; border-color: var(--accent); }
.lib-remove { width: 100%; margin-top: 4px; }
/* คลังของฉัน: ประวัติการดู */
.hist-day { font-size: 0.78rem; color: var(--text-dim); margin: 14px 0 8px; }
.hist-day:first-child { margin-top: 0; }
.hist-row { margin-bottom: 10px; }
.hist-action { flex: none; font-size: 0.8rem; padding: 6px 10px; white-space: nowrap; }
.hist-done { flex: none; color: var(--accent); font-weight: 700; padding: 0 10px; }

/* หน้าเรื่อง */
.pl-cover { position: relative; aspect-ratio: 16 / 9; max-height: 280px; border-radius: 12px; overflow: hidden; background: var(--img-bg); margin-bottom: 12px; }
.pl-cover img, .pl-cover .video-placeholder { width: 100%; height: 100%; object-fit: cover; aspect-ratio: auto; display: grid; }
.pl-name { font-size: 1.2rem; margin: 0 0 4px; }
.pl-meta { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 8px; }
.pl-bar { margin-bottom: 12px; }
.pl-actions { display: flex; gap: 8px; margin-bottom: 14px; }
.pl-actions .btn.primary { flex: 1; justify-content: center; }
.pl-actions .video-save-btn { align-self: auto; }
.pl-controls { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.pl-controls::-webkit-scrollbar { display: none; }
.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.ep-tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; padding: 6px 4px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font: inherit; cursor: pointer; overflow: hidden; min-width: 0; }
.ep-num { font-size: 1.05rem; font-weight: 700; }
.ep-sub { font-size: 0.68rem; color: var(--text-dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-tile.done .ep-num { color: var(--text-dim); font-weight: 600; }
.ep-check { position: absolute; top: 3px; right: 5px; font-size: 0.7rem; color: var(--accent); font-weight: 700; }
.ep-tile.cur { border: 2px solid var(--accent); color: var(--accent); }
.ep-here { position: absolute; top: 0; left: 0; right: 0; font-size: 0.55rem; font-weight: 700; line-height: 1.5; text-align: center; background: var(--accent); color: #0a0f0c; }
.ep-tile.cur:has(.ep-here) { padding-top: 14px; }
.ep-pg { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); }
.ep-new { position: absolute; top: 2px; right: 2px; font-size: 0.55rem; font-weight: 700; padding: 1px 5px; border-radius: 999px; background: var(--new-badge); color: #fff; }
.ep-tile.playing { background: var(--accent); border-color: var(--accent); }
.ep-tile.playing .ep-num, .ep-tile.playing .ep-sub, .ep-tile.playing .ep-check { color: #0a0f0c; }

/* ตัวเล่น: แถบเลขตอน + นับถอยหลังตอนถัดไป */
.player-episodes { display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; background: var(--bg-elevated); border-top: 1px solid var(--border); scrollbar-width: none; }
.player-episodes[hidden] { display: none; }
.player-episodes::-webkit-scrollbar { display: none; }
.player-episodes .ep-tile { flex: 0 0 58px; min-height: 44px; }
.player-episodes .ep-tile.has-sub { flex-basis: 96px; }
.next-overlay { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6; background: rgba(0, 0, 0, 0.85); color: #fff; border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; width: min(320px, calc(100% - 32px)); }
.next-overlay[hidden] { display: none; }
.next-overlay-actions { display: flex; gap: 8px; }

/* ย่อจอ */
.mini-bar { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; padding-right: 6px; }
.mini-bar[hidden] { display: none; }
.mini-title { flex: 1; min-width: 0; background: none; border: 0; color: var(--text); font: inherit; font-size: 0.85rem; font-weight: 600; text-align: left; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.video-player.mini { inset: auto 8px calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px) 8px; height: 72px; flex-direction: row; align-items: center; border-radius: 12px; overflow: hidden; background: var(--bg-elevated); border: 1px solid var(--border); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45); z-index: 110; animation: none; }
.video-player.mini > .reader-topbar, .video-player.mini > .episode-nav, .video-player.mini > .player-episodes, .video-player.mini .video-quality, .video-player.mini .tap-zone, .video-player.mini .video-resume-hint { display: none !important; }
.video-player.mini .video-player-body { flex: 0 0 128px; height: 72px; padding: 0; display: block; overflow: hidden; background: #000; }
.video-player.mini .native-wrap { height: 72px; }
.video-player.mini .native-video { width: 128px; height: 72px; max-height: 72px; border-radius: 0; object-fit: cover; }

/* ===== MeeManga แบบใหม่ ===== */
/* หน้าหลัก: การ์ดอ่านต่อ */
.mh-hero { display: flex; gap: 12px; padding: 12px; margin-bottom: 18px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; cursor: pointer; }
.mh-cover { position: relative; flex: 0 0 84px; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; background: var(--img-bg); }
.mh-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mh-cover .new-badge { top: 5px; left: 5px; right: auto; }
.mh-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 5px; }
.mh-name { font-weight: 700; font-size: 1rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mh-info .btn { align-self: stretch; justify-content: center; margin-top: 4px; }
/* แถวปกแนวตั้ง */
.mm-row.covers > * { flex: 0 0 112px; width: 112px; }
.mm-ctile { position: relative; }
.mm-cthumb { position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; background: var(--img-bg); }
.mm-cthumb img { width: 100%; height: 100%; object-fit: cover; display: block; aspect-ratio: auto; border-radius: 0; }
.mm-cthumb .new-badge { top: 5px; right: 5px; }
.rank-badge { position: absolute; top: 5px; left: 5px; background: var(--accent); color: #0a0f0c; font-size: 0.68rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.mm-ctile .mm-meta { margin-top: 2px; }
.follow-head { align-items: center; margin-top: 4px; }
.follow-head .form-select { font-size: 0.8rem; padding: 5px 8px; }
/* ปุ่มติดตามวงกลมที่มุมปก (พื้นที่กดใหญ่กว่าที่เห็น) */
.follow-dot { position: absolute; z-index: 2; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; padding: 0; font: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer; background: rgba(0, 0, 0, 0.6); color: #fff; border: 1.5px solid rgba(255, 255, 255, 0.85); box-shadow: 0 0 0 8px transparent; }
.follow-dot::after { content: ""; position: absolute; inset: -8px; }
.follow-dot.on { background: var(--accent); color: #0a0f0c; border-color: var(--accent); }
.mm-cthumb .follow-dot { bottom: 6px; right: 6px; }
.manga-card .follow-dot { top: 8px; left: 8px; }
/* ประวัติการอ่าน */
.history-search { width: 100%; background: var(--bg-card); border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: 10px; font: inherit; font-size: 1rem; margin-bottom: 12px; }
.history-list .hist-day { list-style: none; }
.history-row .lib-bar { margin-top: 4px; }
/* หน้าเรื่อง */
.ch-head { display: flex; gap: 12px; margin-bottom: 12px; }
.ch-cover { flex: 0 0 96px; width: 96px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; background: var(--img-bg); }
.ch-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ch-info .pl-name { font-size: 1.1rem; font-weight: 700; margin: 0; }
.ch-info .pl-meta { margin: 0; }
.ch-info .lib-bar { margin-top: 4px; }
#chapterListBody .pl-actions, #chapterListBody .pl-controls, #chapterListBody .ch-head { padding: 0 2px; }
.ch-grid { padding-bottom: 24px; }
/* หน้าอ่าน: การ์ดจบตอน + หลอดในแถบล่าง */
.end-card { width: calc(100% - 32px); max-width: 520px; box-sizing: border-box; margin: 24px auto 32px; padding: 18px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; color: var(--text); }
.end-title { font-weight: 700; font-size: 1rem; }
.end-meta { font-size: 0.82rem; color: var(--text-dim); }
.end-card .end-next { width: 100%; justify-content: center; }
.end-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.end-hint { font-size: 0.85rem; color: var(--text-dim); transition: color 0.25s ease; }
.end-card.show .end-hint { color: var(--accent); font-weight: 600; }
.reader-progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--border); overflow: hidden; }
.reader-progress > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s linear; }
.history-list .hist-day { padding: 12px 16px 6px; margin: 0; }
.follow-head[hidden], #mangaHome[hidden], #catalogHome[hidden] { display: none; }
.reader-error { max-width: 420px; margin: 80px auto 0; padding: 20px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: var(--text); }
.reader-error details { width: 100%; font-size: 0.78rem; color: var(--text-dim); }
.reader-error summary { cursor: pointer; }
.reader-error-raw { margin-top: 6px; word-break: break-all; text-align: left; }
#chapterListView.over-reader { z-index: 105; }

/* ===== หน้าตั้งค่าแบบกลุ่ม ===== */
.set-group-title { font-size: 0.78rem; font-weight: 600; color: var(--text-dim); margin: 18px 4px 6px; }
.set-group { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.set-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; background: none; border: 0; border-top: 1px solid var(--border); color: var(--text); font: inherit; font-size: 0.95rem; text-align: left; text-decoration: none; cursor: pointer; }
.set-group > .set-item:first-child, .set-group > :first-child .set-row { border-top: 0; }
.set-item[hidden] { display: none; }
.set-ic { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--bg); font-size: 0.95rem; }
.set-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.set-label small { font-size: 0.75rem; color: var(--text-dim); }
.set-value { color: var(--text-dim); font-size: 0.85rem; white-space: nowrap; }
.set-item .chev { color: var(--text-dim); }
.set-item .form-select { font-size: 0.85rem; padding: 6px 8px; }
.set-danger .set-label { color: var(--danger); }
.set-details { display: block; padding: 0; }
.set-details > summary { display: flex; align-items: center; gap: 12px; padding: 12px 14px; list-style: none; cursor: pointer; }
.set-details > summary::-webkit-details-marker { display: none; }
.set-details > summary .set-label { flex: 1; }
.set-details .password-form { padding: 0 14px 14px; }
.set-seg { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 2px; gap: 2px; }
.set-seg button { background: none; border: 0; border-radius: 7px; padding: 5px 9px; color: var(--text-dim); font: inherit; font-size: 0.8rem; cursor: pointer; white-space: nowrap; }
.set-seg button.on { background: var(--bg-card); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.set-back { margin-bottom: 10px; }
.status-dot { flex: none; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); margin-right: 5px; vertical-align: middle; }
.status-dot[hidden] { display: none; }
.status-dot.ok { background: var(--accent); }
.status-dot.warn { background: #f5a524; }
.status-dot.bad { background: var(--danger); }
.status-bad { color: var(--danger); }
.admin-search-fake { display: block; text-align: left; color: var(--text-dim); cursor: pointer; }
.admin-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 0 4px; }
.admin-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.admin-card-num { font-size: 1.3rem; font-weight: 700; margin: 2px 0; }
.admin-card-status { font-size: 0.75rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-row { position: relative; flex-wrap: wrap; }
.row-status { display: flex; align-items: center; }
.row-menu { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; padding: 8px 0 2px; }
.row-menu[hidden] { display: none; }
.row-menu .btn { font-size: 0.85rem; padding: 6px 10px; display: inline-flex; align-items: center; gap: 6px; }
.row-menu .btn svg { width: 16px; height: 16px; }
#settingsMain[hidden], #adminHub[hidden], #adminPage[hidden] { display: none; }

/* ===== จัดการคลิป (แอดมิน) ===== */
.vm-seg { margin: 0 0 12px; }
.vm-pane[hidden] { display: none; }
#adminPage.searching .subview > .vm-pane { display: block !important; }
#adminPage.searching .vm-pane > :not(ul) { display: none; }
#adminPage.searching .vm-seg { display: none; }
.vm-list { margin-bottom: 12px; }
.vm-row { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.vm-row .grow { flex: 1; min-width: 0; }
.vm-row .name { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vm-row .meta { font-size: 0.75rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vm-row .btn { font-size: 0.8rem; padding: 5px 9px; flex: none; }
.vm-thumb { flex: none; width: 64px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: var(--img-bg); display: grid; place-items: center; font-size: 0.8rem; }
.vm-ep { position: absolute; left: 52px; top: 4px; background: var(--new-badge); color: #fff; font-size: 0.55rem; font-weight: 700; padding: 1px 5px; border-radius: 999px; }
.vm-more { flex: none; color: var(--text-dim); font-size: 1.1rem; padding: 0 4px; }
.vm-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 8px; }
.vm-card h3 { margin: 0; font-size: 0.95rem; display: flex; justify-content: space-between; align-items: center; }
.vm-card h3 .btn { font-size: 0.8rem; padding: 4px 10px; }
.vm-card textarea, .vm-watch-form input, .vm-field input { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 9px 12px; border-radius: 8px; font: inherit; font-size: 1rem; }
.vm-card .pl-controls { margin: 0; }
.vm-watch-form { display: flex; flex-direction: column; gap: 8px; }
.vm-watch-form[hidden] { display: none; }
.vm-field { display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; color: var(--text-dim); }
/* แผ่นแก้ไขเลื่อนขึ้นจากด้านล่าง */
.sheet-backdrop { position: fixed; inset: 0; z-index: 130; background: rgba(0, 0, 0, 0.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop[hidden] { display: none; }
.sheet { width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; overscroll-behavior: contain; background: var(--bg-elevated); border-radius: 16px 16px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); animation: slide-up 0.18s ease-out; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 12px; }
#vmSheetBody { display: flex; flex-direction: column; gap: 10px; }
#vmSheetBody > .btn { justify-content: center; }
.sheet-head { display: flex; gap: 10px; align-items: center; }
.sheet-head .vm-thumb { width: 80px; }
.sheet-head .name { font-weight: 700; }
.sheet-head .meta { font-size: 0.78rem; color: var(--text-dim); }
.sheet-eps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; }
.sheet-eps li { display: flex; gap: 8px; align-items: center; font-size: 0.8rem; }
.sheet-eps input { width: 72px; flex: none; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 6px 8px; border-radius: 6px; font: inherit; font-size: 1rem; }
.sheet-eps input.saved { border-color: var(--accent); }
.sheet-eps span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }
.vm-seg button { white-space: nowrap; font-size: 0.82rem; padding: 7px 4px; }

/* แถบแนะนำเพิ่มไปหน้าจอโฮม + แผ่นวิธีทำ */
.install-banner { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; margin-bottom: 14px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 14%, var(--bg-card)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); }
.install-banner[hidden] { display: none; }
.install-banner-ic { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-card); font-size: 1.1rem; }
.install-banner .grow { flex: 1; min-width: 0; }
.install-banner-title { font-weight: 700; font-size: 0.9rem; }
.install-banner-desc { font-size: 0.75rem; color: var(--text-dim); }
.install-banner .btn { flex: none; font-size: 0.8rem; padding: 6px 10px; }
.install-banner-close { flex: none; background: none; border: 0; color: var(--text-dim); font-size: 1rem; padding: 6px; margin: -6px -4px -6px 0; cursor: pointer; }
.install-sheet-title { margin: 0 0 10px; font-size: 1rem; }
.install-steps { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 12px; font-size: 0.92rem; line-height: 1.45; }
.install-steps li { display: flex; align-items: center; gap: 10px; }
.install-step-num { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); font-weight: 700; font-size: 0.8rem; }
.install-step-ic { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--bg-card); border: 1px solid var(--border); color: #0a84ff; }
.install-step-word { font-weight: 700; font-size: 0.85rem; color: #0a84ff; }
.install-sheet-actions { display: flex; gap: 8px; }
.install-sheet-actions .btn { flex: 1; justify-content: center; }

/* ดึงลงเพื่อรีเฟรช */
.pull-refresh { position: fixed; top: calc(env(safe-area-inset-top) + 6px); left: 50%; z-index: 60; width: 38px; height: 38px; margin-top: -44px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-elevated); color: var(--text-dim); border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); opacity: 0; transform: translate(-50%, 0); pointer-events: none; }
.pull-refresh.ready, .pull-refresh.spinning { color: var(--accent); }
.pull-refresh.spinning svg { animation: spin 0.8s linear infinite; }

/* พื้นที่แตะอย่างน้อย ~40px บนมือถือ (ปุ่มเล็กเดิมสูง 16-30px แตะพลาดง่าย) */
.video-quality-btn, .video-chip { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.video-quality-btn[hidden], .video-chip[hidden] { display: none; }
.hist-action { min-height: 40px; }
.link-btn { position: relative; }
.link-btn::after { content: ""; position: absolute; inset: -12px -8px; }

/* ค้นหาล่าสุด */
.search-history { margin-bottom: 8px; }
.search-history-head { display: flex; align-items: baseline; justify-content: space-between; }
.search-history-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.search-chip { display: inline-flex; align-items: center; max-width: 100%; background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; }
.search-chip-text { min-height: 40px; padding: 0 4px 0 14px; background: none; border: 0; color: var(--text); font: inherit; font-size: 0.85rem; cursor: pointer; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-chip-x { min-width: 36px; min-height: 40px; background: none; border: 0; color: var(--text-dim); font-size: 1.1rem; cursor: pointer; }

/* แผ่นยืนยัน + ข้อความลอย (แทน confirm/alert) — อยู่บนสุดเหนือหน้าอ่าน/ตัวเล่น/แผ่นอื่น */
.confirm-backdrop { z-index: 450; }
.confirm-text { margin: 4px 0 16px; font-size: 0.95rem; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.confirm-actions { display: flex; gap: 8px; }
.confirm-actions .btn { flex: 1; justify-content: center; min-height: 44px; }
.confirm-actions .btn.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); transform: translateX(-50%); z-index: 460; width: max-content; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 0.88rem; line-height: 1.45; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); white-space: pre-line; animation: slide-up 0.18s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
.toast[hidden] { display: none; }

/* YouTube: ตัวเล่น + ป้ายบนการ์ด + เลือกพากย์/ซับในหน้าเรื่อง */
.yt-wrap { position: relative; width: 100%; max-width: 900px; aspect-ratio: 16 / 9; justify-self: center; background: #000; border-radius: 6px; overflow: hidden; }
.yt-wrap iframe, .yt-wrap #ytMount { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.yt-open { justify-self: center; margin-top: 10px; color: var(--text-dim); font-size: 0.82rem; text-decoration: underline; padding: 10px; }
.yt-error { justify-self: center; margin-top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; color: var(--text); font-size: 0.88rem; }
.yt-error[hidden] { display: none; }
.video-player.mini .yt-wrap { width: 128px; height: 72px; aspect-ratio: auto; border-radius: 0; }
.video-player.mini .yt-open, .video-player.mini .yt-error { display: none; }
/* Anifume: กรอบ 16:9 — ขนาด/scale ของ iframe คำนวณใน mountAnifumeVideo */
.af-wrap { position: relative; width: 100%; max-width: min(854px, calc((100dvh - 260px) * 16 / 9)); aspect-ratio: 16 / 9; justify-self: center; background: #000; border-radius: 6px; overflow: hidden; }
.af-wrap iframe { position: absolute; top: 0; left: 0; width: 100%; border: 0; transform-origin: 50% 0; }
.playback-error { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 0 16px; }
.playback-code { font-size: 0.7rem; color: var(--text-dim); font-family: ui-monospace, monospace; }
.af-note { justify-self: center; max-width: 520px; margin-top: 10px; padding: 0 8px; color: var(--text-dim); font-size: 0.78rem; text-align: center; line-height: 1.5; }
.af-note a { color: inherit; text-decoration: underline; white-space: nowrap; }
.video-player.mini .af-note { display: none; }
.video-player.mini .af-wrap { width: 128px; height: 72px; aspect-ratio: auto; border-radius: 0; }
.af-list { max-height: 260px; overflow: auto; margin: 6px 0; padding: 0; list-style: none; font-size: 0.85rem; }
.af-list li { display: flex; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.af-list .ep { min-width: 3.5em; color: var(--text-dim); }
.af-list .exists { color: var(--text-dim); }
#afItems { width: 100%; min-height: 110px; font: inherit; font-size: 0.85rem; }
.yt-badge.af-badge { background: #6b46c1; }
.yt-badge { position: absolute; left: 6px; bottom: 6px; z-index: 2; background: #e0302b; color: #fff; font-size: 0.6rem; font-weight: 700; line-height: 1; padding: 3px 5px; border-radius: 4px; pointer-events: none; }
.pl-lang { display: flex; gap: 4px; padding: 4px; margin: 12px 0 4px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; }
.pl-lang button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: none; color: var(--text-dim); font: inherit; font-size: 0.9rem; cursor: pointer; }
.pl-lang button.active { background: var(--accent); color: #0a0f0c; font-weight: 600; }
.ep-tile.na { border-style: dashed; background: none; color: var(--text-dim); }
.ep-tile.na .ep-num { font-weight: 500; }
.pl-hint { margin-top: 12px; }
.yt-add-row { display: flex; gap: 8px; }
.yt-add-row input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 9px 12px; border-radius: 8px; font: inherit; font-size: 1rem; }
.yt-preview { display: flex; gap: 10px; align-items: center; }
.yt-preview .name { font-weight: 700; }
.yt-preview .meta { font-size: 0.78rem; color: var(--text-dim); }
.switch-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.88rem; }
.tag-lang { display: inline-block; font-size: 0.7rem; padding: 1px 6px; border-radius: 4px; background: var(--bg); border: 1px solid var(--border); color: var(--text-dim); }
.season-name { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 0.85rem; color: var(--text-dim); }
.season-name input { flex: 1; }
/* สวิตช์ในช่อง .vm-field ไม่ใช้กติกา "ช่องกรอกเต็มความกว้าง" (เดิมยืดจนล้นแถว) */
.vm-field input.switch { width: 46px; height: 28px; padding: 0; border: 0; border-radius: 999px; background: var(--border); }
.vm-field input.switch:checked { background: var(--accent); }
.switch-label { flex: none; white-space: nowrap; }
.merge-opts { display: flex; gap: 8px; margin-top: 6px; }
.merge-opts label { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text-dim); white-space: nowrap; }
.merge-opts input, .merge-opts select { flex: 1; min-width: 0; }
.series-info { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.series-seasons { color: var(--accent); font-weight: 600; }
.series-lang { font-size: 0.68rem; line-height: 1.4; padding: 0 5px; border: 1px solid var(--border); border-radius: 4px; color: var(--text); }
.pl-lang-one { display: flex; align-items: center; gap: 8px; margin: 10px 0 2px; font-size: 0.8rem; color: var(--text-dim); }
.pl-lang-one .series-lang { font-size: 0.8rem; padding: 2px 8px; }

/* แบนเนอร์สไลด์ (หน้า MeeMovie) — ปัดได้เอง + เลื่อนอัตโนมัติทุก 5 วิ */
.mm-hero-carousel { position: relative; margin-bottom: 18px; }
.mm-hero-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; border-radius: 14px; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.mm-hero-track::-webkit-scrollbar { display: none; }
.mm-hero-track > .mm-hero { flex: 0 0 100%; margin-bottom: 0; border-radius: 0; scroll-snap-align: start; scroll-snap-stop: always; }
.mm-hero-dots { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 2px; }
.mm-hero-dots button { width: 22px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.mm-hero-dots button::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.5); transition: width 0.2s, background 0.2s; }
.mm-hero-dots button.active::before { width: 18px; background: #fff; }

/* แบรนด์ Mee+ (หัวแอป / หน้า login) */
.brand-title { display: flex; align-items: center; gap: 8px; }
.brand-icon { width: 28px; height: 28px; border-radius: 7px; flex: none; }
.brand-plus { color: var(--accent); }
.brand-sub { font-weight: 600; color: var(--text-dim); font-size: 0.95rem; }
.login-logo { display: block; width: 72px; height: 72px; border-radius: 16px; margin: 0 auto 10px; }
.login-tagline { text-align: center; color: var(--text-dim); font-size: 0.85rem; margin: -2px 0 14px; }

/* ผู้เยี่ยมชม: การ์ด "ใช้ Mee+ ให้ครบ" (เข้าสู่ระบบ + ติดตั้ง) */
.setup-card { margin-bottom: 14px; padding: 12px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 10%, var(--bg-card)); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); }
.setup-card[hidden] { display: none; }
.setup-head { display: flex; align-items: center; gap: 8px; }
.setup-heading { flex: 1; font-weight: 700; font-size: 0.92rem; }
.setup-count { font-size: 0.75rem; color: var(--text-dim); }
.setup-bar { height: 4px; border-radius: 2px; background: var(--border); margin: 8px 0 2px; overflow: hidden; }
.setup-bar span { display: block; height: 100%; background: var(--accent); }
.setup-step { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.setup-step + .setup-step { border-top: 1px solid var(--border); }
.setup-num { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 0.78rem; font-weight: 700; background: color-mix(in srgb, var(--accent) 22%, var(--bg-card)); color: var(--accent); }
.setup-step.done .setup-num { background: color-mix(in srgb, var(--accent) 16%, var(--bg-card)); }
.setup-step .grow { flex: 1; min-width: 0; }
.setup-title { font-weight: 600; font-size: 0.86rem; }
.setup-step.done .setup-title { color: var(--text-dim); font-weight: 500; }
.setup-desc { font-size: 0.74rem; color: var(--text-dim); line-height: 1.45; }
.setup-step .btn { flex: none; font-size: 0.8rem; padding: 6px 12px; }
.setup-foot { text-align: center; font-size: 0.75rem; color: var(--text-dim); margin-top: 4px; }
.setup-foot a { color: var(--accent); }

/* แผ่นชวนเข้าสู่ระบบ */
.login-sheet-title { margin: 4px 0 4px; font-size: 1.05rem; }
.login-perks { list-style: none; margin: 4px 0 12px; padding: 0; display: grid; gap: 6px; font-size: 0.88rem; }
.login-perks li::before { content: "✓"; color: var(--accent); font-weight: 700; margin-right: 8px; }
.login-local { font-size: 0.8rem; line-height: 1.5; padding: 8px 10px; border-radius: 8px; margin: 0 0 12px; background: color-mix(in srgb, var(--accent) 14%, var(--bg-card)); }
.login-local[hidden] { display: none; }
.btn.block { display: block; width: 100%; text-align: center; margin-top: 8px; box-sizing: border-box; text-decoration: none; }
.btn.ghost { background: none; border-color: transparent; color: var(--text-dim); }
.hint.center { text-align: center; margin-top: 8px; }
.guest-actions { display: flex; gap: 8px; margin: -10px 0 20px; }
.guest-actions[hidden] { display: none; }
.guest-actions .btn { flex: 1; text-align: center; text-decoration: none; }
.member-only[hidden] { display: none !important; }
#pushBtn.locked { opacity: 0.6; }
.login-skip { display: block; text-align: center; margin-top: 14px; font-size: 0.82rem; color: var(--text-dim); }

/* MeeMovie: ปุ่มบนหัว (คลังของฉัน / + เพิ่ม) */
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.topbar-actions[hidden], .topbar-pill[hidden] { display: none; }
.topbar-pill { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.topbar-pill.active { color: var(--accent); border-color: var(--accent); }
.topbar-pill.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
:root:not([data-theme="light"]) .topbar-pill.primary { color: #0a0f0c; }
.library-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.library-head[hidden] { display: none; }
.library-head .seg { flex: 1; margin: 0; }

/* MeeMovie: ปุ่มเลือกหมวด + หมวดที่เปิดล่าสุด */
.vcat-picker { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; min-width: 0; }
.vcat-picker[hidden] { display: none; }
.vcat-btn { flex: none; display: flex; align-items: center; gap: 6px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; font: inherit; font-size: 1.02rem; font-weight: 700; color: var(--text); cursor: pointer; max-width: 60%; }
.vcat-recent { display: flex; gap: 6px; overflow-x: auto; min-width: 0; }

/* แผ่นเลือกหมวด (เลื่อนขึ้นจากล่าง) — รายการ / ตาราง */
.vcat-sheet-wrap[hidden] { display: none; }
.vcat-sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 60; }
.vcat-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-width: 640px; margin: 0 auto; background: var(--bg-elevated); border-radius: 16px 16px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 78vh; overflow-y: auto; box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.2); }
.vcat-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 12px; }
.vcat-sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.vcat-sheet-head h3 { margin: 0; font-size: 1rem; }
.vcat-view { display: flex; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.vcat-view button { display: flex; align-items: center; gap: 4px; background: none; border: 0; border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 0.8rem; color: var(--text-dim); cursor: pointer; }
.vcat-view button.active { background: var(--bg-elevated); color: var(--text); font-weight: 700; box-shadow: 0 0 0 1px var(--border); }
.vcat-list button { display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--border); padding: 9px 2px; font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.vcat-thumb { flex: none; width: 64px; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: var(--img-bg); }
.vcat-thumb img, .vcat-thumb .video-placeholder { width: 100%; height: 100%; object-fit: cover; display: grid; place-items: center; }
.vcat-name { flex: 1; min-width: 0; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcat-list b, .vcat-grid b { flex: none; font-weight: 400; color: var(--text-dim); font-size: 0.78rem; }
.vcat-list button.active .vcat-name { color: var(--accent); font-weight: 700; }
.vcat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.vcat-grid button { display: flex; align-items: center; justify-content: space-between; gap: 6px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; font: inherit; font-size: 0.9rem; color: var(--text); text-align: left; cursor: pointer; min-width: 0; }
.vcat-grid button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcat-grid button.active { border-color: var(--accent); color: var(--accent); font-weight: 700; }
body.sheet-open { overflow: hidden; }

/* หน้าหมวด: ชื่อหมวด + ชิปแนว + ป้ายแนวใต้ชื่อ */
.mm-cat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 2px 0 6px; }
.mm-cat-head h2 { margin: 0; font-size: 1.35rem; }
.mm-cat-head span { color: var(--text-dim); font-size: 0.8rem; white-space: nowrap; }
.mm-genres { display: flex; gap: 4px; overflow-x: auto; margin: 0 0 12px; padding-bottom: 2px; }
.mm-genres button { flex: 0 0 auto; border: 0; background: none; color: var(--text-dim); font: inherit; font-size: 0.82rem; padding: 4px 9px; border-radius: 6px; cursor: pointer; }
.mm-genres button.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); font-weight: 700; }
.mm-genres b { font-weight: 400; opacity: 0.7; margin-left: 4px; }
.mm-tags { font-size: 0.7rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mm-cat .mm-hero { max-height: 220px; }
@media (min-width: 900px) { .mm-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
.library-head .link-btn { text-decoration: none; color: var(--accent); white-space: nowrap; }
.brand-sub { white-space: nowrap; }
@media (max-width: 380px) {
  body[data-tab="videos"] .brand-sub { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar-pill { padding: 5px 10px; font-size: 0.8rem; }
}

/* ตั้งค่า › หมวด: หมวดหลัก / แนว */
.vc-seg { margin: 0 0 12px; }
.vc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.vc-row { display: flex; align-items: center; gap: 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; }
.vc-row.dragging { opacity: 0.85; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2); border-color: var(--accent); position: relative; z-index: 2; }
.vc-expanded { flex-direction: column; align-items: stretch; }
.vc-top { display: flex; align-items: center; gap: 10px; }
.vc-drag { flex: none; color: var(--text-dim); font-size: 1.15rem; padding: 6px 4px; cursor: grab; touch-action: none; user-select: none; }
.vc-thumb { flex: none; width: 64px; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: var(--img-bg); }
.vc-thumb img, .vc-thumb .video-placeholder { width: 100%; height: 100%; object-fit: cover; display: grid; place-items: center; }
.vc-grow { flex: 1; min-width: 0; }
button.vc-grow { background: none; border: 0; padding: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.vc-name { font-weight: 700; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-meta { font-size: 0.75rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-badge { font-size: 0.66rem; font-weight: 400; border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; margin-left: 6px; color: var(--text-dim); vertical-align: middle; }
.vc-more { flex: none; background: none; border: 0; color: var(--text-dim); font-size: 1.3rem; padding: 2px 6px; cursor: pointer; }
.vc-sub { font-size: 0.78rem; font-weight: 700; color: var(--text-dim); margin: 12px 0 6px; }
.vc-words { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.vc-words > span { display: inline-flex; align-items: center; gap: 2px; font-size: 0.8rem; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 2px 4px 2px 10px; }
.vc-words > span button { background: none; border: 0; color: var(--text-dim); font-size: 0.75rem; padding: 2px 5px; cursor: pointer; }
.vc-word-add input { width: 110px; font: inherit; font-size: 0.8rem; color: var(--accent); background: none; border: 1px dashed var(--border); border-radius: 999px; padding: 4px 10px; }
.vc-hits { display: flex; flex-direction: column; gap: 6px; }
.vc-hit { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; }
.vc-hit span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-hit mark { background: color-mix(in srgb, var(--accent) 24%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.vc-hit button { flex: none; background: none; border: 1px solid var(--border); border-radius: 999px; font: inherit; font-size: 0.72rem; padding: 2px 9px; color: var(--text-dim); cursor: pointer; }
.vc-menu { position: fixed; z-index: 70; min-width: 190px; max-height: 60vh; overflow-y: auto; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); padding: 4px; }
.vc-menu[hidden] { display: none; }
.vc-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 10px 12px; font: inherit; font-size: 0.88rem; color: var(--text); cursor: pointer; }
.vc-menu button:hover { background: var(--bg-card); }
.vc-menu button.danger { color: var(--danger); }
#sheetGenres .video-chip.auto { border-style: dashed; }
#sheetGenres .video-chip small { font-size: 0.65rem; opacity: 0.8; margin-left: 4px; }
.vcat-name .vc-badge { margin-left: 8px; }
.vc-row > .vc-top { flex: 1; min-width: 0; }
#sheetGenres { flex-wrap: wrap; overflow: visible; }
