/* Fanpage Auto Poster — giao diện dùng chung cho bản Python và PHP */
:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #171a2b;
  --text-2: #4b5170;
  --muted: #8a90aa;
  --border: #e7e9f2;
  --border-strong: #d6d9e6;
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-soft: #eef0ff;
  --primary-text: #ffffff;
  --fb: #1877f2;
  --ok: #15a34a;      --ok-soft: #e8f8ee;
  --warn: #c2700a;    --warn-soft: #fff4e2;
  --danger: #dc2f45;  --danger-soft: #ffecef;
  --info: #2563eb;    --info-soft: #e8f0ff;
  --violet-soft: #f3ebff;
  --shadow-sm: 0 1px 2px rgba(23, 26, 43, .06);
  --shadow: 0 4px 16px rgba(23, 26, 43, .07), 0 1px 3px rgba(23, 26, 43, .05);
  --shadow-lg: 0 24px 60px rgba(23, 26, 43, .18);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar: 248px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1120; --surface: #171a2e; --surface-2: #1d2138; --text: #eceefa; --text-2: #b6bbd6; --muted: #7e84a3;
    --border: #262a45; --border-strong: #343958; --primary: #7c74ff; --primary-2: #a78bfa; --primary-soft: #23244a;
    --ok: #4ade80; --ok-soft: #12301f; --warn: #fbbf24; --warn-soft: #33270f; --danger: #fb7185; --danger-soft: #3a1720;
    --info: #60a5fa; --info-soft: #152844; --violet-soft: #2a2148;
    --shadow-sm: none; --shadow: 0 1px 0 rgba(255,255,255,.03); --shadow-lg: 0 24px 60px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1120; --surface: #171a2e; --surface-2: #1d2138; --text: #eceefa; --text-2: #b6bbd6; --muted: #7e84a3;
  --border: #262a45; --border-strong: #343958; --primary: #7c74ff; --primary-2: #a78bfa; --primary-soft: #23244a;
  --ok: #4ade80; --ok-soft: #12301f; --warn: #fbbf24; --warn-soft: #33270f; --danger: #fb7185; --danger-soft: #3a1720;
  --info: #60a5fa; --info-soft: #152844; --violet-soft: #2a2148;
  --shadow-sm: none; --shadow: 0 1px 0 rgba(255,255,255,.03); --shadow-lg: 0 24px 60px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.55 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
code { font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 6px; word-break: break-all; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- khung ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 18px 14px;
  background: var(--surface); border-right: 1px solid var(--border); z-index: 20; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.logo-mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-size: 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 6px 16px rgba(79, 70, 229, .35); }
.logo b { display: block; font-size: 15px; line-height: 1.2; }
.logo small { color: var(--muted); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text-2);
  font-weight: 500; cursor: pointer; transition: background .15s, color .15s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-badge { margin-left: auto; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px;
  padding: 1px 7px; min-width: 20px; text-align: center; }
.nav-badge:empty { display: none; }
.nav-badge.warn { background: var(--danger); }
/* nhóm fanpage */
.group-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: -6px 0 18px; }
.gdot { width: 10px; height: 10px; border-radius: 3px; background: var(--pc); flex: none; }
.gdot.lg { width: 14px; height: 14px; border-radius: 4px; }
.gcount { font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--text-2); border-radius: 99px; padding: 0 6px; }
.chip.on .gcount { background: var(--primary); color: #fff; }
.group-section { margin-bottom: 26px; }
.group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 2px solid color-mix(in srgb, var(--pc) 35%, transparent); flex-wrap: wrap; }
.group-head h2 { margin: 0; font-size: 17px; }
.group-head .actions { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.group-tag { display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; font-size: 11.5px; font-weight: 600; color: color-mix(in srgb, var(--pc) 75%, var(--text));
  background: color-mix(in srgb, var(--pc) 14%, transparent); padding: 1px 8px; border-radius: 99px; }
.health-item.link { cursor: pointer; border-radius: 6px; } .health-item.link:hover { color: var(--primary); }
.secret { position: relative; }
.secret .input { padding-right: 44px; }
.secret button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.saved { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ok); background: var(--ok-soft);
  padding: 1px 8px; border-radius: 99px; margin-left: 6px; }
.saved svg { width: 13px; height: 13px; }
.guide { margin: 0; padding-left: 20px; color: var(--text-2); line-height: 1.8; }
.guide b { color: var(--text); }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row code { flex: 1; padding: 8px 10px; font-size: 12.5px; }
.sticky-actions { position: sticky; bottom: 0; display: flex; gap: 10px; justify-content: flex-end; padding: 14px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.test-result { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; }
.test-result.ok { background: var(--ok-soft); color: var(--ok); } .test-result.bad { background: var(--danger-soft); color: var(--danger); }
.test-result .detail { color: var(--text-2); font-size: 12.5px; word-break: break-word; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.health { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: grid; gap: 6px; }
.health-title { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.health-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.side-actions { display: flex; gap: 6px; }
.side-actions > * { flex: 1; }

.main { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 60px; }
.view { display: none; max-width: 1320px; margin: 0 auto; animation: fade .2s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; line-height: 1.2; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- nút & ô nhập ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: transform .08s, box-shadow .15s, background .15s, border-color .15s; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); box-shadow: 0 4px 12px rgba(79, 70, 229, .25); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ai { background: linear-gradient(135deg, var(--primary), var(--primary-2)); border: 0; color: #fff; box-shadow: 0 6px 18px rgba(124, 58, 237, .3); }
.btn.ai:hover { filter: brightness(1.07); }
.btn.fb { background: var(--fb); border-color: var(--fb); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.icon { width: 40px; padding: 0; } .btn.icon.sm { width: 32px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea { width: 100%; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
.input, .select { height: 42px; }
.textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input:disabled, .textarea:disabled, .select:disabled { background: var(--surface-2); color: var(--muted); }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 38px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: var(--border-strong); position: relative;
  cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(16px); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: all .15s; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.chip .x { opacity: .6; } .chip .x:hover { opacity: 1; }
.chip.static { cursor: default; } .chip.static:hover { border-color: var(--border-strong); color: var(--text-2); }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; height: 32px; padding: 0 13px; border-radius: 8px; font-weight: 600; font-size: 13px;
  color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.seg .count { font-size: 11px; background: var(--border); color: var(--text-2); border-radius: 99px; padding: 0 6px; font-weight: 700; }
.seg button.on .count { background: var(--primary); color: #fff; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.draft { background: var(--surface-2); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border); }
.pill.approved { background: var(--info-soft); color: var(--info); }
.pill.scheduled { background: var(--warn-soft); color: var(--warn); }
.pill.publishing { background: var(--violet-soft); color: var(--primary-2); }
.pill.published, .pill.active { background: var(--ok-soft); color: var(--ok); }
.pill.failed, .pill.token_error { background: var(--danger-soft); color: var(--danger); }
.pill.paused { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none;
  background: var(--pc, var(--primary)); font-size: 14px; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.lg { width: 52px; height: 52px; font-size: 20px; }

/* ---------- thẻ ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.card-head .actions { margin-left: auto; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.stat { display: flex; gap: 14px; align-items: center; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat-icon.violet { background: var(--violet-soft); color: var(--primary-2); }
.stat-icon.warn { background: var(--warn-soft); color: var(--warn); }
.stat-icon.ok { background: var(--ok-soft); color: var(--ok); }
.stat-icon.danger { background: var(--danger-soft); color: var(--danger); }
.stat b { font-size: 26px; line-height: 1; letter-spacing: -.02em; display: block; }
.stat span { color: var(--muted); font-size: 13px; }

.hero { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border: 0; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255,255,255,.08); }
.hero h2 { margin: 0 0 4px; font-size: 20px; }
.hero p { margin: 0 0 14px; opacity: .85; }
.hero .textarea { background: rgba(255,255,255,.96); color: #171a2b; border: 0; min-height: 70px; }
.hero .select { background: rgba(255,255,255,.96); color: #171a2b; border: 0; width: auto; min-width: 200px; }
.hero .btn { background: #fff; color: var(--primary); border: 0; }

.steps { display: grid; gap: 10px; }
.step { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.step-num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
  background: var(--surface); border: 2px solid var(--border-strong); color: var(--muted); }
.step.done .step-num { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.done .step-title { text-decoration: line-through; color: var(--muted); }
.step-title { font-weight: 600; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 99px; transition: width .4s; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 6px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 8px; }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { font-size: 12.5px; color: var(--muted); }
.when { font-size: 12.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; text-align: right; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .empty-icon { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); }
.empty .empty-icon svg { width: 28px; height: 28px; }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 16px; }
.empty p { margin: 0 0 16px; }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 13.5px; margin-bottom: 16px; }
.notice svg { margin-top: 1px; }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice b { color: inherit; }
.notice .notice-body { color: var(--text-2); } .notice .notice-body b { color: var(--text); }

/* ---------- danh sách bài ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 340px; }
.toolbar .select { width: auto; min-width: 170px; }
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.post-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column; box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s, border-color .15s; }
.post-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.post-thumb { aspect-ratio: 16 / 9; background: var(--surface-2); position: relative; overflow: hidden; display: grid; place-items: center; color: var(--muted); }
.post-thumb img { width: 100%; height: 100%; object-fit: cover; }
.post-thumb .ph { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; padding: 0 18px; text-align: center;
  background: linear-gradient(135deg, color-mix(in srgb, var(--pc) 16%, transparent), transparent); width: 100%; height: 100%; justify-content: center; }
.post-thumb .ph q { font-style: italic; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; quotes: none; }
.post-thumb .count { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px; display: flex; gap: 4px; align-items: center; }
.post-thumb .count svg { width: 13px; height: 13px; }
.post-thumb .pill { position: absolute; left: 10px; top: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.post-thumb .pill.draft { background: var(--surface); }
.post-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.post-title { font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-top: auto; }
.post-meta .page-name { font-weight: 600; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-error { font-size: 12px; color: var(--danger); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- khung soạn thảo (trượt từ phải) ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(15, 17, 32, .45); backdrop-filter: blur(2px); z-index: 40; animation: fadeIn .15s; }
@keyframes fadeIn { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(1180px, 100vw); background: var(--bg); z-index: 41; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: slideIn .22s cubic-bezier(.2,.8,.2,1); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 14px 22px; background: var(--surface); border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { flex: 1; overflow: auto; padding: 22px; }
.drawer-foot { display: flex; align-items: center; gap: 10px; padding: 12px 22px; background: var(--surface); border-top: 1px solid var(--border); flex-wrap: wrap; }
.drawer-foot .spacer { flex: 1; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 22px; align-items: start; }
@media (max-width: 1080px) { .editor { grid-template-columns: 1fr; } }
.editor .preview-col { position: sticky; top: 0; display: flex; flex-direction: column; gap: 16px; }
.section-title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 12px; }
.section-title .hint { font-weight: 400; margin-left: auto; }
.cap-wrap { position: relative; }
/* nơi đăng của bài */
.dest-groups { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.dest-groups svg { width: 15px; height: 15px; color: var(--info); }
.dest-groups .pill { font-size: 11px; padding: 1px 8px; }
.dest-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.dest-row:last-of-type { border-bottom: 0; }
.dest-row .title { font-weight: 600; font-size: 13.5px; }
.dest-row .sub { font-size: 12px; color: var(--muted); }
.ok-text { color: var(--ok) !important; font-weight: 600; }
/* trình soạn thảo: thanh công cụ */
.editor-toolbar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; padding: 6px; margin-bottom: 8px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.editor-toolbar .btn.sm { height: 32px; }
.tb { min-width: 34px; height: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer;
  font-size: 15px; font-family: inherit; display: inline-flex; align-items: center; justify-content: center; }
.tb:hover { background: var(--surface); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.tb b { font-weight: 800; } .tb i { font-family: Georgia, serif; } .tb sub { font-size: 10px; }
.tb-sep { width: 1px; height: 22px; background: var(--border-strong); margin: 0 6px; }
.tb-quick { display: inline-flex; flex-wrap: wrap; margin-left: auto; }
.cap-wrap .textarea { font-size: 15px; }
#pv-mode { flex-wrap: nowrap; padding: 2px; }
#pv-mode button { height: 28px; padding: 0 10px; font-size: 12.5px; white-space: nowrap; }
.preview-col .section-title { flex-wrap: wrap; row-gap: 8px; }
/* xem trước kiểu điện thoại */
.fb.mobile { max-width: 380px; margin: 0 auto; }
.fb.mobile .fb-text { font-size: 15px; }
/* bảng chọn emoji */
.cap-tools { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; margin-bottom: 8px; }
.cap-tools .btn { margin-right: 6px; }
.emo { border: 0; background: transparent; font-size: 22px; line-height: 1; width: 38px; height: 38px; border-radius: 8px; cursor: pointer;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
.emo:hover { background: var(--surface-2); transform: scale(1.15); }
.emo.quick { font-size: 18px; width: 32px; height: 32px; }
.emoji-pop { position: absolute; z-index: 75; width: min(360px, calc(100vw - 20px)); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: 10px; animation: pop .12s; }
.emoji-pop .emo-search { height: 36px; margin-bottom: 8px; }
.emo-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-bottom: 6px; overflow-x: auto; }
.emo-tabs button { border: 0; background: transparent; font-size: 18px; padding: 4px 6px; border-radius: 8px; cursor: pointer; opacity: .55; }
.emo-tabs button.on, .emo-tabs button:hover { opacity: 1; background: var(--surface-2); }
.emo-title { margin: 2px 4px 4px; font-weight: 600; }
.emo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); max-height: 240px; overflow-y: auto; }
.cap-wrap .textarea { min-height: 220px; padding-bottom: 30px; }
.cap-count { position: absolute; right: 12px; bottom: 9px; font-size: 12px; color: var(--muted); background: var(--surface); padding: 0 4px; }
.ai-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.ai-row .label-ai { display: flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; color: var(--primary-2); }
.chip.ai-chip:hover { border-color: var(--primary-2); color: var(--primary-2); background: var(--violet-soft); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 42px; padding: 5px 8px; border: 1px solid var(--border-strong);
  border-radius: 10px; background: var(--surface); cursor: text; }
.tags:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.tags .chip { height: 28px; background: var(--primary-soft); color: var(--primary); border-color: transparent; padding: 0 8px 0 10px; }
.tags input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 120px; height: 28px; }

.images { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.img-tile { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); cursor: grab; }
.img-tile img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.img-tile.dragging { opacity: .4; } .img-tile.over { outline: 3px solid var(--primary); outline-offset: -3px; }
.img-tile .num { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.img-tile .tools { position: absolute; inset: auto 0 0 0; display: flex; justify-content: center; gap: 4px; padding: 6px;
  background: linear-gradient(transparent, rgba(0,0,0,.6)); opacity: 0; transition: opacity .15s; }
.img-tile:hover .tools, .img-tile:focus-within .tools { opacity: 1; }
.img-tile .tools button { width: 30px; height: 30px; border-radius: 8px; border: 0; background: rgba(255,255,255,.92); color: #171a2b; cursor: pointer;
  display: grid; place-items: center; }
.img-tile .tools button:hover { background: #fff; } .img-tile .tools button svg { width: 15px; height: 15px; }
.dropzone { aspect-ratio: 1; border-radius: 12px; border: 2px dashed var(--border-strong); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 6px; color: var(--muted); font-size: 12.5px; text-align: center; cursor: pointer; padding: 8px; transition: all .15s; background: var(--surface); }
.dropzone:hover, .dropzone.over { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.dropzone.ai:hover { border-color: var(--primary-2); color: var(--primary-2); background: var(--violet-soft); }

.locked-banner { display: flex; gap: 12px; align-items: center; }

/* xem trước kiểu Facebook */
.fb { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; color: var(--text); box-shadow: var(--shadow); }
.fb-head { display: flex; gap: 10px; align-items: center; padding: 12px 14px; }
.fb-name { font-weight: 700; font-size: 14px; } .fb-time { font-size: 12px; color: var(--muted); }
.fb-text { padding: 0 14px 12px; white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; line-height: 1.5; }
.fb-text .more { color: var(--muted); font-weight: 600; }
.fb-text .tag { color: var(--fb); }
.fb-media { display: grid; gap: 2px; }
.fb-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fb-media.n1 img { max-height: 440px; }
.fb-media.n2 { grid-template-columns: 1fr 1fr; } .fb-media.n2 img { aspect-ratio: 1; }
.fb-media.n3 { grid-template-columns: 1fr 1fr; } .fb-media.n3 > :first-child { grid-column: span 2; } .fb-media.n3 > :first-child img { aspect-ratio: 2; } .fb-media.n3 img { aspect-ratio: 1; }
.fb-media.n4 { grid-template-columns: 1fr 1fr; } .fb-media.n4 img { aspect-ratio: 1; }
.fb-media .more-img { position: relative; } .fb-media .more-img::after { content: attr(data-more); position: absolute; inset: 0; background: rgba(0,0,0,.45);
  color: #fff; font-size: 28px; font-weight: 700; display: grid; place-items: center; }
.fb-stats { display: flex; justify-content: space-between; padding: 8px 14px; font-size: 13px; color: var(--muted); }
.fb-foot { display: flex; justify-content: space-around; border-top: 1px solid var(--border); margin: 0 10px; padding: 4px 0; }
.fb-foot span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: 13.5px; padding: 6px 10px; }

.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; position: relative; padding-bottom: 14px; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--border); }
.tl-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.tl-icon svg { width: 14px; height: 14px; }
.tl-icon.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tl-icon.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tl-icon.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.tl-icon.violet { background: var(--violet-soft); color: var(--primary-2); border-color: transparent; }
.tl-body { min-width: 0; flex: 1; }
.tl-title { font-weight: 600; font-size: 13.5px; }
.tl-detail { font-size: 12.5px; color: var(--muted); word-break: break-word; }
.tl-time { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- lịch ---------- */
.cal-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-bar h2 { margin: 0 8px; font-size: 18px; min-width: 150px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; font-size: 12.5px; color: var(--text-2); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend span::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--pc); }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.calendar .dow { padding: 10px; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border); background: var(--surface-2); }
.calendar .day { min-height: 118px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; transition: background .15s; position: relative; }
.calendar .day:nth-child(7n) { border-right: 0; }
.calendar .day:hover { background: var(--surface-2); }
.calendar .day:hover .add { opacity: 1; }
.calendar .day .add { position: absolute; right: 6px; top: 6px; opacity: 0; color: var(--primary); }
.calendar .day.other { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.calendar .day.other .dnum { opacity: .45; }
.calendar .day.past .dnum { color: var(--muted); }
.calendar .dnum { font-size: 13px; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.calendar .day.today .dnum { background: var(--primary); color: #fff; }
.cal-post { display: flex; align-items: center; gap: 5px; text-align: left; font-size: 11.5px; font-weight: 500; padding: 3px 6px; border-radius: 6px; border: 0; cursor: pointer;
  background: color-mix(in srgb, var(--pc) 14%, var(--surface)); color: var(--text); overflow: hidden; white-space: nowrap; width: 100%; }
.cal-post b { font-weight: 700; color: color-mix(in srgb, var(--pc) 80%, var(--text)); }
.cal-post span { overflow: hidden; text-overflow: ellipsis; }
.cal-post.published { opacity: .55; } .cal-post.failed { box-shadow: inset 2px 0 0 var(--danger); }
.cal-more { font-size: 11.5px; color: var(--muted); padding-left: 6px; }

/* ---------- tạo bài ---------- */
.create-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .create-grid { grid-template-columns: 1fr; } }
.cstep { display: flex; gap: 14px; padding-bottom: 20px; }
.cstep-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary);
  font-weight: 700; font-size: 13px; flex: none; }
.cstep-body { flex: 1; min-width: 0; }
.cstep-title { font-weight: 700; margin: 3px 0 10px; }
.page-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.page-pick .chip { height: 40px; padding: 0 14px 0 6px; }
.page-pick .chip .avatar { width: 28px; height: 28px; font-size: 12px; }
.range { width: 100%; accent-color: var(--primary); }
.target-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .target-pick { grid-template-columns: 1fr; } }
.target { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px 14px; border-radius: 12px; cursor: pointer; text-align: left;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text); transition: all .15s; }
.target svg { color: var(--muted); }
.target b { font-size: 14px; }
.target span { font-size: 12px; color: var(--muted); }
.target:hover { border-color: var(--primary); }
.target.on { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft); }
.target.on svg, .target.on b { color: var(--primary); }

/* ---------- fanpage ---------- */
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.page-card { display: flex; flex-direction: column; gap: 14px; }
.page-card .top { display: flex; gap: 12px; align-items: center; }
.page-card .top { align-items: flex-start; }
.page-card .top .pill { margin-top: 4px; }
.page-card .name { font-weight: 700; font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.page-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.page-stats div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; text-align: center; }
.page-stats b { display: block; font-size: 18px; } .page-stats span { font-size: 11.5px; color: var(--muted); }
.connect-hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.connect-hero .fb-logo { width: 56px; height: 56px; border-radius: 16px; background: var(--fb); color: #fff; display: grid; place-items: center;
  font: 800 30px/1 Helvetica, Arial, sans-serif; flex: none; }
details.more summary { cursor: pointer; color: var(--text-2); font-weight: 600; list-style: none; display: flex; align-items: center; gap: 6px; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary svg { transform: rotate(90deg); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; }
.stepper button { width: 38px; height: 40px; border: 0; background: var(--surface-2); cursor: pointer; font-size: 18px; color: var(--text-2); }
.stepper input { width: 52px; height: 40px; border: 0; text-align: center; background: var(--surface); font-weight: 700; outline: 0; }

/* ---------- hộp thoại ---------- */
.modal-wrap { position: fixed; inset: 0; display: grid; place-items: center; z-index: 60; padding: 16px; }
/* lớp nền của hộp thoại phải nằm DƯỚI hộp thoại (.backdrop chung có z-index 40 cho khung soạn thảo) */
.modal-wrap > .backdrop { z-index: 0; }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: min(520px, 100%); max-height: calc(100vh - 32px);
  display: flex; flex-direction: column; animation: pop .18s cubic-bezier(.2,.8,.2,1); position: relative; z-index: 1; }
.modal.wide { width: min(720px, 100%); }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 6px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-head .icon-badge { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.modal-head .icon-badge.danger { background: var(--danger-soft); color: var(--danger); }
.modal-body { padding: 10px 22px 6px; overflow: auto; color: var(--text-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px 20px; }
.menu { position: absolute; z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 6px; min-width: 220px; animation: pop .12s; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 9px 10px; border-radius: 8px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.menu .menu-label { font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 6px 10px 2px; text-transform: uppercase; letter-spacing: .05em; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 80; max-width: min(400px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--ok);
  padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow-lg); white-space: pre-wrap; animation: pop .18s; font-size: 13.5px; }
.toast svg { color: var(--ok); margin-top: 1px; }
.toast.err { border-left-color: var(--danger); } .toast.err svg { color: var(--danger); }
.toast.info { border-left-color: var(--info); } .toast.info svg { color: var(--info); }

.busy { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(15, 17, 32, .5); backdrop-filter: blur(3px); padding: 16px; }
.busy-card { background: var(--surface); border-radius: 20px; padding: 28px 30px; width: min(380px, 100%); text-align: center; box-shadow: var(--shadow-lg); animation: pop .2s; }
.busy-orb { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%; background: conic-gradient(from 0deg, var(--primary), var(--primary-2), transparent 70%);
  animation: spin 1.1s linear infinite; position: relative; }
.busy-orb::after { content: "✦"; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; color: var(--primary); font-size: 20px; }
.busy-card h3 { margin: 0 0 6px; font-size: 16px; } .busy-card p { margin: 0; color: var(--muted); font-size: 13px; min-height: 20px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- điện thoại ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border); }
  .logo, .side-foot, .nav-badge { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 10.5px; flex: 1; text-align: center; }
  .nav a.nav-logs { display: none; }
  .sticky-actions { bottom: 64px; }
  .main { padding: 18px 16px 90px; }
  .page-head h1 { font-size: 22px; }
  .drawer-body { padding: 16px; } .drawer-head, .drawer-foot { padding: 10px 16px; }
  .calendar .day { min-height: 74px; padding: 3px; } .cal-post span { display: none; } .cal-post { justify-content: center; padding: 3px; }
  .toasts { left: 16px; right: 16px; bottom: 84px; }
  .mobile-only { display: inline-flex !important; }
}
.mobile-only { display: none !important; }

/* ---------- hướng dẫn A–Z ---------- */
.guide-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.guide-toc { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px; max-height: calc(100vh - 40px); overflow: auto; }
.guide-toc a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-size: 13.5px; cursor: pointer; }
.guide-toc a:hover { background: var(--surface-2); color: var(--text); }
.guide-toc a span:first-of-type { flex: 1; }
.guide-sec { scroll-margin-top: 20px; min-width: 0; }
.guide-sec code { overflow-wrap: anywhere; }
.guide-sec .copy-row { flex-wrap: wrap; }
.guide-sec p { color: var(--text-2); line-height: 1.7; margin: 0 0 10px; }
.guide-sec .guide { margin-bottom: 12px; }
.guide-sec .guide ul { padding-left: 18px; margin: 4px 0; }
.guide-sec .notice { margin: 4px 0 10px; }
.guide-sec .card-head .btn { flex: none; }
.faq details { border-top: 1px solid var(--border); padding: 10px 0; }
.faq details:first-child { border-top: 0; }
.faq details p { margin: 8px 0 0 26px; }
@media (max-width: 1000px) {
  .guide-layout { grid-template-columns: minmax(0, 1fr); }
  .guide-toc { display: none; }
}
@media (max-width: 860px) {
  .nav a { min-width: 0; padding: 6px 2px; }
  .nav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
}
