/* ============================================================
   Vibe Ads by Viva — hệ thiết kế kính mờ (glassmorphism)
   Nền navy + nhấn teal (lấy theo perplexity.ai/personal-computer).
   Nguồn sự thật duy nhất về giao diện — không viết <style> trong trang.
   ============================================================ */

/* ---------- 1. Token màu / kích thước ---------- */
:root {
  /* nền */
  --ink:          #0a0e1a;
  --ink-2:        #0f1629;

  /* lớp kính — màng trắng phủ lên nền tối (kiểu liquid glass),
     KHÔNG phải panel màu tối đặc */
  --film:         rgba(255, 255, 255, 0.06);   /* màng trắng lớp vỏ ngoài */
  --film-2:       rgba(255, 255, 255, 0.10);   /* màng trắng lớp lõi trong */
  --glass-base:   rgba(13, 18, 32, 0.52);      /* nền tối phía dưới màng, giữ chữ đọc được */
  --glass-base-2: rgba(17, 23, 40, 0.72);
  --glass-strong: rgba(20, 26, 45, 0.86);
  --glass-line:   rgba(255, 255, 255, 0.14);   /* viền sáng quanh 4 cạnh */
  --glass-line-hi:rgba(255, 255, 255, 0.26);
  --rim:          inset 0 1px 0 rgba(255, 255, 255, 0.16);  /* vệt sáng mép trong */
  --rim-hi:       inset 0 1px 0 rgba(255, 255, 255, 0.34);

  /* chữ */
  --text:         #e2e8f0;
  --text-muted:   #94a3b8;
  --text-dim:     #64748b;

  /* nhấn — teal lấy đúng từ nút CTA của perplexity.ai/personal-computer */
  --accent:       #20808d;                      /* nền nút — dùng đúng hex của họ */
  --accent-hi:    #2a9aa8;                      /* trạng thái hover */
  --accent-text:  #5fd0dd;                      /* bản sáng, dùng cho CHỮ trên nền tối */
  --accent-soft:  rgba(32, 128, 141, 0.14);
  --accent-line:  rgba(32, 128, 141, 0.34);
  --primary:      #1a73e8;
  --primary-hi:   #4a9af5;
  --violet:       #8b5cf6;
  --teal:         #3fc7b8;
  --coral:        #e2725b;
  /* cảnh báo / lỗi — hai màu này vốn nằm rải rác dưới dạng hex viết thẳng
     trong `style=` của từng trang; gom về token để chỗ mới dùng đúng một màu */
  --warn:         #e0a030;
  --danger:       #e06666;

  /* hình khối — bo lớn, lồng lớp: vỏ ngoài 24px → lõi trong 18px */
  --radius:       24px;
  --radius-in:    18px;
  --radius-sm:    14px;
  --radius-xs:    12px;
  --pill:         9999px;
  --blur:         22px;
  /* đổ bóng rất nhẹ — kính nổi lên chứ không đè xuống */
  --shadow:       0 18px 48px rgba(0, 0, 0, 0.32), 0 2px 8px rgba(0, 0, 0, 0.10);
  --shadow-sm:    0 4px 24px rgba(0, 0, 0, 0.16), 0 1px 3px rgba(0, 0, 0, 0.08);

  /* chữ */
  --font-body:    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* khung */
  --nav-h:        68px;
  --wrap:         1180px;
  --wrap-narrow:  760px;
}

/* ---------- 2. Nền trang + blob gradient (cái để lớp kính làm mờ) ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 3 blob cố định phía sau — không có blob thì hiệu ứng kính vô nghĩa */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(560px circle at 50% 34%,  rgba(99, 102, 241, 0.30), transparent 66%),
    radial-gradient(700px circle at 10% 4%,   rgba(26, 115, 232, 0.40), transparent 62%),
    radial-gradient(640px circle at 90% 18%,  rgba(139, 92, 246, 0.34), transparent 64%),
    radial-gradient(720px circle at 74% 62%,  rgba(32, 128, 141, 0.30), transparent 62%),
    radial-gradient(820px circle at 26% 96%,  rgba(32, 128, 141, 0.18), transparent 62%);
}

/* lưới mờ rất nhẹ cho có chiều sâu */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 75%);
}

/* ---------- 3. Lớp kính chuẩn ---------- */
/* Vỏ ngoài: màng trắng mỏng phủ lên nền tối, viền sáng quanh 4 cạnh,
   vệt sáng chạy bên trong mép trên (--rim) — đây là chữ ký của kiểu kính này. */
.glass {
  position: relative;
  background:
    linear-gradient(180deg, var(--film), rgba(255,255,255,0.015)),
    var(--glass-base);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm), var(--rim);
}

/* Lõi trong — lồng bên trong .glass. Sáng hơn vỏ, bo nhỏ hơn (24 → 18). */
.glass-in {
  position: relative;
  background:
    linear-gradient(180deg, var(--film-2), rgba(255,255,255,0.02)),
    var(--glass-base-2);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-in);
  box-shadow: 0 1px 3px rgba(0,0,0,.10), var(--rim-hi);
}

/* Trình duyệt không hỗ trợ backdrop-filter (Firefox cũ, máy yếu):
   đổ nền đặc hơn để không bị trong suốt lem, mất chữ */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass    { background: linear-gradient(180deg, var(--film), transparent), #131a2c; }
  .glass-in { background: linear-gradient(180deg, var(--film-2), transparent), #182036; }
  .nav      { background: #0d1220; }
}

/* ---------- 4. Khung, chữ ---------- */
.wrap        { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.wrap-narrow { width: 100%; max-width: var(--wrap-narrow); margin: 0 auto; padding: 0 24px; }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.2rem, 5.5vw, 4rem); }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.3rem); }
h3 { font-size: 1.15rem; }
p  { margin: 0 0 1em; }
a  { color: var(--primary-hi); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted    { color: var(--text-muted); }
.dim      { color: var(--text-dim); }
.mono     { font-family: var(--font-mono); font-size: .92em; }
.accent   { color: var(--accent-text); }
.center   { text-align: center; }
.nowrap   { white-space: nowrap; }
.hidden   { display: none !important; }

.grad-text {
  background: linear-gradient(96deg, var(--primary-hi) 0%, var(--violet) 48%, var(--accent-text) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.section       { padding: 88px 0; }
.section-title { text-align: center; margin-bottom: 8px; }
.section-sub   { text-align: center; color: var(--text-muted); margin-bottom: 48px; }

/* ---------- 5. Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, rgba(255,255,255,.05), transparent), rgba(10, 14, 26, 0.62);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--glass-line);
  box-shadow: var(--rim);
}
.nav .wrap { display: flex; align-items: center; gap: 20px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
/* Logo Viva không vuông (240×213) — khoá chiều cao, để chiều rộng tự co */
.brand img { height: 32px; width: auto; display: block; }
.brand small { font-weight: 400; font-size: .8rem; color: var(--text-muted); }

.nav-links { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.nav-links a { padding: 8px 14px; border-radius: var(--radius-xs); color: var(--text-muted); font-size: .94rem; font-weight: 500; }
.nav-links a:hover { color: var(--text); background: rgba(255,255,255,.06); text-decoration: none; }

.nav-user { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: .92rem; color: var(--text-muted); }

/* ---------- 6. Nút ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border: 1px solid transparent;
  border-radius: var(--pill);
  font-family: inherit;
  font-size: .95rem;
  font-weight: 500;      /* Perplexity dùng 500 — chữ nhẹ tạo cảm giác điềm đạm */
  line-height: 1.2;
  cursor: pointer;
  transition: transform .12s ease, filter .18s ease, background .18s ease, border-color .18s ease;
  text-decoration: none;
}
.btn:hover  { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; transform: none; }

/* Nút chính — công thức lấy nguyên từ nút "Download for Mac" của Perplexity:
   teal đặc, viền trắng rất mờ, quầng sáng cùng màu + vệt sáng mép trong. */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: rgba(255,255,255,.12);
  box-shadow: 0 4px 24px -2px rgba(32,128,141,.40),
              0 0 0 1px rgba(32,128,141,.20),
              inset 0 1px 0 rgba(255,255,255,.15);
}
.btn-primary:hover { background: var(--accent-hi); }

/* Nút viền trắng đặc — bản "Setup Guide" */
.btn-outline {
  background: transparent;
  border-color: #fff;
  color: #fff;
}
.btn-outline:hover { background: rgba(255,255,255,.10); }

.btn-blue {
  background: linear-gradient(180deg, var(--primary-hi), var(--primary));
  color: #fff;
  box-shadow: 0 2px 10px -2px rgba(26,115,232,.45), inset 0 1px 0 rgba(255,255,255,.32);
}
.btn-blue:hover { filter: brightness(1.06); }

/* nút kính — đúng công thức nút "Download" nhỏ trên nav của Perplexity */
.btn-ghost {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.18);
  color: #fff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 12px -2px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.10);
}
.btn-ghost:hover { background: rgba(255,255,255,.18); }

.btn-danger { background: rgba(226,114,91,.06); border-color: rgba(226,114,91,.45); color: var(--coral); }
.btn-danger:hover { background: rgba(226,114,91,.14); }

.btn-sm  { padding: 7px 15px; font-size: .85rem; }
.btn-lg  { padding: 15px 32px; font-size: 1.02rem; }
.btn-block { width: 100%; }

/* ---------- 7. Thẻ ---------- */
.card { padding: 24px; }
.card-hd {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 14px; margin-bottom: 18px;
  border-bottom: 1px solid var(--glass-line);
  font-weight: 700; font-size: 1.05rem;
}
.card-hd .spacer { margin-left: auto; }

.grid    { display: grid; gap: 20px; }
.grid-2  { grid-template-columns: repeat(2, 1fr); }
.grid-3  { grid-template-columns: repeat(3, 1fr); }
.grid-4  { grid-template-columns: repeat(4, 1fr); }
/* Năm ô đếm ở trang Tổng quan.
   Khung nội dung rộng 900px, nên với gap 20px mặc định thì 5×150+4×20 = 830px
   — sát quá, và ô thứ năm rớt xuống hàng dưới một mình. Gap hẹp hơn và đáy
   140px cho 756px, vừa chắc chắn. Dưới 900px thì responsive lo tiếp.  */
.grid-5  { gap: 14px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

.feature { padding: 26px; transition: transform .2s ease, border-color .2s ease; }
.feature:hover { transform: translateY(-3px); border-color: var(--glass-line-hi); }
.feature .ico { font-size: 1.6rem; margin-bottom: 12px; display: block; }
.feature h3 { margin-bottom: 8px; }
.feature p  { margin: 0; color: var(--text-muted); font-size: .93rem; }

.step .num {
  font-family: var(--font-mono); font-size: 2.6rem; font-weight: 700;
  color: rgba(255,255,255,.14); line-height: 1; margin-bottom: 6px; display: block;
}

/* ---------- 8. Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; letter-spacing: .01em;
}
.badge-active  { background: rgba(63,199,184,.14);  color: var(--teal);    border: 1px solid rgba(63,199,184,.3); }
.badge-pending { background: rgba(226,114,91,.14);  color: var(--coral);   border: 1px solid rgba(226,114,91,.3); }
.badge-accent  { background: var(--accent-soft);   color: var(--accent-text);        border: 1px solid var(--accent-line); }
.badge-info    { background: rgba(26,115,232,.16);  color: var(--primary-hi); border: 1px solid rgba(26,115,232,.34); }
.badge-off     { background: rgba(148,163,184,.12); color: var(--text-muted); border: 1px solid rgba(148,163,184,.24); }

/* ---------- 9. Form ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 7px; font-size: .9rem; font-weight: 600; color: var(--text); }
/* `.hint` tới giờ chỉ có kiểu khi nằm trong `.field`, nên mọi chỗ dùng nó
   ngoài `.field` — hộp sửa bài, `login.html`, `media.html`, `page.html` —
   rơi về cỡ chữ mặc định mà không ai để ý. Kiểu nền cho mọi `.hint`; hai
   selector dưới có độ ưu tiên cao hơn nên phần trong `.field` không đổi. */
.hint { font-size: .82rem; color: var(--text-dim); line-height: 1.5; }
.field .hint { margin-top: 7px; font-size: .82rem; color: var(--text-dim); line-height: 1.5; }

/* `input:not([type])` nằm đầu danh sách có lý do.

   Trước 18/09 danh sách này chỉ liệt kê từng `input[type=…]`, nên một thẻ
   `<input>` viết không có `type` rơi hết ra ngoài: nền trắng, viền xám, phông
   khác — lạc hẳn giữa giao diện tối. Đúng cùng một lỗi với `input[type=date]`
   ghi ở dưới, chỉ khác là lần này thiếu cả thuộc tính.

   Trang `/zns.html` dựng ô nhập bằng JS từ `listParams` của Zalo và quên
   `type`, nên **toàn bộ** form nhập liệu ZNS không có style nào. Thêm `type`
   vào chỗ đó là sửa đúng một trang; thêm selector này là sửa cho mọi trang sau
   này nữa. Làm cả hai. */
input:not([type]),
input[type=text], input[type=email], input[type=number], input[type=password], input[type=url], input[type=tel], input[type=search], input[type=date], input[type=datetime-local], input[type=time], select, textarea {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: .96rem;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.01)), rgba(8, 12, 22, 0.55);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-in);
  outline: none;
  box-shadow: var(--rim);
  transition: border-color .18s ease, box-shadow .18s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
input:focus, select:focus, textarea:focus {
  border-color: rgba(32,128,141,.75);
  box-shadow: 0 0 0 3px rgba(32,128,141,.20), var(--rim-hi);
}
textarea { resize: vertical; min-height: 90px; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}
select option { background: #131a2c; color: var(--text); }

/* Ô chọn ngày.

   Trước 14/09 `input[type=date]` không nằm trong danh sách selector ở trên, nên
   nó rơi về style mặc định của trình duyệt: nền trắng, viền xám, phông khác —
   lạc hẳn giữa một giao diện tối. Chỉ thêm nó vào danh sách là xong phần khung,
   nhưng còn hai thứ trình duyệt vẽ riêng mà kế thừa không tới:

   1. Biểu tượng lịch mặc định màu đen, gần như tàng hình trên nền tối. Không
      đổi màu trực tiếp được, phải nghịch đảo rồi giảm sáng.
   2. Từng phần ngày/tháng/năm là pseudo-element riêng, giữ màu hệ thống khi
      trống.  */
input[type=date], input[type=datetime-local], input[type=time] { position: relative; }
input[type=date]::-webkit-calendar-picker-indicator,
input[type=datetime-local]::-webkit-calendar-picker-indicator,
input[type=time]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(.75);
  cursor: pointer;
  opacity: .7;
  transition: opacity .18s ease;
}
input[type=date]:hover::-webkit-calendar-picker-indicator,
input[type=datetime-local]:hover::-webkit-calendar-picker-indicator,
input[type=time]:hover::-webkit-calendar-picker-indicator { opacity: 1; }

/* `datetime-local` có THÊM ba phần giờ/phút/AM-PM so với `date`. Bỏ sót chúng
   thì nửa ô hiện màu hệ thống (đen trên nền tối) — ô nhìn như chưa được gắn
   CSS, đúng như anh Hiếu chỉ ra ngày 21/09/2026. */
input[type=date]::-webkit-datetime-edit-text,
input[type=date]::-webkit-datetime-edit-month-field,
input[type=date]::-webkit-datetime-edit-day-field,
input[type=date]::-webkit-datetime-edit-year-field,
input[type=datetime-local]::-webkit-datetime-edit-text,
input[type=datetime-local]::-webkit-datetime-edit-month-field,
input[type=datetime-local]::-webkit-datetime-edit-day-field,
input[type=datetime-local]::-webkit-datetime-edit-year-field,
input[type=datetime-local]::-webkit-datetime-edit-hour-field,
input[type=datetime-local]::-webkit-datetime-edit-minute-field,
input[type=datetime-local]::-webkit-datetime-edit-ampm-field,
input[type=time]::-webkit-datetime-edit-text,
input[type=time]::-webkit-datetime-edit-hour-field,
input[type=time]::-webkit-datetime-edit-minute-field,
input[type=time]::-webkit-datetime-edit-ampm-field { color: var(--text); }
input[type=date]::-webkit-datetime-edit-fields-wrapper,
input[type=datetime-local]::-webkit-datetime-edit-fields-wrapper,
input[type=time]::-webkit-datetime-edit-fields-wrapper { padding: 0; }

/* Ô nhập gọn — dùng trong ô của bảng, nơi padding 12px đẩy dòng cao gấp đôi
   cần thiết. Vẫn chung nền, viền, bo góc và vòng focus với ô nhập thường. */
.input-sm { padding: 7px 10px; font-size: .88rem; border-radius: var(--radius-xs); }

/* Một ô trong form nhập liệu sinh động: nhãn, ô nhập, bộ đếm ký tự, gợi ý.
   Hẹp hơn `.field` vì form ZNS có 5–7 ô liền nhau, 18px giữa mỗi ô là quá thưa
   để nhìn hết một lần. */
.field-tight { margin-bottom: 12px; }
.field-tight label { margin-bottom: 4px; font-size: .89rem; }
.field-tight .hint { margin-top: 4px; font-size: .8rem; }
/* Bộ đếm ký tự nằm cùng dòng với nhãn, dạt phải. Trần độ dài của Zalo là hợp
   đồng cứng (§15 của CLAUDE.md đo ở Article API; ZNS đếm ký tự, xem
   `zns_templates`), nên chỗ này phải thấy được trước khi gõ tràn. */
.field-tight .dem { float: right; font-weight: 400; font-size: .8rem; color: var(--text-dim); }
.field-tight .dem.day { color: var(--warn); }
.field-tight .buoc { color: var(--danger); }

/* Lưới ô nhập tự xuống dòng. Số ô do mẫu tin quyết định (Zalo trả về), từ 3 tới
   7+ — nên không ghi cứng số cột, để mỗi ô giữ bề ngang đọc được rồi tự xếp. */
.form-luoi {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0 18px;
}

/* ô mã OTP */
.otp-input {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  letter-spacing: .5em;
  text-align: center;
  padding: 14px 10px 14px 20px;
}

/* ---------- 10. Tab ---------- */
.tabs {
  display: flex; gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  background: rgba(15, 22, 41, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--glass-line);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs .wrap { display: flex; gap: 4px; }
.tab {
  padding: 15px 16px;
  font-size: .94rem; font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover  { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent-text); }

/* ---------- 11. Bảng ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 640px; }
table.tbl th {
  text-align: left; padding: 11px 12px;
  font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--glass-line);
}
table.tbl td { padding: 13px 12px; border-bottom: 1px solid rgba(255,255,255,.05); }
table.tbl tbody tr:hover { background: rgba(255,255,255,.03); }
table.tbl td.num, table.tbl th.num { text-align: right; font-family: var(--font-mono); }

/* ---------- 12. Ô mã / token ---------- */
.code-box {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: rgba(6, 9, 18, 0.6);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: .84rem;
  color: var(--teal);
  word-break: break-all;
}
.code-box .val { flex: 1; min-width: 0; }
.code-box button { flex-shrink: 0; }

pre.code {
  margin: 0;
  padding: 14px;
  max-height: 260px;
  overflow: auto;
  background: rgba(6, 9, 18, 0.6);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: .8rem;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- 13. Thanh tiến độ ---------- */
.bar { height: 8px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar > i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent-text));
  transition: width .4s ease;
}
.bar.warn > i { background: linear-gradient(90deg, #e8b04b, var(--coral)); }

/* ---------- 14. Trạng thái rỗng ---------- */
.empty-state { padding: 56px 24px; text-align: center; }
.empty-state .ico { font-size: 2.6rem; display: block; margin-bottom: 14px; opacity: .85; }
.empty-state h3 { margin-bottom: 6px; }
.empty-state p  { color: var(--text-muted); margin: 0 auto; max-width: 460px; font-size: .94rem; }

/* ---------- 15. Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(4, 7, 14, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-backdrop.open { display: flex; }
/* Cột dọc: đầu và chân đứng yên, chỉ .modal-body cuộn. Trước đây cả .modal
   cuộn nên tiêu đề trôi mất và thanh cuộn cắt ngang góc bo. */
.modal {
  width: 100%; max-width: 460px;
  max-height: min(90vh, 940px);
  display: flex; flex-direction: column;
  padding: 0; overflow: hidden;
  background: linear-gradient(180deg, var(--film-2), rgba(255,255,255,.02)), var(--glass-strong);
  backdrop-filter: blur(28px) saturate(170%);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  border: 1px solid var(--glass-line-hi);
  border-radius: var(--radius);
  box-shadow: var(--shadow), var(--rim-hi);
  animation: modal-in .22s ease;
}
.modal-lg { max-width: 660px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.modal-hd {
  display: flex; align-items: center; gap: 10px;
  flex: 0 0 auto;
  padding: 22px 26px 14px;
  border-bottom: 1px solid var(--glass-line);
}
.modal-hd h3 { margin: 0; font-size: 1.12rem; }
.modal-hd .x {
  margin-left: auto; background: none; border: 0; cursor: pointer;
  color: var(--text-muted); font-size: 1.5rem; line-height: 1; padding: 0 4px;
  border-radius: var(--radius-xs); transition: color .15s ease, background .15s ease;
}
.modal-hd .x:hover { color: var(--text); background: rgba(255,255,255,.07); }

/* Vùng cuộn. Padding nằm trong đây để thanh cuộn chạy sát mép trong, không
   đè lên viền bo của .modal. */
.modal-body { flex: 1 1 auto; overflow-y: auto; padding: 20px 26px 24px; }
.modal-body > :first-child { margin-top: 0; }
/* Chân cố định cho nút hành động — form dài không phải cuộn xuống mới bấm được */
.modal-ft {
  flex: 0 0 auto; padding: 14px 26px 20px;
  border-top: 1px solid var(--glass-line);
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent);
}

/* Nhóm trường trong form dài */
.form-section { margin: 0 0 6px; }
.form-section + .form-section { margin-top: 22px; }
.form-section > h4 {
  margin: 0 0 14px; font-size: .82rem; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; color: var(--accent-text);
  display: flex; align-items: center; gap: 9px;
}
.form-section > h4::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--accent-line), transparent);
}

/* ---------- 15b. Thanh cuộn theo theme ----------
   Mặc định của trình duyệt là thanh trắng dày, chọi hẳn với nền kính tối. */
.modal-body, .table-wrap, pre.code, textarea, .scroll-y {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}
.modal-body::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
pre.code::-webkit-scrollbar,
textarea::-webkit-scrollbar,
.scroll-y::-webkit-scrollbar { width: 11px; height: 11px; }

.modal-body::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track,
pre.code::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track,
.scroll-y::-webkit-scrollbar-track { background: transparent; }

/* border trong suốt + background-clip tạo khoảng đệm quanh thanh kéo,
   nhìn thanh mảnh mà vùng bấm vẫn đủ rộng */
.modal-body::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
pre.code::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb,
.scroll-y::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.16);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: var(--pill);
}
.modal-body::-webkit-scrollbar-thumb:hover,
.table-wrap::-webkit-scrollbar-thumb:hover,
pre.code::-webkit-scrollbar-thumb:hover,
textarea::-webkit-scrollbar-thumb:hover,
.scroll-y::-webkit-scrollbar-thumb:hover {
  background: var(--accent-line);
  border: 3px solid transparent;
  background-clip: padding-box;
}
.modal-body::-webkit-scrollbar-corner,
.table-wrap::-webkit-scrollbar-corner { background: transparent; }

/* ---------- 16. Toast ---------- */
#toasts {
  position: fixed; z-index: 200;
  right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
}
.toast {
  padding: 13px 17px;
  background: linear-gradient(180deg, var(--film-2), rgba(255,255,255,.02)), var(--glass-strong);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--glass-line-hi);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-in);
  box-shadow: var(--shadow), var(--rim);
  font-size: .92rem;
  animation: toast-in .22s ease;
}
.toast.ok   { border-left-color: var(--teal); }
.toast.err  { border-left-color: var(--coral); }
.toast.warn { border-left-color: #e8b04b; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } }

/* ---------- 17. Bảng giá ---------- */
.plan { padding: 26px 22px; display: flex; flex-direction: column; }
.plan.current { border-color: var(--accent-line); box-shadow: 0 0 0 1px rgba(32,128,141,.30), var(--shadow-sm); }
.plan .plan-name { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 12px; }
.plan .price { font-family: var(--font-mono); font-size: 1.9rem; font-weight: 600; color: var(--text); line-height: 1.1; }
.plan .price small { display: block; font-family: var(--font-body); font-size: .82rem; font-weight: 400; color: var(--text-dim); margin-top: 2px; }
.plan ul { list-style: none; margin: 18px 0; padding: 0; flex: 1; }
.plan li { padding: 5px 0; font-size: .89rem; color: var(--text-muted); }
.plan li strong { color: var(--text); font-family: var(--font-mono); }
.plan li.no { color: var(--text-dim); }

.toggle {
  display: inline-flex; padding: 4px; gap: 4px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--glass-line);
  border-radius: 999px;
}
.toggle button {
  padding: 8px 18px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text-muted);
  font-family: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.toggle button.on { background: var(--accent); color: #fff; }

/* ---------- 18. Phiếu chờ duyệt (ticket stub) ---------- */
.ticket {
  position: relative;
  padding: 16px 20px;
  margin-bottom: 12px;
  background: linear-gradient(180deg, var(--film-2), rgba(255,255,255,.02)), var(--glass-base-2);
  border: 1px solid var(--glass-line);
  border-left: 3px solid var(--coral);
  border-radius: var(--radius-in);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 3px rgba(0,0,0,.10), var(--rim);
}
.ticket .t-hd { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-weight: 600; }
.ticket .t-hd .spacer { margin-left: auto; }
.ticket .t-body { font-size: .9rem; color: var(--text-muted); }

/* ---------- 19. Footer ---------- */
.footer {
  margin-top: 40px;
  padding: 32px 0;
  border-top: 1px solid var(--glass-line);
  background: rgba(8, 11, 21, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: .88rem;
  color: var(--text-dim);
}
.footer .wrap { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; }
.footer .links { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px 20px; }
.footer a { color: var(--text-muted); }

/* ---------- 20. Trang nội dung (privacy/terms) ---------- */
.doc { padding: 40px 34px; }
.doc h2 { font-size: 1.3rem; margin-top: 32px; }
.doc h2:first-of-type { margin-top: 0; }
.doc ul { padding-left: 20px; color: var(--text-muted); }
.doc li { margin-bottom: 7px; }

/* ---------- 21. Responsive ---------- */
@media (max-width: 900px) {
  .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .section { padding: 60px 0; }
}
@media (max-width: 680px) {
  :root { --blur: 10px; }              /* giảm blur cho đỡ tụt khung hình trên mobile */
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .wrap, .wrap-narrow { padding: 0 16px; }
  .nav-links a { padding: 8px 10px; font-size: .88rem; }
  .nav-links .hide-sm { display: none; }
  .card, .doc { padding: 20px 18px; }
  .footer .wrap { flex-direction: column; align-items: flex-start; }
  .footer .links { margin-left: 0; }
  #toasts { left: 16px; right: 16px; bottom: 16px; max-width: none; }
}

/* ---------- 22. Tôn trọng cài đặt giảm chuyển động ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}


/* ============================================================
   Hộp soạn bài (site/js/soan-bai.js)
   ============================================================ */

/* Chọn một kiểu bài trước khi nhập nội dung: ảnh và link không đi chung. */
.sb-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-in);
  background: var(--film);
}
.sb-tab {
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
}
.sb-tab:hover { color: var(--text); background: rgba(255,255,255,.05); }
.sb-tab.active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.sb-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#sb-loai-hint { margin-top: 8px; color: var(--text-dim); font-size: .84rem; }
@media (max-width: 480px) { .sb-tab { padding: 10px 7px; font-size: .82rem; } }

/* Lưới ảnh — dùng chung cho ảnh đã chọn và hộp chọn từ kho. */
.sb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.sb-o {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--film);
  border: 1px solid var(--glass-line);
  cursor: grab;
}
.sb-o img,
.sb-o video { width: 100%; height: 100%; object-fit: cover; display: block; }
.sb-o:active { cursor: grabbing; }

/* Nhãn "bìa" trên ảnh đầu tiên. Thứ tự ảnh quyết định ảnh bìa và Facebook tôn
   trọng nó (đo M-FB1) — nên phải nhìn thấy được, không giấu trong tooltip. */
.sb-bia {
  position: absolute; left: 5px; top: 5px;
  background: var(--accent); color: #fff;
  font-size: .68rem; font-weight: 600;
  padding: 2px 7px; border-radius: var(--pill);
}

.sb-xoa {
  position: absolute; right: 4px; top: 4px;
  width: 22px; height: 22px; line-height: 1;
  border: none; border-radius: 50%;
  background: rgba(0, 0, 0, .62); color: #fff;
  font-size: 1rem; cursor: pointer; padding: 0;
  opacity: 0; transition: opacity .15s ease;
}
.sb-o:hover .sb-xoa { opacity: 1; }

/* Dấu tích trong hộp chọn từ kho. Ẩn cho tới khi ảnh được chọn. */
.sb-pick { cursor: pointer; }
.sb-tick {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(32, 128, 141, .55); color: #fff;
  font-size: 1.6rem; font-weight: 700;
  opacity: 0; transition: opacity .15s ease;
}
.sb-pick.da-chon .sb-tick { opacity: 1; }
.sb-pick.da-chon { border-color: var(--accent-line); }

.sb-trong {
  grid-column: 1 / -1;
  padding: 18px; text-align: center;
  color: var(--text-dim); font-size: .88rem;
  border: 1px dashed var(--glass-line); border-radius: var(--radius-xs);
}

/* Ba chế độ đăng: ngay / hẹn giờ / lưu nháp. */
.sb-chon { display: flex; gap: 8px; flex-wrap: wrap; }
.sb-radio {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px; margin: 0;
  border: 1px solid var(--glass-line); border-radius: var(--pill);
  background: var(--film); cursor: pointer; font-size: .89rem;
  transition: border-color .15s ease, background .15s ease;
}
.sb-radio:hover { border-color: var(--glass-line-hi); }
.sb-radio:has(input:checked) {
  border-color: var(--accent-line); background: var(--accent-soft);
}

.sb-check {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: .89rem; cursor: pointer; margin: 0;
}
.sb-check input { margin-top: 3px; flex: none; }

/* Ba ô trên một hàng cho nhóm targeting. */
.sb-hang {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 10px; margin-top: 8px;
}
@media (max-width: 560px) { .sb-hang { grid-template-columns: 1fr; } }

/* Lời giải thích cho hai nhóm targeting. Hai thứ này dễ nhầm — một cái GIỚI
   HẠN ai xem được, một cái chỉ ƯU TIÊN hiển thị — nên lời giải thích phải nằm
   ngay trên ô nhập, không phải trong tooltip. */
.sb-canh {
  padding: 9px 12px; border-radius: var(--radius-xs);
  background: var(--film); border: 1px solid var(--glass-line);
  font-size: .85rem; color: var(--text-muted);
}

/* Hộp chọn ảnh chồng lên hộp soạn bài. */
#sb-kho-backdrop { z-index: 120; }

/* ══════════════════════════════════════════════════════════════════
   Hộp SỬA bài đã đăng — hai lưới ảnh (`ep-` = edit photos)

   Lưới dùng lại `.sb-grid` / `.sb-o` của hộp soạn bài, nhưng ngữ cảnh khác
   ở hai chỗ nên phải viết riêng: ảnh hiện tại CHỈ ĐỂ XEM, và ô ảnh thay thế
   có thêm thanh đổi thứ tự.
   ══════════════════════════════════════════════════════════════════ */

.ep-photos { margin-top: 18px; }

/* `.sb-o` đặt `cursor: grab` vì bên hộp soạn bài ô nào cũng kéo được. Ảnh
   hiện tại trên Facebook thì không — để nguyên bàn tay nắm là mời người ta
   kéo một thứ không kéo được. */
.ep-current { cursor: default; }

.ep-actions {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-top: 12px;
}

/* Thanh đổi thứ tự PHẢI nằm đè lên ảnh.

   Đặt nó theo dòng chảy bình thường thì nó rơi xuống DƯỚI thẻ `<img>` cao
   100% và bị `.sb-o { overflow: hidden }` cắt mất sạch: nút vẫn nằm trong
   DOM, `getComputedStyle` vẫn báo `display: block`, nhưng không ai bấm được.
   Chỉ còn cách kéo thả — mà kéo thả thì không dùng được bằng bàn phím. */
.ep-order {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 4px; padding: 4px 5px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .78) 55%);
}
.ep-order span {
  font-size: .72rem; font-weight: 700; color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}
.ep-order button {
  width: 22px; height: 22px; padding: 0; line-height: 1;
  border: none; border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, .2); color: #fff; font-size: .8rem;
  transition: background .15s ease;
}
.ep-order button:hover:not(:disabled) { background: rgba(255, 255, 255, .38); }
.ep-order button:disabled { opacity: .28; cursor: default; }

/* `.sb-o:hover .sb-xoa` giấu nút bỏ ảnh cho tới khi rê chuột. Ở đây ô nhỏ và
   người dùng đang so hai lưới với nhau, nên để hiện sẵn. */
.ep-selected .sb-xoa { opacity: .88; }

/* Ảnh trong kho đã thêm vào danh sách thay thế: xám đi, không bấm lại được. */
.ep-in-use { opacity: .42; cursor: default; }
.ep-used-label {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 3px 0; text-align: center;
  background: rgba(0, 0, 0, .7); color: #fff;
  font-size: .68rem; font-weight: 600;
}

.ep-warning { margin-top: 14px; }

/* Hộp chọn ảnh chồng lên hộp sửa bài — cùng lý do với `#sb-kho-backdrop`. */
#edit-library { z-index: 120; }

/* Ảnh vừa thêm vào album, chưa có trên Facebook. Phân biệt được ảnh nào đang
   ở trên trang với ảnh nào sắp lên là điều kiện để đọc được ô "giữ N · thêm M
   · gỡ K" ngay bên dưới. */
.ep-moi {
  position: absolute; right: 5px; bottom: 26px;
  background: var(--teal, #20808d); color: #fff;
  font-size: .64rem; font-weight: 700; letter-spacing: .3px;
  padding: 2px 6px; border-radius: var(--pill);
}
.ep-them { border-color: var(--accent-line); }

/* Ảnh Facebook trả URL nhưng KHÔNG trả id — không giữ lại được khi sửa album,
   vì gửi đại một id khác sẽ lấy mất ảnh của bài kia (đo M-FB13). */
.ep-hong { background: var(--danger, #c8453c); }

/* ---------- 23. Biểu đồ (vibe-chart.js) ----------
   Chỉ phần vỏ: tooltip, chú giải, ô KPI. Bản thân hình vẽ nằm trong SVG và
   ăn màu từ bảng màu đã qua kiểm của vibe-chart.js — đừng đặt màu chuỗi ở
   đây, hai nơi cùng giữ màu là hai nơi lệch nhau. */

.vc-hop { margin-top: 10px; }

.vc-tip {
  position: fixed; z-index: 3000; pointer-events: none;
  opacity: 0; transform: translateY(-3px); transition: opacity .12s ease;
  background: var(--glass-strong); border: 1px solid var(--glass-line);
  border-radius: var(--radius-xs); box-shadow: var(--shadow-sm);
  padding: 9px 11px; font-size: .82rem; line-height: 1.45;
  color: var(--text); max-width: 320px;
}
.vc-tip.mo { opacity: 1; transform: none; }
.vc-tip b { font-weight: 700; }
.vc-tip > b { display: block; margin-bottom: 5px; font-size: .84rem; }
.vc-tip span {
  display: flex; align-items: center; gap: 7px;
  color: var(--text-muted); white-space: nowrap;
}
.vc-tip span b { margin-left: auto; color: var(--text); }
.vc-tip i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.vc-tip .vc-canh { color: var(--warn); font-size: .76rem; white-space: normal; }

.vc-chu-giai {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  margin-top: 8px; font-size: .8rem; color: var(--text-muted);
}
.vc-chu-giai span { display: inline-flex; align-items: center; gap: 6px; }
.vc-chu-giai i { width: 11px; height: 11px; border-radius: 3px; flex: none; }

.vc-trong {
  margin: 0; padding: 26px 0; text-align: center;
  font-size: .86rem; color: var(--text-dim);
}

/* Hàng KPI — số lớn đọc trước, tia xu hướng đọc sau. */
.kpi-hang {
  display: grid; gap: 10px; margin-bottom: 14px;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
}
.kpi-o { padding: 12px 14px; }
.kpi-ten { font-size: .78rem; color: var(--text-muted); line-height: 1.35; }
.kpi-so  { font-size: 1.52rem; font-weight: 700; margin-top: 2px;
           letter-spacing: -.01em; }
.kpi-doi { font-size: .78rem; margin-top: 1px; }
.kpi-tia { margin-top: 6px; opacity: .85; }

/* Nhận xét đầu báo cáo. Dải màu bên trái để liếc qua là biết tốt hay xấu. */
.nx-list { display: flex; flex-direction: column; gap: 7px; }
.nx { padding: 9px 12px; border-left: 3px solid var(--text-dim);
      border-radius: var(--radius-xs); background: var(--film);
      font-size: .89rem; line-height: 1.5; }
.nx-tot  { border-left-color: var(--teal); }
.nx-xau  { border-left-color: var(--danger); }
.nx-trung{ border-left-color: var(--accent-text); }
