*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ตัวแปรสีเดิมทั้งหมดยังอยู่ (app.js อ้าง var(--primary), var(--danger), var(--muted) ฯลฯ ใน inline style) */
:root {
  /* [UI โฉมใหม่ 25 ก.ย. 2569] ค่าเดิมทั้งหมดดูได้ที่ legacy/app.css — ชื่อตัวแปรเดิมคงไว้ (app.js อ้าง var(--primary), var(--danger), var(--muted)) */
  --bg:        #0c0c0e;
  --bg2:       #101013;
  --surface:   #141417;
  --surface2:  #1c1c21;
  --surface3:  #25252b;
  --border:    rgba(255,255,255,.08);
  --border-h:  rgba(255,255,255,.14);
  --border-strong: rgba(255,255,255,.24);
  --hover:     rgba(255,255,255,.04);
  --hover-soft: rgba(255,255,255,.02);
  --inset-bg:  rgba(0,0,0,.18);
  --primary:   #f2c30f;
  --primary-h: #ffdc5c;            /* ใช้เป็นสีตัวอักษรเหลือง (โหมดสว่างเปลี่ยนเป็นเหลืองเข้ม) */
  --primary-ink: #f2c30f;
  --primary-g: linear-gradient(135deg, #ffd83a, #e1ab06);
  --primary-glow: rgba(242,195,15,.24);
  --primary-soft: rgba(242,195,15,.10);
  --primary-line: rgba(242,195,15,.34);
  --on-primary:#1a1403;
  --success:   #34d399;
  --success-bg:rgba(52,211,153,.10);
  --danger:    #f87171;
  --danger-bg: rgba(248,113,113,.10);
  --warn:      #fb923c;
  --warn-bg:   rgba(251,146,60,.10);
  --text:      #f4f2ec;
  --text2:     #b5b1a6;
  --muted:     #8f8a7f;            /* เดิม #6f6b62 (contrast 3.3–3.7:1) → 4.9–5.7:1 */
  --knob-off:  #9b978c;
  --bar:       rgba(20,20,23,.82);
  --bar-solid: rgba(15,15,18,.92);
  --scheme:    dark;
  /* พรีวิวโพส Facebook (โหมดมืด = Facebook โหมดมืด) */
  --fb-bg: #242526; --fb-card: #3a3b3c; --fb-card2: #303133; --fb-btn: #4e4f50;
  --fb-text: #e4e6eb; --fb-sub: #b0b3b8; --fb-img: #2c2c30; --fb-line: rgba(255,255,255,.06);
  --fb-avatar: linear-gradient(140deg, #4a4b4d, #3a3b3c); --fb-faint: rgba(255,255,255,.7);
  /* ตัวอักษร 6 ขนาด */
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 28px;
  --radius:    16px;
  --radius-s:  10px;
  --radius-xs: 8px;
  --sidebar-w: 264px;
  --shadow:    0 1px 2px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.22);
  --shadow-lg: 0 24px 64px rgba(0,0,0,.5);
  --transition: .18s cubic-bezier(.3,.7,.2,1);
  --ease: cubic-bezier(.3,.7,.2,1);
  --font: 'IBM Plex Sans Thai', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

html { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── ไอคอนเส้น (SVG sprite ใน index.html) ── */
.ic {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.ic-sm { width: 15px; height: 15px; }
.ic-lg { width: 20px; height: 20px; }

/* ══════════════════════════════════════════════════════════════ */
/* ── Fullscreen (Connect / No Extension) ─────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.fullscreen-msg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 30% 15%, rgba(242,195,15,.08) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 85%, rgba(201,154,10,.06) 0%, transparent 55%),
    var(--bg);
}
.msg-box {
  background: var(--surface);
  border: 1px solid var(--border-h);
  border-radius: 28px;
  padding: 44px 40px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg);
}
.msg-icon {
  width: 60px; height: 60px;
  border-radius: 18px;
  display: grid; place-items: center;
  background: var(--primary-g);
  color: var(--on-primary);
  box-shadow: 0 8px 28px var(--primary-glow), inset 0 1px 0 rgba(255,255,255,.4);
}
.msg-icon .ic { width: 28px; height: 28px; stroke-width: 1.9; }
.msg-box h2 { font-size: var(--fs-xl); font-weight: 600; line-height: 1.35; }
.msg-box p  { color: var(--text2); line-height: 1.7; font-size: var(--fs-md); }

.manual-fallback { width: 100%; margin-top: 8px; }
.manual-fallback summary {
  font-size: var(--fs-sm);
  color: var(--text2);
  cursor: pointer;
  text-align: center;
  padding: 8px;
  transition: color var(--transition);
}
.manual-fallback summary:hover { color: var(--text); }
.manual-fallback-body {
  margin-top: 12px;
  text-align: left;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}
.step-list { padding-left: 20px; color: var(--text2); line-height: 2.1; font-size: var(--fs-sm); }
.step-list a { color: var(--primary-h); text-decoration: none; }
.step-list a:hover { text-decoration: underline; }
#tokenModal { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }

/* ══════════════════════════════════════════════════════════════ */
/* ── Sidebar Layout ──────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .28s var(--ease);
}

/* ── Collapsible sidebar ── */
.app-layout.sidebar-collapsed .sidebar { width: 76px; padding-inline: 10px; }
.app-layout.sidebar-collapsed .main-content { margin-left: 76px; }
.app-layout.sidebar-collapsed .brand-text,
.app-layout.sidebar-collapsed .nav-group-label,
.app-layout.sidebar-collapsed .nav-item span:not(.nav-icon),
.app-layout.sidebar-collapsed .sidebar-pages-head span,
.app-layout.sidebar-collapsed .sidebar-pages-list,
.app-layout.sidebar-collapsed .sidebar-pages-actions,
.app-layout.sidebar-collapsed .sidebar-pages,
.app-layout.sidebar-collapsed .sidebar-quota {
  display: none;
}
.app-layout.sidebar-collapsed .nav-item { justify-content: center; padding: 11px; }
.app-layout.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 4px 0 46px; border-bottom: 0; }

/* ปุ่มย่อ/ขยาย — อยู่ในแถบ brand (ยังเป็น #btnSidebarCollapse ตัวเดิม) */
.collapse-btn {
  position: absolute;
  top: 22px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 60;
  font-size: var(--fs-lg);
  line-height: 1;
  transition: background .15s, color .15s, transform .28s var(--ease);
}
.collapse-btn:hover { background: var(--surface2); color: var(--text); }
.app-layout.sidebar-collapsed .collapse-btn { right: auto; left: 24px; top: 62px; transform: rotate(180deg); }

.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  transition: margin-left .28s var(--ease);
  padding: 28px clamp(16px, 3vw, 40px) 56px;
  min-height: 100vh;
}
.main-content > .mode-content { max-width: 1120px; margin-inline: auto; }

/* ── Sidebar Brand ── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 44px 14px 6px;
}
.sidebar-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--primary-g);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px; /* ตัวอักษรในโลโก้ คงขนาดเดิม */
  font-weight: 700;
  color: var(--on-primary);
  flex-shrink: 0;
  box-shadow: 0 4px 18px rgba(242,195,15,.22), inset 0 1px 0 rgba(255,255,255,.35);
}
.sidebar-name {
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.35;
}
.sidebar-sub {
  font-size: var(--fs-xs);
  color: var(--success);
  font-weight: 500;
}

/* ── Sidebar Navigation ── */
.sidebar-nav {
  padding: 8px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-group-label {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
  padding: 0 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-s);
  color: var(--text2);
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  border: 1px solid transparent;
  background: none;
  font-family: inherit;
  text-decoration: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: var(--hover);
  color: var(--text);
}
.nav-item.active {
  background: var(--primary-soft);
  border-color: var(--primary-line);
  color: var(--primary-h);
  font-weight: 600;
}
.nav-icon { width: 20px; height: 20px; display: grid; place-items: center; flex-shrink: 0; }

/* ── Sidebar Pages ── */
.sidebar-pages {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.sidebar-pages-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 8px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
}
.sel-count {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--primary-h);
  font-weight: 500;
}
.sel-count:not(:empty) {
  background: var(--primary-soft);
  padding: 1px 9px;
  border-radius: 999px;
}
.sidebar-pages-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 80px;
  max-height: 380px;
}
.sidebar-pages-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 6px 4px;
  margin-top: 8px;
}
.btn-link {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  padding: 3px 10px;
  border-radius: 999px;
  transition: background .15s, color .15s;
}
.btn-link:hover { background: var(--surface2); color: var(--text); }
.dot-sep { display: none; }

/* ── Page Checkbox Items ── */
.page-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background .12s;
  user-select: none;
  border: 1px solid transparent;
}
.page-check-item:hover { background: var(--hover); }
.page-check-item input[type=checkbox] { display: none; }
.page-cb {
  width: 17px; height: 17px;
  border-radius: 6px;
  border: 1.5px solid var(--muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
  color: transparent;
}
.page-cb::after {
  content: '';
  width: 8px; height: 4px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg) translate(1px, -1px);
  opacity: 0;
}
.page-check-item.checked .page-cb {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.page-check-item.checked .page-cb::after { opacity: 1; }
.page-label { font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text2); }
.page-check-item.checked .page-label { color: var(--text); }

/* ── โควตา Facebook (สีข้อความ JS เป็นคนกำหนดเอง) ── */
.sidebar-quota {
  margin-top: auto;
  padding: 10px 12px;
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
}

/* ══════════════════════════════════════════════════════════════ */
/* ── Content Header ──────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.content-header {
  margin-bottom: 4px;
}
.content-header h1 {
  font-family: var(--font);
  font-size: var(--fs-2xl);
  font-weight: 600;
  line-height: 1.3;
}
.content-header p {
  color: var(--text2);
  font-size: var(--fs-md);
  margin-top: 2px;
}

/* ══════════════════════════════════════════════════════════════ */
/* ── Buttons ─────────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border: none;
  border-radius: var(--radius-s);
  font-size: var(--fs-md);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font);
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary {
  background: var(--primary-g);
  color: var(--on-primary);
  box-shadow: 0 6px 22px var(--primary-glow), inset 0 1px 0 rgba(255,255,255,.4);
  border-radius: 999px;
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 10px 32px rgba(242,195,15,.4), inset 0 1px 0 rgba(255,255,255,.4);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-lg {
  height: 48px;
  padding: 0 30px;
  font-size: var(--fs-md);
  border-radius: 999px;
}
.btn-ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border-h);
  font-weight: 500;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface3);
  border-color: var(--border-strong);
}
.btn-sm { height: 34px; padding: 0 14px; font-size: var(--fs-sm); border-radius: var(--radius-xs); }
.btn-danger { color: var(--danger); background: var(--danger-bg); border-color: rgba(248,113,113,.22); }
.btn-danger:hover:not(:disabled) { background: rgba(248,113,113,.16); border-color: rgba(248,113,113,.4); }

/* ══════════════════════════════════════════════════════════════ */
/* ── Grid & Stack Utilities ──────────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  align-items: start;
}
.grid-2-sm {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: 16px; }
.inline-settings {
  display: flex;
  gap: 24px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.inline-settings .field { min-width: 180px; }

@media (max-width: 1180px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 500px) {
  .grid-2-sm { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════ */
/* ── Cards ───────────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 20px;
}
.card-ico {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--primary-soft);
  color: var(--primary-h);
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════ */
/* ── Form Fields ─────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lbl { font-size: var(--fs-sm); color: var(--text2); font-weight: 500; }
.req { color: var(--danger); }

.inp {
  width: 100%;
  min-height: 44px;
  background: var(--bg2);
  border: 1px solid var(--border-h);
  border-radius: var(--radius-s);
  color: var(--text);
  font-size: var(--fs-lg);
  padding: 10px 14px;
  outline: none;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.inp:hover { border-color: var(--border-strong); }
.inp:focus {
  border-color: var(--primary-line);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.inp::placeholder { color: var(--muted); }
.inp-select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a8a498' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}
.inp-select option { background: var(--surface2); color: var(--text); }
.inp-textarea { resize: vertical; min-height: 84px; line-height: 1.6; }
input[type="datetime-local"].inp,
input[type="date"].inp { color-scheme: var(--scheme); }

/* ปุ่ม "Choose file" ของเบราว์เซอร์ → ปุ่มสไตล์เดียวกับแอป */
input[type="file"].inp { padding: 5px 8px; color: var(--text2); font-size: var(--fs-sm); cursor: pointer; }
input[type="file"].inp::file-selector-button {
  height: 30px;
  margin-right: 12px;
  padding: 0 14px;
  border: 1px solid var(--border-h);
  border-radius: 8px;
  background: var(--surface3);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
input[type="file"].inp::file-selector-button:hover { background: var(--surface2); }

.row-gap { display: flex; gap: 8px; }
.row-gap .inp { flex: 1; }

/* ══════════════════════════════════════════════════════════════ */
/* ── Toggle Switch ───────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.toggle-sw {
  width: 44px; height: 26px;
  background: var(--surface3);
  border-radius: 999px;
  position: relative;
  transition: background .2s, border-color .2s;
  flex-shrink: 0;
  border: 1px solid var(--border-h);
}
.toggle-sw::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  background: var(--knob-off);
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform .25s var(--ease), background .2s;
}
.toggle-row input:checked + .toggle-sw {
  background: var(--primary);
  border-color: var(--primary);
}
.toggle-row input:checked + .toggle-sw::after {
  transform: translateX(18px);
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.toggle-row input:focus-visible + .toggle-sw { outline: 2px solid var(--primary); outline-offset: 2px; }
.toggle-txt { font-size: var(--fs-md); font-weight: 500; color: var(--text); min-width: 0; }
.toggle-txt small { display: block; font-size: var(--fs-xs); font-weight: 400; color: var(--muted); line-height: 1.5; }
.tag-exp {
  display: inline-block;
  margin-left: 8px;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 18px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--warn);
  background: var(--warn-bg);
  vertical-align: 1px;
}
.tr-ico {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface2);
  color: var(--text2);
  flex-shrink: 0;
  transition: background .2s, color .2s;
}
.toggle-row:has(input:checked) .tr-ico { background: var(--primary-soft); color: var(--primary-h); }

.sched-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 0 2px;
}
.sched-datetime {
  flex: 1;
  min-width: 180px;
}
.comment-block {
  width: 100%;
  padding: 4px 0 10px;
}

/* กลุ่มตัวเลือกเสริม (ตั้งเวลา / ซ่อน / คอมเมนต์แรก) — แถวรายการ สวิตช์อยู่ขวา */
.setting-group {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg2);
  overflow: hidden;
}
.setting-group > * + * { border-top: 1px solid var(--border); }
.setting-group .sched-row { display: flex; flex-wrap: wrap; gap: 0; padding: 0; }
.setting-group .toggle-row { flex: 1 1 100%; padding: 14px 16px; transition: background .15s; }
.setting-group .toggle-row:hover { background: var(--hover-soft); }
.setting-group .toggle-row .tr-ico { order: 0; }
.setting-group .toggle-row .toggle-txt { order: 1; flex: 1; }
.setting-group .toggle-row .toggle-sw { order: 2; }
.setting-group .sched-datetime,
.setting-group .comment-block {
  flex: 1 1 100%;
  padding: 14px 16px 16px;
  background: var(--inset-bg);
}
.setting-group .sched-datetime { border-top: 1px solid var(--border); }

/* ── OG Preview (legacy) ── */
.og-preview {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
}
.og-site  { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.og-title { font-weight: 700; font-size: var(--fs-sm); margin: 4px 0; }
.og-desc  { font-size: var(--fs-xs); color: var(--muted); }

/* ══════════════════════════════════════════════════════════════ */
/* ── Facebook Post Preview ───────────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.fb-preview-card-wrap {
  position: sticky;
  top: 24px;
}
@media (max-width: 1180px) {
  .fb-preview-card-wrap { position: static; }
}
.fb-preview {
  background: var(--fb-bg);
  border-radius: 16px;
  overflow: hidden;
  font-family: Helvetica, Arial, sans-serif;
  border: 1px solid var(--fb-line);
}
.fb-preview-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 8px;
}
.fb-preview-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--fb-avatar);
  flex-shrink: 0;
}
.fb-preview-page {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--fb-text);
}
.fb-preview-time {
  font-size: var(--fs-xs);
  color: var(--fb-sub);
}
.fb-preview-msg {
  padding: 4px 16px 12px;
  font-size: var(--fs-md);
  color: var(--fb-text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.fb-preview-msg:empty { display: none; }
.fb-preview-card {
  border-top: 1px solid var(--fb-card);
  cursor: pointer;
}
.fb-preview-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  background:
    radial-gradient(circle at 24% 22%, rgba(242,195,15,.32) 0, transparent 42%),
    radial-gradient(circle at 78% 74%, rgba(31,138,112,.36) 0, transparent 48%),
    var(--fb-img);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.fb-preview-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.fb-preview-img:hover {
  opacity: .85;
}
.fb-preview-img-placeholder {
  font-size: var(--fs-sm);
  color: var(--fb-faint);
  cursor: pointer;
}
.fb-preview-card-body {
  background: var(--fb-card2);
  padding: 12px 16px;
}
.fb-preview-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.fb-preview-domain {
  font-size: var(--fs-xs);
  color: var(--fb-sub);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.fb-preview-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--fb-text);
  line-height: 1.3;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.fb-preview-title:empty { display: none; }
.fb-preview-desc {
  font-size: var(--fs-sm);
  color: var(--fb-sub);
  line-height: 1.4;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.fb-preview-desc:empty { display: none; }
.fb-preview-cta {
  display: flex;
  flex-shrink: 0;
}
.fb-preview-cta span {
  display: inline-block;
  background: var(--fb-btn);
  color: var(--fb-text);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 8px;
  white-space: nowrap;
}
.fb-preview-cta:empty,
.fb-preview-cta.hidden { display: none; }

/* ══════════════════════════════════════════════════════════════ */
/* ── Action Bar (ปุ่มโพสลอยติดขอบล่าง) ─────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.action-bar {
  position: sticky;
  bottom: 16px;
  z-index: 20;
  margin-top: 4px;
  padding: 10px;
  border-radius: 28px;
  background: var(--bar);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-h);
  box-shadow: 0 16px 48px rgba(0,0,0,.55);
}
.btn-post {
  width: 100%;
  height: 52px;
  padding: 0 24px;
  font-size: var(--fs-lg);
  border-radius: 999px;
  gap: 12px;
}
.btn-post > span:first-child {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(26,20,3,.14);
  font-size: var(--fs-lg);
  line-height: 1;
}

/* ══════════════════════════════════════════════════════════════ */
/* ── Mode Content (Card Link / Photos) ───────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.mode-content { display: none; }
.mode-content.active { display: flex; flex-direction: column; gap: 20px; }

/* ══════════════════════════════════════════════════════════════ */
/* ── Progress ────────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.progress-track {
  height: 6px;
  background: var(--surface3);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}
.progress-fill {
  height: 100%;
  background: var(--primary-g);
  border-radius: 999px;
  width: 0%;
  transition: width .5s ease;
}
.progress-label { font-size: var(--fs-md); font-weight: 600; color: var(--text); text-align: left; }
.progress-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 12px;
  font-size: var(--fs-sm);
}
/* แถวข้อมูลทางเทคนิค (ℹ ... สถานะโพส: published=true ...) — ตัวเล็ก mono สีหม่น */
.progress-log .log-row:not(.log-ok):not(.log-err):not(.log-pending) {
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  padding-block: 3px;
  word-break: break-word;
}

.sched-confirm {
  background: linear-gradient(180deg, rgba(242,195,15,.08), rgba(242,195,15,.03));
  border: 1px solid rgba(242,195,15,.24);
  border-radius: var(--radius);
  padding: 18px 22px;
  font-size: var(--fs-md);
  color: var(--text2);
  line-height: 2;
}
.sched-confirm strong { font-size: var(--fs-lg); font-weight: 600; color: var(--text); }

/* ══════════════════════════════════════════════════════════════ */
/* ── Tabs (Schedule / History) ───────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.tab-nav {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  margin-bottom: 18px;
}
.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  background: none;
  border: none;
  border-radius: 10px;
  color: var(--text2);
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  background: var(--surface3);
  color: var(--text);
  box-shadow: 0 1px 0 var(--fb-line) inset, 0 2px 8px rgba(0,0,0,.35);
}
.tab-btn.active .ic { color: var(--primary-h); }
.badge-count {
  background: var(--primary);
  color: var(--on-primary);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 18px;
  padding: 0 7px;
  border-radius: 999px;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.pane-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.pane-toolbar .inp { width: 150px; min-height: 34px; height: 34px; padding: 0 12px; font-size: var(--fs-sm); border-radius: var(--radius-xs); }
.pane-toolbar .tb-to { font-size: var(--fs-sm); color: var(--muted); }
.pane-toolbar .tb-spacer { flex: 1; }

/* ══════════════════════════════════════════════════════════════ */
/* ── Photo Upload ────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.photo-drop-zone {
  border: 1.5px dashed rgba(242,195,15,.28);
  border-radius: var(--radius);
  padding: 34px 24px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: 16px;
  background: rgba(242,195,15,.025);
}
.photo-drop-zone:hover, .photo-drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(242,195,15,.06);
}
.drop-icon {
  width: 52px; height: 52px;
  margin: 0 auto 12px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: var(--primary-soft);
  color: var(--primary-h);
}
.drop-icon .ic { width: 24px; height: 24px; }
.drop-title { font-size: var(--fs-md); font-weight: 500; color: var(--text); }
.drop-sub { font-size: var(--fs-sm); color: var(--muted); margin-top: 4px; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.photo-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color .18s, box-shadow .18s, transform .18s;
}
.photo-item:hover {
  border-color: var(--border-h);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  transform: translateY(-2px);
}
.photo-img-wrap { position: relative; }
.photo-item img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}
.photo-item textarea {
  width: 100%;
  border: none;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  font-size: var(--fs-sm);
  resize: vertical;
  min-height: 56px;
  font-family: inherit;
  transition: background .15s;
}
.photo-item textarea::placeholder { color: var(--muted); }
.photo-item textarea:focus { outline: none; background: rgba(242,195,15,.04); }
.photo-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: var(--fs-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all .15s;
  opacity: 0;
}
.photo-item:hover .photo-remove { opacity: 1; }
.photo-remove:hover { background: var(--danger); transform: scale(1.1); }
.photo-count {
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.photo-time-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.8));
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 16px 10px 6px;
  text-align: center;
  pointer-events: none;
}
.photo-order {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary-g);
  color: var(--on-primary);
  font-size: var(--fs-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

/* ══════════════════════════════════════════════════════════════ */
/* ── Job Cards ───────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.job-list { display: flex; flex-direction: column; gap: 10px; }
.job-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  transition: border-color .15s;
}
.job-card:hover { border-color: var(--border-h); }
.job-row1 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.job-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  flex-shrink: 0;
}
.jb-sched   { background: var(--warn-bg); color: var(--warn); }
.jb-posting { background: var(--primary-soft); color: var(--primary-h); }
.jb-now     { background: var(--primary-soft); color: var(--primary-h); }
.jb-done    { background: var(--success-bg); color: var(--success); }
.job-link {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.job-link:hover { color: var(--primary-h); text-decoration: underline; }
.job-meta { font-size: var(--fs-xs); color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
.job-preview { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.job-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex-shrink: 0; background: var(--surface3); }
.job-preview-text { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.job-msg { font-size: var(--fs-sm); color: var(--text2); word-break: break-word; }
.job-details { font-size: var(--fs-xs); color: var(--muted); line-height: 1.6; word-break: break-word; }
.job-details b { color: var(--text2); font-weight: 500; }
.job-pages { font-size: var(--fs-xs); color: var(--muted); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.chip { font-size: var(--fs-xs); padding: 2px 9px; border-radius: 999px; font-weight: 500; }
.chip-ok  { background: var(--success-bg); color: var(--success); }
.chip-err { background: var(--danger-bg); color: var(--danger); }
.job-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.job-results { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.res-row { font-size: var(--fs-sm); padding: 6px 12px; border-radius: var(--radius-xs); line-height: 1.6; }
.res-row a { color: var(--primary-h); text-decoration: none; }
.res-row a:hover { text-decoration: underline; }
.res-ok { color: var(--success); background: var(--success-bg); }
.res-fail { color: var(--danger); background: var(--danger-bg); word-break: break-word; }
.hist-del-chk { width: 15px; height: 15px; accent-color: var(--primary); vertical-align: -3px; cursor: pointer; }

.job-page-statuses { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.page-status-chip { font-size: var(--fs-xs); padding: 3px 10px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--border); font-weight: 500; }

/* ══════════════════════════════════════════════════════════════ */
/* ── Live Status Card ────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.live-status-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}
.live-status-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: var(--fs-md);
  font-weight: 600;
}
.live-pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.live-pulse.active {
  background: var(--primary);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242,195,15,.4); }
  50%      { box-shadow: 0 0 0 6px rgba(242,195,15,0); }
}
.live-summary { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.live-badge {
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 3px 11px;
  border-radius: 999px;
}
.lb-done    { background: var(--success-bg); color: var(--success); }
.lb-posting { background: var(--primary-soft); color: var(--primary-h); }
.lb-error   { background: var(--danger-bg); color: var(--danger); }
.lb-waiting { background: var(--hover); color: var(--muted); }

.live-page-list { display: flex; flex-direction: column; gap: 4px; }
.live-page-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius-s);
  font-size: var(--fs-sm);
  background: var(--bg2);
  transition: background .15s;
}
.live-page-row:hover { background: var(--surface3); }
.lp-icon { font-size: var(--fs-md); flex-shrink: 0; }
.lp-name { font-weight: 500; flex: 1; }
.lp-detail { font-size: var(--fs-xs); color: var(--muted); text-align: right; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-done    { box-shadow: inset 3px 0 0 var(--success); }
.lp-error   { box-shadow: inset 3px 0 0 var(--danger); }
.lp-posting { box-shadow: inset 3px 0 0 var(--primary); }
.lp-waiting { box-shadow: inset 3px 0 0 var(--surface3); }

/* ══════════════════════════════════════════════════════════════ */
/* ── Utility / Misc ──────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
.loading-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--surface3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-md);
}

.error-inline {
  color: var(--danger);
  font-size: var(--fs-sm);
  padding: 10px 14px;
  background: var(--danger-bg);
  border: 1px solid rgba(248,113,113,.16);
  border-radius: var(--radius-s);
  width: 100%;
  text-align: center;
}

.log-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  line-height: 1.5;
  padding: 7px 12px;
  border-radius: var(--radius-xs);
  background: var(--bg2);
}
.log-ok  { color: var(--success); background: var(--success-bg); }
.log-err { color: var(--danger); background: var(--danger-bg); }
.log-pending { color: var(--muted); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ══════════════════════════════════════════════════════════════ */
/* ── Responsive ──────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    width: 100%;
    height: auto;
    max-height: 68px;
    bottom: 0;
    top: auto;
    left: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    background: var(--bar-solid);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    flex-direction: row;
    padding: 0;
    overflow: visible;
    z-index: 100;
  }
  .app-layout.sidebar-collapsed .sidebar { width: 100%; }
  .sidebar-brand,
  .sidebar-pages,
  .sidebar-quota,
  .collapse-btn,
  .nav-group-label { display: none; }
  .sidebar-nav {
    flex-direction: row;
    width: 100%;
    justify-content: center;
    padding: 8px;
    gap: 4px;
  }
  .nav-item {
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
    font-size: var(--fs-xs);
    white-space: nowrap;
    text-align: center;
    justify-content: center;
    width: auto;
  }
  .app-layout.sidebar-collapsed .nav-item span:not(.nav-icon) { display: inline; }
  .main-content, .app-layout.sidebar-collapsed .main-content {
    margin-left: 0;
    padding: 20px 16px 96px;
  }
  .action-bar { bottom: 80px; }
}

@media (max-width: 500px) {
  .main-content, .app-layout.sidebar-collapsed .main-content { padding: 16px 12px 96px; }
  .card { padding: 16px; }
  .msg-box { padding: 32px 24px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .content-header h1 { font-size: var(--fs-xl); }
  .pane-toolbar .inp { flex: 1; min-width: 120px; }
  .pane-toolbar .tb-spacer { display: none; }
}

/* ══════════════════════════════════════════════════════════════ */
/* ── Auto Card Link (เมนูใหม่: ลิงก์ Lazada + ข่าว → grid) ────── */
/* ══════════════════════════════════════════════════════════════ */
.ac-status { font-size: var(--fs-sm); color: var(--text2); min-height: 1.2em; line-height: 1.5; word-break: break-word; }
.ac-status.ok { color: var(--success); }
.ac-status.err { color: var(--danger); }
.ac-hint { font-size: var(--fs-sm); color: var(--muted); line-height: 1.6; }
/* [ใหม่] แผง "เบื้องหลัง" ตอนดึงลิงก์โพส Facebook (auto-card.js renderFbSteps) */
.ac-fb-steps { border: 1.5px dashed var(--primary-line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; }
.ac-fb-steps[hidden] { display: none; }
#acLz2Box[hidden], #clLz2Box[hidden] { display: none; } /* [ใหม่] กล่องสินค้าเจ้าของ 2 — .field ตั้ง display:flex ทับ hidden */
.ac-fb-head { font-weight: 600; font-size: var(--fs-sm); }
.ac-fb-head span { font-weight: 400; color: var(--muted); margin-left: 6px; }
.ac-fb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ac-fb-list li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start; font-size: var(--fs-sm); color: var(--muted); }
.ac-fb-dot { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--border-h); display: grid; place-items: center; font-size: 11px; }
.ac-fb-list li.run { color: var(--text); }
.ac-fb-list li.run .ac-fb-dot { border-color: var(--primary); color: var(--primary-h); }
.ac-fb-list li.done { color: var(--text2); }
.ac-fb-list li.done .ac-fb-dot { border-color: var(--success); background: var(--success-bg); color: var(--success); }
.ac-fb-list li.fail { color: var(--text2); }
.ac-fb-list li.fail .ac-fb-dot { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.ac-fb-list small { display: block; color: var(--muted); word-break: break-word; }
.ac-fb-warn { font-size: var(--fs-sm); color: var(--warn); background: var(--warn-bg); border-radius: 8px; padding: 8px 10px; }
.ac-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.ac-thumbs .empty-state { grid-column: 1 / -1; }
.ac-thumb {
  position: relative;
  padding: 0;
  aspect-ratio: 1;
  border-radius: var(--radius-xs);
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  transition: border-color var(--transition);
}
.ac-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ac-thumb:hover { border-color: var(--border-h); }
.ac-thumb.sel { border-color: var(--primary); }
.ac-thumb.bad { opacity: .3; cursor: not-allowed; }
.ac-badge {
  position: absolute; top: 4px; left: 4px;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px;
  background: var(--primary); color: var(--on-primary);
  font-size: var(--fs-xs); font-weight: 700;
  display: none; place-items: center;
}
.ac-thumb.sel .ac-badge { display: grid; }
.ac-templates { display: flex; flex-wrap: wrap; gap: 8px; }
.ac-tpl {
  width: 68px; padding: 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  font: inherit; font-size: var(--fs-xs);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: border-color var(--transition);
}
.ac-tpl:hover { border-color: var(--border-h); }
.ac-tpl svg { width: 100%; height: auto; display: block; }
.ac-tpl rect { fill: var(--surface3); stroke: var(--text2); stroke-width: 40; }
.ac-tpl.sel { border-color: var(--primary); color: var(--text); }
.ac-tpl.sel rect { stroke: var(--primary); }
.ac-preview canvas { width: 100%; height: auto; display: block; border-radius: var(--radius-xs); border: 1px solid var(--border); }
.ac-trend-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.ac-trend-list:empty { display: none; }
.ac-trend-row {
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color var(--transition);
}
.ac-trend-row:hover { border-color: var(--primary-line); }
.ac-trend-title { font-size: var(--fs-md); line-height: 1.5; }
.ac-trend-meta { margin-top: 2px; font-size: var(--fs-xs); color: var(--muted); }
/* จำนวนรูปใน grid 3/4/5 + ปุ่ม 💬 รูปในคอมเมนต์แรก */
.ac-count { display: flex; gap: 8px; }
.ac-count button {
  flex: 1; height: 36px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  font: inherit; font-size: var(--fs-sm); font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.ac-count button:hover { border-color: var(--border-h); color: var(--text); }
.ac-count button.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.ac-cell { position: relative; }
.ac-cell .ac-thumb { display: block; width: 100%; }
.ac-cmt {
  position: absolute; right: 4px; bottom: 4px;
  width: 26px; height: 26px; padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border-h);
  background: rgba(11,11,13,.72);
  font-size: var(--fs-sm); line-height: 1;
  cursor: pointer;
  opacity: .75;
  transition: opacity var(--transition), background var(--transition), border-color var(--transition);
}
.ac-cmt:hover { opacity: 1; }
.ac-cmt.on { opacity: 1; background: var(--primary); border-color: var(--primary); }

/* [ใหม่] Auto Card Link — ร่างที่บันทึกไว้ (คลาสใหม่ทั้งหมด ไม่แตะคลาสเดิม) */
.ac-actions { display: flex; gap: 10px; align-items: center; }
.ac-actions .btn-post { flex: 1 1 auto; width: auto; min-width: 0; }
.ac-draft-save {
  flex: 0 0 auto; height: 52px; padding: 0 22px; border-radius: 999px; gap: 8px; font-size: var(--fs-lg);
  color: var(--primary); border-color: var(--primary-line); background: var(--primary-soft);
}
.ac-draft-count { margin-left: 6px; font-weight: 400; color: var(--text2); font-variant-numeric: tabular-nums; }
.ac-draft-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.ac-draft {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 8px; border-radius: var(--radius-xs); background: var(--surface2); border: 1px solid var(--border);
}
.ac-draft.open { border-color: var(--primary-line); }
.ac-draft-thumbs { display: flex; gap: 4px; align-items: flex-end; }
.ac-draft-grid { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; display: block; background: var(--surface3); }
.ac-draft-cimg {
  width: 28px; height: 28px; border-radius: 6px; object-fit: cover; display: grid; place-items: center;
  background: var(--surface3); color: var(--muted); font-size: var(--fs-xs);
}
.ac-draft-body { min-width: 0; }
.ac-draft-title { font-size: var(--fs-md); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-draft-meta { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-draft-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ac-draft-confirm {
  grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 8px 10px; border-radius: 8px; background: var(--danger-bg); font-size: var(--fs-sm);
}
.ac-draft-confirm span { flex: 1 1 160px; }
.ac-preview img { width: 100%; height: auto; display: block; border-radius: var(--radius-xs); border: 1px solid var(--border); }
/* [ใหม่] ป้ายคอมเมนต์แรก + ปุ่ม "✨ สรุปด้วย AI" */
.ac-label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ac-label-row .lbl { margin-bottom: 0; flex: 1 1 220px; }
.ac-ai-btn { color: var(--primary); border-color: var(--primary-line); background: var(--primary-soft); }
/* [ใหม่] แถวรูปในคอมเมนต์แรก */
.ac-cimg-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: start; }
.ac-cimg-box {
  width: 96px; height: 96px; border-radius: var(--radius-xs); overflow: hidden;
  display: grid; place-items: center; text-align: center; font-size: var(--fs-xs); color: var(--muted);
  background: var(--surface2); border: 1px dashed var(--border-h);
}
.ac-cimg-box.has { border-style: solid; border-color: var(--primary-line); }
.ac-cimg-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 480px) {
  .ac-draft-save { padding: 0 14px; }
  .ac-draft { grid-template-columns: auto minmax(0, 1fr); }
  .ac-draft-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ══════════════════════════════════════════════════════════════ */
/* ── [ใหม่] โหมดสว่าง — ใช้เมื่อ <html data-theme="light"> (ตั้งโดย theme.js)          */
/*    ทุกคู่ตัวอักษร/พื้นผ่าน contrast ≥ 4.5:1 (ตรวจด้วยสคริปต์ 25 ก.ย. 2569)            */
/* ══════════════════════════════════════════════════════════════ */
html[data-theme="light"] {
  --bg:        #f5f4f0;
  --bg2:       #faf9f6;
  --surface:   #ffffff;
  --surface2:  #f1efea;
  --surface3:  #e7e4dd;
  --border:    rgba(27,25,20,.10);
  --border-h:  rgba(27,25,20,.18);
  --border-strong: rgba(27,25,20,.28);
  --hover:     rgba(27,25,20,.04);
  --hover-soft: rgba(27,25,20,.02);
  --inset-bg:  rgba(27,25,20,.03);
  --primary-h: #8a6500;            /* ตัวอักษรเหลืองบนพื้นขาว ต้องเข้มขึ้นถึงจะอ่านได้ */
  --primary-ink: #8a6500;
  --primary-glow: rgba(242,195,15,.30);
  --primary-soft: rgba(242,195,15,.16);
  --primary-line: rgba(176,130,0,.45);
  --success:   #0f7a4f;
  --success-bg:rgba(15,122,79,.10);
  --danger:    #c0362c;
  --danger-bg: rgba(192,54,44,.08);
  --warn:      #a64b06;            /* ผ่าน 4.5:1 บน surface2 */
  --warn-bg:   rgba(180,83,9,.10);
  --text:      #1b1914;
  --text2:     #55514a;
  --muted:     #6b665c;
  --knob-off:  #8f8a7f;
  --bar:       rgba(255,255,255,.86);
  --bar-solid: rgba(255,255,255,.94);
  --scheme:    light;
  --fb-bg: #ffffff; --fb-card: #f0f2f5; --fb-card2: #e4e6eb; --fb-btn: #d8dadf; /* ปุ่ม CTA ในพรีวิวให้เห็นชัดบนพื้นเทาอ่อน */
  --fb-text: #050505; --fb-sub: #65676b; --fb-img: #e9e7e1; --fb-line: rgba(0,0,0,.08);
  --fb-avatar: linear-gradient(140deg, #d8dadf, #c4c7cc); --fb-faint: rgba(0,0,0,.55);
  --shadow:    0 1px 2px rgba(27,25,20,.06), 0 8px 24px rgba(27,25,20,.06);
  --shadow-lg: 0 24px 64px rgba(27,25,20,.14);
  color-scheme: light;
}
/* สีที่ app.js เขียนตรงใน style="" (ไม่แก้ JS) — โหมดสว่างปรับให้อ่านได้บนพื้นขาว */
html[data-theme="light"] [style*="color:#f0a500"] { color: #8a5a00 !important; }
html[data-theme="light"] [style*="color:#e5534b"] { color: var(--danger) !important; }
/* ตัวอักษรที่ใช้สีเหลืองสดตรง ๆ (อ่านไม่ออกบนพื้นขาว) → เหลืองเข้มในโหมดสว่าง */
html[data-theme="light"] .ac-count button.on,
html[data-theme="light"] .ac-draft-save,
html[data-theme="light"] .ac-ai-btn,
html[data-theme="light"] [style*="color:var(--primary)"] { color: var(--primary-ink) !important; }

/* ── [ใหม่] ปุ่มสลับโหมดมืด/สว่าง (แถบซ้าย เหนือกล่องโควตา) ── */
.theme-toggle {
  margin-top: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 9px 12px;
  font-family: inherit; font-size: var(--fs-sm); color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s);
  cursor: pointer; transition: background .15s, border-color .15s;
}
.theme-toggle:hover { background: var(--surface2); border-color: var(--border-h); }
.theme-toggle-hint { font-size: var(--fs-xs); color: var(--muted); }
.theme-toggle + .sidebar-quota { margin-top: 8px; }
.app-layout.sidebar-collapsed .theme-toggle { justify-content: center; padding: 9px; }
.app-layout.sidebar-collapsed .theme-toggle-hint,
.app-layout.sidebar-collapsed .theme-toggle-text { display: none; }

/* ══════════════════════════════════════════════════════════════ */
/* ── [ใหม่] Dashboard ในแอป (dashboard-app.js) — คลาสใหม่ขึ้นต้น db- ใช้ตัวแปรสีเดิม (มืด/สว่าง) */
/* ══════════════════════════════════════════════════════════════ */
.db-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.db-ranges { display: inline-flex; gap: 4px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 3px; }
.db-ranges button { font-family: inherit; font-size: var(--fs-sm); border: 0; background: none; color: var(--text2); padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.db-ranges button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.db-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .db-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.db-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: grid; gap: 2px; min-width: 0; }
.db-tile span { font-size: var(--fs-sm); color: var(--text2); }
.db-tile b { font-size: var(--fs-2xl); line-height: 1.2; font-variant-numeric: tabular-nums; }
.db-tile small { font-size: var(--fs-xs); color: var(--muted); }
.db-tile.db-hl { border-color: var(--primary-line); }
.db-tile.db-hl b { color: var(--primary-h); }
.db-cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1100px) { .db-cols { grid-template-columns: 1fr; } }
.db-sub { margin-left: auto; font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.db-chart { position: relative; }
.db-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.db-grid { stroke: var(--border); }
.db-axis { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.db-bar { fill: var(--primary); }
/* [ใหม่] กราฟโพส & คลิกต่อวัน — แท่งฟ้า = คลิก (โหมดสว่างใช้ฟ้าเข้มขึ้น) */
#modeDashboard { --db-clk: #3987e5; }
html[data-theme="light"] #modeDashboard { --db-clk: #2a78d6; }
.db-bar-clk { fill: var(--db-clk); }
.db-val { font-size: 10px; fill: var(--text2); font-family: var(--font); }
.db-legend { display: flex; gap: 14px; font-size: var(--fs-sm); color: var(--text2); margin: -4px 0 8px; }
.db-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.db-lg-post { background: var(--primary); }
.db-lg-clk { background: var(--db-clk); }
.db-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.db-tip { position: absolute; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border-h); border-radius: 8px; padding: 6px 10px; font-size: var(--fs-sm); box-shadow: var(--shadow); white-space: nowrap; transform: translate(-50%, -115%); }
.db-bars { display: grid; gap: 10px; }
.db-brow { display: grid; grid-template-columns: minmax(0, 120px) minmax(0, 1fr) 64px; gap: 10px; align-items: center; font-size: var(--fs-sm); }
.db-bname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text2); }
.db-track { height: 10px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.db-fill { height: 100%; background: var(--primary); border-radius: 0 4px 4px 0; }
.db-bval { text-align: right; font-variant-numeric: tabular-nums; }
.db-note { margin-top: 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 10px 12px; font-size: var(--fs-sm); color: var(--text2); line-height: 1.6; }
.db-title-row { align-items: center; }
.db-grow { flex: 1; }
.db-ins-btn { color: var(--primary-h); border-color: var(--primary-line); background: var(--primary-soft); }
.db-tablewrap { overflow-x: auto; margin-top: 8px; }
.db-table { width: 100%; border-collapse: collapse; min-width: 680px; font-size: var(--fs-md); }
.db-table th { text-align: left; font-size: var(--fs-sm); font-weight: 500; color: var(--text2); padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.db-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.db-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.db-table small { font-size: var(--fs-xs); color: var(--muted); }
.db-table .db-err { color: var(--danger); cursor: help; }
.db-nowrap { white-space: nowrap; }
.db-msg { display: block; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-pill { display: inline-block; font-size: var(--fs-xs); border-radius: 999px; padding: 1px 9px; white-space: nowrap; }
.db-ok { color: var(--success); background: var(--success-bg); }
.db-bad { color: var(--danger); background: var(--danger-bg); cursor: help; }
.db-wait { color: var(--warn); background: var(--warn-bg); }
.db-plink { color: var(--primary-h); text-decoration: none; font-size: var(--fs-sm); white-space: nowrap; }
.db-plink:hover { text-decoration: underline; }

/* ── [ใหม่] Dashboard: ปฏิทินเลือกวันที่ + แท็บ โพสล่าสุด/คลิกรายวัน (dashboard-app.js) ── */
.db-range-wrap { position: relative; }
.db-ranges { flex-wrap: wrap; }
.db-cal { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: min(640px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border-h); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 16px; display: grid; gap: 14px; }
.db-cal[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) { .db-cal:not([hidden]) { animation: dbCalIn .16s var(--ease); } @keyframes dbCalIn { from { opacity: 0; transform: translateY(-4px); } } }
.db-cal-top, .db-cal-foot { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.db-cal-foot { border-top: 1px solid var(--border); padding-top: 12px; }
.db-cal-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.db-cal-chips button { font-family: inherit; font-size: var(--fs-xs); border: 1px solid var(--border); background: var(--surface2); color: var(--text2); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.db-cal-chips button:hover { color: var(--text); border-color: var(--border-h); }
.db-cal-legend { font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: 6px; }
.db-cal-legend i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary-h); display: inline-block; }
.db-cal-months { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 600px) { .db-cal-months { grid-template-columns: 1fr; } .db-cal-months .db-m2 { display: none; } }
.db-mhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: var(--fs-md); }
.db-mnav { font-family: inherit; width: 30px; height: 30px; border-radius: var(--radius-xs); border: 1px solid var(--border); background: var(--surface2); color: var(--text); cursor: pointer; }
.db-mnav[disabled] { visibility: hidden; }
.db-grid7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px 0; }
.db-dow { text-align: center; font-size: 11.5px; color: var(--muted); padding: 2px 0 4px; }
.db-day { position: relative; font-family: inherit; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; height: 36px; border: 0; background: none; color: var(--text); cursor: pointer; padding: 0; }
.db-day span { display: grid; place-items: center; width: 34px; height: 34px; margin: 0 auto; border-radius: 999px; }
.db-day:hover span { background: var(--surface3); }
.db-day.out { visibility: hidden; }
.db-day:disabled { opacity: .35; cursor: not-allowed; }
.db-day.today span { box-shadow: inset 0 0 0 1px var(--primary-line); }
.db-day.inrange { background: var(--primary-soft); }
.db-day.start { background: linear-gradient(90deg, transparent 50%, var(--primary-soft) 50%); }
.db-day.end { background: linear-gradient(90deg, var(--primary-soft) 50%, transparent 50%); }
.db-day.start.end { background: none; }
.db-day.start span, .db-day.end span { background: var(--primary); color: var(--on-primary); font-weight: 700; }
.db-day i { position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--primary-h); }
.db-day.start i, .db-day.end i { background: var(--on-primary); }
.db-cal-sum { color: var(--text2); font-size: var(--fs-sm); }
.db-cal-sum b { color: var(--text); }
/* [ใหม่] ปฏิทินหน้า Card Link (cal-picker.js) — ใช้ .db-cal ข้างบน + ส่วนเสริมเหล่านี้ */
.cp-pop { position: fixed; right: auto; top: 0; left: 0; z-index: 1000; max-height: calc(100vh - 32px); overflow: auto; }
.cp-trigger { display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer; }
.cp-trigger .cp-ph { color: var(--muted); }
.pane-toolbar .cp-trigger { width: auto; }
.cp-time { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text2); }
.cp-time .inp-select { width: auto; min-height: 34px; height: 34px; padding: 0 30px 0 10px; font-size: var(--fs-sm); background-position: right 8px center; }
.cp-warn { color: var(--danger, #e5484d); }
.db-cal-btns { display: flex; gap: 8px; }
.db-tabs { display: inline-flex; gap: 4px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 3px; }
.db-tabs button { font-family: inherit; font-size: var(--fs-md); border: 0; background: none; color: var(--text2); padding: 5px 14px; border-radius: var(--radius-xs); cursor: pointer; white-space: nowrap; }
.db-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.db-daily-bar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 8px; }
.db-confirm { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--danger-bg); border-radius: var(--radius-s); padding: 8px 12px; font-size: var(--fs-sm); margin-top: 8px; }
.db-confirm[hidden] { display: none; }
.db-confirm span { flex: 1 1 220px; }
.db-chk { width: 28px; }
.db-table input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; vertical-align: -2px; }
.db-table tr.db-sel td { background: var(--primary-soft); }
/* [แก้] Dashboard: ปุ่มช่วงเวลาชิดขวาตรงขอบการ์ด — เว้นขวา 190px (กันปุ่มมืด/สว่าง ดู .main-content .content-header) เฉพาะเท่าที่จะทับจริง
   ที่ว่างนอกกรอบเนื้อหา (1120px) ต่อข้าง = (100vw − แถบซ้าย − padding 2×40px − 1120px) / 2 · จอกว้าง = 0 · ไม่เกิน 190px เดิม */
.main-content #modeDashboard .content-header.db-head { padding-right: clamp(0px, calc(190px - (100vw - var(--sidebar-w) - 80px - 1120px) / 2), 190px); }
@media (max-width: 768px) { .main-content #modeDashboard .content-header.db-head { padding-right: 0; } }

/* ══════════════════════════════════════════════════════════════ */
/* ── [ใหม่] ปุ่มคู่สลับโหมด มุมขวาบน (.theme-seg ใน main-content, theme.js) */
/* ══════════════════════════════════════════════════════════════ */
.main-content { position: relative; }
.theme-seg {
  position: absolute; top: 28px; right: clamp(16px, 3vw, 40px); z-index: 30;
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface2); border: 1px solid var(--border-h); border-radius: 999px;
}
.theme-seg button {
  font-family: inherit; font-size: var(--fs-sm); font-weight: 500; line-height: 1.4;
  border: 0; background: none; color: var(--text2); padding: 6px 14px; border-radius: 999px; cursor: pointer;
  transition: background .15s, color .15s;
}
.theme-seg button:hover { color: var(--text); }
.theme-seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); font-weight: 600; }
/* เว้นที่ด้านขวาของหัวข้อทุกหน้า ไม่ให้ปุ่มทับชื่อหน้า/ปุ่มของหน้า (เช่น วันนี้/7/30 วัน ของ Dashboard) */
.main-content .content-header { padding-right: 190px; }
@media (max-width: 768px) {
  .theme-seg { position: static; display: flex; width: max-content; margin: 0 0 12px auto; }
  .main-content .content-header { padding-right: 0; }
}

/* ══════════════════════════════════════════════════════════════ */
/* ── [ใหม่] หน้าคอมเมนต์ + ตอบอัตโนมัติ (comments-app.js) — คลาสใหม่ขึ้นต้น cm- */
/* ══════════════════════════════════════════════════════════════ */
.cm-connect { display: grid; gap: 12px; }
.cm-p { color: var(--text2); line-height: 1.6; }
.cm-hint { font-size: var(--fs-sm); color: var(--muted); line-height: 1.6; }
.cm-cols { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1100px) { .cm-cols { grid-template-columns: 1fr; } }
.cm-cols .card { display: grid; gap: 12px; }
.cm-cols .card-title { margin-bottom: 0; }
.cm-title-row { align-items: center; }
.cm-grow { flex: 1; }
.cm-sub { font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.cm-sw { width: 48px; height: 28px; border-radius: 999px; background: var(--surface3); border: 1px solid var(--border-h); position: relative; cursor: pointer; flex: none; transition: background .2s; }
.cm-sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: left .2s; }
.cm-sw[aria-checked="true"] { background: var(--primary); border-color: transparent; }
.cm-sw[aria-checked="true"]::after { left: 23px; }
.cm-state { display: grid; gap: 4px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 10px 12px; font-size: var(--fs-sm); }
.cm-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); margin-right: 6px; vertical-align: 1px; }
.cm-dot.cm-off { background: var(--muted); }
.cm-kpi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cm-kpi div { background: var(--surface2); border-radius: var(--radius-s); padding: 8px 10px; }
.cm-kpi b { display: block; font-size: var(--fs-xl); font-variant-numeric: tabular-nums; }
.cm-kpi span { font-size: var(--fs-xs); color: var(--muted); }
.cm-tpl { display: grid; gap: 8px; }
.cm-tpl-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: start; }
.cm-tpl-row textarea { min-height: 64px; }
.cm-x { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--muted); cursor: pointer; font-family: inherit; }
.cm-x:hover { color: var(--danger); border-color: var(--border-h); }
.cm-save { color: var(--primary-h); border-color: var(--primary-line); background: var(--primary-soft); }
.cm-rule { display: flex; align-items: center; gap: 10px; font-size: var(--fs-md); flex-wrap: wrap; }
.cm-rule input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; }
.cm-sel { width: auto; min-height: 36px; font-size: var(--fs-sm); padding-block: 6px; }
.cm-posts { display: grid; gap: 10px; }
.cm-post { border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface2); overflow: hidden; }
.cm-post-h { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; padding: 10px 12px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.cm-post-h:hover { background: var(--hover); }
.cm-thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--surface3); display: block; }
.cm-post-txt { min-width: 0; }
.cm-post-txt b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-post-txt small { font-size: var(--fs-xs); color: var(--muted); }
.cm-chev { color: var(--muted); }
.cm-cmts { border-top: 1px solid var(--border); background: var(--surface); padding: 10px 12px 12px; display: grid; gap: 12px; }
.cm-c { display: grid; gap: 4px; font-size: var(--fs-md); }
.cm-who { font-weight: 600; }
.cm-who small { font-weight: 400; color: var(--muted); font-size: var(--fs-xs); margin-left: 6px; }
.cm-reply { margin-left: 16px; padding: 6px 10px; border-left: 2px solid var(--primary-line); background: var(--primary-soft); border-radius: 0 8px 8px 0; }
.cm-reply small { color: var(--muted); font-size: var(--fs-xs); }
.cm-manual { display: flex; gap: 6px; margin-left: 16px; }
.cm-manual .inp { min-height: 36px; font-size: var(--fs-md); padding-block: 6px; }
.cm-log { display: grid; max-height: 320px; overflow-y: auto; }
.cm-lg { display: grid; grid-template-columns: 56px auto minmax(0, 1fr); gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.cm-lg:last-child { border-bottom: 0; }
.cm-t { color: var(--muted); font-variant-numeric: tabular-nums; }
.cm-m { color: var(--text2); min-width: 0; overflow-wrap: anywhere; }
.cm-m b { color: var(--text); font-weight: 500; }
.cm-m small { color: var(--muted); }
.cm-pill { display: inline-block; font-size: var(--fs-xs); border-radius: 999px; padding: 1px 9px; white-space: nowrap; }
.cm-ok { color: var(--success); background: var(--success-bg); }
.cm-skip { color: var(--warn); background: var(--warn-bg); }
.cm-bad { color: var(--danger); background: var(--danger-bg); }
/* [ใหม่] ตอบด้วย AI: กล่องในการ์ด 🤖 + ป้ายที่มาของคำตอบใน log + ปุ่มร่าง/ดูเพิ่ม */
.cm-ai-box { display: grid; gap: 8px; border: 1px solid var(--primary-line); background: var(--primary-soft); border-radius: var(--radius-s); padding: 10px 12px; }
.cm-ai { color: var(--primary-h); background: var(--primary-soft); border: 1px solid var(--primary-line); }
.cm-tplsrc { color: var(--text2); background: var(--surface3); }
.cm-manual .cm-draft { color: var(--primary-h); border-color: var(--primary-line); background: var(--primary-soft); white-space: nowrap; }
.cm-more { justify-self: start; }
.cm-foot { font-size: var(--fs-sm); color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cm-legacy { margin-top: 8px; }
.cm-legacy > summary { cursor: pointer; color: var(--text2); font-size: var(--fs-sm); padding: 8px 0; }
.cm-legacy[open] > summary { margin-bottom: 12px; }

/* ── [โหมดลาว] Modal ตั้งค่าเครือข่าย — ใช้ปุ่มสลับแบบ .tab-nav/.tab-btn เดิม ── */
.net-form { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 12px; }
.net-seg { display: flex; width: 100%; margin-bottom: 0; }
.net-seg .tab-btn { flex: 1; justify-content: center; position: relative; }
.net-seg input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.net-seg .tab-btn:has(input:checked) {
  background: var(--surface3);
  color: var(--text);
  box-shadow: 0 1px 0 var(--fb-line) inset, 0 2px 8px rgba(0,0,0,.35);
}
.net-seg .tab-btn:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.net-field { display: flex; flex-direction: column; gap: 6px; }
.msg-box .net-hint { font-size: var(--fs-sm); color: var(--muted); line-height: 1.6; margin: 0; }
.net-form .btn { width: 100%; justify-content: center; }

/* ── [ใหม่] Card Link โหมด "จากร่าง" (draft-schedule.js) ─────────────────── */
/* .grid-2 / .action-bar / .stack / .card ตั้ง display เอง → ต้องบอกให้ซ่อนเมื่อมี hidden */
#modeCardlink > .grid-2[hidden], #modeCardlink > .action-bar[hidden], #dsView[hidden], #dsProg[hidden] { display: none; }
.ds-seg { display: inline-flex; align-self: flex-start; gap: 4px; padding: 4px; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; }
.ds-seg button { border: 0; background: none; color: var(--text2); font: inherit; padding: 8px 16px; border-radius: 9px; cursor: pointer; }
.ds-seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.ds-seg button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.ds-card { display: grid; gap: 12px; }
.ds-title { margin-bottom: 0; align-items: center; flex-wrap: wrap; }
.ds-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-h); font-size: var(--fs-sm); flex: none; }
.ds-grow { flex: 1; min-width: 0; }
.ds-sub { font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.ds-drafts { display: grid; gap: 8px; max-height: 420px; overflow-y: auto; }
.ds-draft { display: grid; grid-template-columns: auto 56px minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface2); cursor: pointer; }
.ds-draft.bad { opacity: .65; cursor: not-allowed; }
.ds-draft input { accent-color: var(--primary); width: 16px; height: 16px; }
.ds-thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--surface3); display: block; }
.ds-draft-txt { min-width: 0; display: grid; gap: 2px; }
.ds-draft-txt b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-draft-txt small { font-size: var(--fs-xs); color: var(--muted); }
.ds-done { color: var(--success); }
.ds-bad { color: var(--warn) !important; }
.ds-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.ds-check { display: flex; align-items: center; gap: 8px; font-size: var(--fs-md); }
.ds-check input { accent-color: var(--primary); width: 16px; height: 16px; }
.ds-quota { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--surface2); border-radius: var(--radius-s); padding: 10px 12px; font-size: var(--fs-sm); }
.ds-tbl { overflow-x: auto; }
.ds-tbl table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.ds-tbl th, .ds-tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.ds-tbl th { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.ds-td-title { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.ds-td-time { color: var(--primary-h); }
