/*
 * chung.css — giao diện dùng chung của mọi trang seo-studio. T0. Chủ: T0; T6/T7 chỉ DÙNG (cần thêm ⇒ <style> trong trang của mình).
 * Nguồn chuẩn: prototype seo-canvas/project/*.dc.html (Main, Pipeline, Lich, Review, Settings…). Màu = token dưới; KHÔNG gõ mã màu
 * trong trang. Rail 220px ở màn ≥ 761px; thanh tab đáy 5 ô ở màn ≤ 760px (Chung.dungKhung dựng cả hai, CSS chọn cái hiện).
 */
@import url('https://fonts.googleapis.com/css2?family=Epilogue:wght@400;500;600;700&family=Space+Grotesk:wght@500;700&display=swap');

:root {
  --ground: #F7F5FA; --card: #FFFFFF; --ink: #1D1633; --muted: #6E6784; --muted-2: #625B78; --line: #EAE6F0; --soft: #ECE8F2;
  --edge: #DDD7E6; --focus: #6A3FB0; --focus-dam: #4B2A86; --lilac: #EFE7FB; --chon: #F3F0F8; --hom-nay: #EDE7F7;
  /* trạng thái */
  --wait: #E0603F; --wait-nen: #FCEBE5; --wait-chu: #8A2C16;
  --doing: #E0A100; --doing-nen: #FFF1D1; --doing-chu: #6B4E00;
  --ok: #2F8F5B; --ok-nen: #E8F3EC; --ok-chu: #22603F;
  --err: #C23B3B; --err-nen: #FDE4DD; --err-chu: #8A2C16;
  --draft: #A39DB5; --draft-nen: #EFECF4; --trong-vien: #CFC9DA;
  --grad: linear-gradient(110deg, #7FE0C4, #86CFF5 40%, #9FB2FF 72%, #D7B4FF);
  --font-dau: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --font-than: 'Epilogue', 'Helvetica Neue', Arial, 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  --rail: 220px; --bo: 14px; --bo-lon: 22px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--font-than); font-size: 15px; line-height: 1.5; }
a { color: var(--focus); }
a:hover { color: var(--focus-dam); }
h1, h2, h3 { font-family: var(--font-dau); font-weight: 700; line-height: 1.2; margin: 0; }
h1 { font-size: 32px; letter-spacing: -0.01em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fg-2, .phu { color: var(--muted); }
.nho { font-size: 13px; }
.so { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ── Biểu tượng ─────────────────────────────────────────────────────────────── */
.ic { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic-lg { width: 22px; height: 22px; }
.ic-sm { width: 16px; height: 16px; }

/* ── KHUNG: rail (≥ 761px) · đầu trang điện thoại + tab đáy (≤ 760px) ──────────────────────── */
body.co-khung { min-height: 100vh; }
.noi-dung, body.co-khung > main { min-width: 0; padding: 34px 48px 48px; max-width: 1180px; display: flex; flex-direction: column; gap: 28px; }
.rail { display: none; }
.dau-mobile { display: none; }
.tab-day { display: none; }

@media (min-width: 761px) {
  body.co-khung { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); align-items: start; }
  .rail { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: 26px 16px; background: var(--card); border-right: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .noi-dung, body.co-khung > main { padding: 18px 16px 112px; gap: 22px; }
  h1 { font-size: 28px; }
  .dau-mobile { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .tab-day { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: 84px; padding: 6px 8px 14px; background: var(--card); border-top: 1px solid var(--line); }
}

.thuong-hieu { font-family: var(--font-dau); font-weight: 700; font-size: 19px; color: var(--ink); text-decoration: none; padding: 0 12px 18px; letter-spacing: 0.01em; }
.rail-bai-moi { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; margin: 0 4px 18px; border-radius: 999px;
  color: var(--ink); text-decoration: none; font-family: var(--font-dau); font-weight: 700; font-size: 15px; background: var(--grad); }
.rail-bai-moi:hover { color: var(--ink); filter: saturate(1.15); }
.rail-muc { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: var(--muted-2); text-decoration: none; }
.rail-muc:hover { background: var(--chon); color: var(--ink); }
.rail-muc[aria-current='page'] { background: var(--chon); color: var(--ink); font-weight: 600; }
.rail-muc .nhan { flex: 1; }
.huy-hieu { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--wait); color: #FFFFFF; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.rail-dem { flex: 1; }
.rail-chan { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px 0; font-size: 12px; color: var(--muted); }
.rail-nguoi { display: flex; align-items: center; gap: 6px; }
.rail-nguoi span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo-tu { font-family: var(--font-dau); font-weight: 700; font-size: 17px; flex: 1; }

.tab-day a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 48px; text-decoration: none; color: var(--muted); font-size: 11px; }
.tab-day a[aria-current='page'] { color: var(--ink); font-weight: 600; }
.tab-day a.tab-bai-moi { justify-self: center; width: 54px; height: 54px; min-height: 54px; border-radius: 50%; display: grid; place-items: center; color: var(--ink); background: var(--grad); }

/* Chip "Giả lập" trên rail / đầu trang: có kết nối nào đang giả lập ⇒ số trên màn có thể là số mẫu. */
.chip-gia-lap { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; min-height: 24px; padding: 0 10px; border-radius: 999px;
  background: var(--doing-nen); color: var(--doing-chu); font-size: 12px; font-weight: 600; text-decoration: none; }
.chip-gia-lap::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--doing); }

/* ── NÚT (viên thuốc) ───────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--ink);
  background: var(--card); color: var(--ink); font-family: var(--font-dau); font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { color: var(--ink); background: var(--chon); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
.btn-chinh, .btn-primary { background: var(--ink); color: #FFFFFF; border-color: var(--ink); }
.btn-chinh:hover, .btn-primary:hover { background: #2E2550; color: #FFFFFF; }
.btn-grad { background: var(--grad); border-color: transparent; color: var(--ink); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--focus); }
.btn-ghost:hover { background: var(--chon); color: var(--focus-dam); }
.btn-nho { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn-icon { min-width: 40px; min-height: 40px; padding: 0; }
.nut-hang { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Nhóm chọn kiểu viên thuốc (Bảng/Lịch, Ý tưởng/Dàn ý/Từ keyword) */
.chon-nhom { display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; border-radius: 999px; background: var(--soft); }
.chon-nhom > * { display: grid; place-items: center; min-height: 40px; padding: 0 18px; border: 0; border-radius: 999px; background: transparent; color: #5B5470;
  font-family: var(--font-dau); font-size: 14px; text-decoration: none; cursor: pointer; }
.chon-nhom > [aria-selected='true'], .chon-nhom > [aria-pressed='true'] { background: var(--card); color: var(--ink); font-weight: 700; }
/* Viên chọn site: horos.vn / horos.tw / Cả hai web */
.vien-chon { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--edge); background: var(--card);
  color: var(--ink); font-family: inherit; font-size: 14px; cursor: pointer; }
.vien-chon[aria-pressed='true'], .vien-chon[aria-checked='true'] { background: var(--ink); color: #FFFFFF; border-color: var(--ink); }

/* ── THẺ, KHỐI ──────────────────────────────────────────────────────────────── */
.the { background: var(--card); border-radius: 20px; padding: 22px; }
.the-mong { background: var(--card); border-radius: var(--bo); padding: 14px 16px; border: 1px solid var(--line); }
.khoi { display: flex; flex-direction: column; gap: 12px; }
.hang { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.dong-ke { border-top: 1px solid var(--line); }
.the-noi { position: relative; display: block; text-decoration: none; color: var(--ink); }
.the-noi::before { content: ''; position: absolute; left: 40px; right: 40px; top: 30px; bottom: -14px; border-radius: 60px; background: var(--grad); filter: blur(34px); opacity: 0.5; z-index: 0; }
.the-noi > * { position: relative; z-index: 1; }
.so-lon { font-family: var(--font-dau); font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }

/* ── BẢNG KANBAN (Bài viết) ──────────────────────────────────────────────────── */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; overflow-x: auto; align-items: start; }
.cot-bang { display: flex; flex-direction: column; gap: 10px; padding: 14px 12px; border-radius: 18px; background: var(--draft-nen); min-height: 240px; }
.cot-bang.cot-cho-ban { background: var(--wait-nen); }
.cot-bang.cot-theo-doi { background: var(--ok-nen); }
.cot-dau { display: flex; align-items: baseline; gap: 8px; padding: 0 4px; }
.cot-dau h2 { font-size: 16px; flex: 1; }
.cot-hoi { font-size: 13px; color: var(--muted); padding: 0 4px; }
.the-bai { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: var(--bo); background: var(--card); border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.the-bai:hover { border-color: var(--edge); color: var(--ink); }
.the-bai .noi { font-size: 12px; color: var(--muted); }
.the-bai .tieu-de { font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.dong-may { font-size: 12px; color: var(--doing-chu); display: flex; align-items: center; gap: 6px; }

/* ── CHIP / TEM / CHẤM TRẠNG THÁI ───────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 10px; border-radius: 999px; background: var(--soft); color: #4A4360; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip-mau { background: var(--doing-nen); color: var(--doing-chu); }           /* "số mẫu" — số giả lập */
.chip-trong { background: var(--draft-nen); color: var(--muted); }            /* "chưa có dữ liệu" */
.chip-that { background: var(--ok-nen); color: var(--ok-chu); }
.chip-cho { background: var(--wait-nen); color: var(--wait-chu); }
.chip-loi { background: var(--err-nen); color: var(--err-chu); }
.chip-tim { background: var(--lilac); color: #3B2A66; }
.cham { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; display: inline-block; background: var(--draft); }
.cham-cho, .cham-wait { background: var(--wait); }
.cham-dang, .cham-doing { background: var(--doing); }
.cham-ok { background: var(--ok); }
.cham-loi, .cham-err { background: var(--err); }
.cham-nhap, .cham-draft { background: var(--draft); }

/* ── Ô TRỐNG (empty state) ─────────────────────────────────────────────────── */
.trong { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 18px; border-radius: var(--bo); border: 1.5px dashed var(--trong-vien); color: var(--muted); font-size: 14px; }
.trong b { color: var(--ink); font-weight: 600; }
.o-trong-lich { border: 1.5px dashed var(--trong-vien); background: transparent; color: var(--muted); }

/* ── DÒNG DANH SÁCH (Hôm nay · Page · Cài đặt) ───────────────────────────────── */
.dong { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.dong .giua { flex: 1; min-width: 0; }
.dong .giua b, .dong .giua .chinh { display: block; font-weight: 600; }
.dong .giua .phu { display: block; font-size: 14px; }

/* ── BẢNG SỐ ────────────────────────────────────────────────────────────────── */
.bang-so { width: 100%; border-collapse: collapse; font-size: 14px; }
.bang-so th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.bang-so td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.bang-so td.so, .bang-so th.so { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Ô NHẬP ─────────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; }
.input, .select, .textarea { min-height: 44px; width: 100%; border: 1px solid var(--edge); border-radius: 12px; background: var(--card); padding: 0 12px; font-family: inherit; font-size: 15px; color: var(--ink); }
.textarea { padding: 10px 12px; min-height: 96px; resize: vertical; }
.select { appearance: auto; }
.hint { font-size: 13px; color: var(--muted); }
.loi-chu { color: var(--err-chu); font-size: 14px; }

/* ── HỘP THOẠI · TOAST · BĂNG ───────────────────────────────────────────────── */
dialog.hop { border: 0; border-radius: var(--bo-lon); padding: 0; width: min(var(--hop-w, 520px), calc(100vw - 32px)); max-height: calc(100vh - 48px); color: var(--ink); background: var(--card); box-shadow: 0 24px 64px rgba(29, 22, 51, 0.18); }
dialog.hop::backdrop { background: rgba(29, 22, 51, 0.32); }
.hop-dau { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.hop-dau h2 { flex: 1; font-size: 18px; }
.hop-than { padding: 8px 20px 16px; overflow-y: auto; }
.hop-chan { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  dialog.hop { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 22px 22px 0 0; }
}
.toast-vung { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
@media (max-width: 760px) { .toast-vung { bottom: 100px; } }
.toast { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 14px; background: var(--ink); color: #FFFFFF; font-size: 14px; box-shadow: 0 8px 24px rgba(29, 22, 51, 0.24); }
.bang { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.bang-tin { background: var(--lilac); color: #3B2A66; }
.bang-canh { background: var(--doing-nen); color: var(--doing-chu); }
.bang-loi { background: var(--err-nen); color: var(--err-chu); }

/* ── BÀI VIẾT (Chung.dungMarkdown) ──────────────────────────────────────────── */
.md { font-size: 17px; line-height: 1.7; max-width: 720px; }
.md > * { margin: 0 0 16px; scroll-margin-top: 80px; }
.md h2 { font-size: 22px; margin-top: 28px; }
.md h3 { font-size: 18px; margin-top: 20px; }
.md ul, .md ol { padding-left: 24px; }
.md li { margin: 4px 0; }
.md img.anh-md { display: block; max-width: 100%; height: auto; border-radius: 10px; margin: 12px 0 0; background: var(--soft); }
.md [data-doan] { border-radius: 6px; }
.md mark.co { background: rgba(106, 63, 176, 0.16); border-bottom: 2px solid var(--focus); color: inherit; padding: 0 1px; }
.md mark.co-d3 { background: rgba(194, 59, 59, 0.12); border-bottom-color: var(--err); }

/* ── TRANG ĐĂNG NHẬP / KHỞI TẠO ─────────────────────────────────────────────── */
.dn-bo { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.dn-khung { width: min(420px, 100%); background: var(--card); border-radius: var(--bo-lon); padding: 28px; display: flex; flex-direction: column; gap: 18px; position: relative; }
.dn-khung::before { content: ''; position: absolute; left: 30px; right: 30px; top: 40px; bottom: -16px; border-radius: 60px; background: var(--grad); filter: blur(36px); opacity: 0.45; z-index: -1; }
.dn-dau h1 { font-size: 26px; }
.dn-dau p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.dn-form { display: flex; flex-direction: column; gap: 14px; }
.dn-loi { min-height: 20px; color: var(--err-chu); font-size: 14px; }
.dn-chan { margin: 0; font-size: 13px; color: var(--muted); }
