/* Họ Dương Duy An Vinh — hệ thiết kế theo phong cách shadcn/ui (New York).
   Token đặt tên theo quy ước shadcn, nhuộm màu dòng họ. Thay thế hoàn toàn
   BRIEF.md mục 2 và DESIGN.md cũ — xem DESIGN.md cho tài liệu đầy đủ.
   BRIEF.md mục 8 (ràng buộc không thương lượng: cỡ chữ, vùng bấm, không
   hoạt hình gây mất phương hướng…) vẫn còn hiệu lực và được tôn trọng. */

:root {
  /* ===== token shadcn, nhuộm màu dòng họ ===== */
  --background:         #FAF9F5;
  --foreground:          #2A1810;
  --card:                #FFFFFF;
  --muted:               #F2EFE8;
  --muted-foreground:    #7A6A58;
  --primary:             #8A1207;
  --primary-foreground:  #FAF9F5;
  --accent:              #F2EFE8;
  --border:              #E5E0D5;
  --ring:                #C00015;
  --radius:              0.5rem;

  /* Phần mở rộng riêng của site — không thuộc bộ token shadcn gốc nhưng
     cần để giữ bản sắc + đáp ứng BRIEF mục 8. */
  --accent-gold:         #F5CE0F; /* vàng của con triện — dùng làm điểm nhấn trang trọng */
  --primary-hover:       #6E0E05; /* --primary đậm hơn cho trạng thái hover */
  --tap-target:          44px;    /* vùng bấm tối thiểu, BRIEF mục 8 */

  /* thang khoảng cách kiểu Tailwind */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-6:  24px;
  --space-8:  32px;
  --space-12: 48px;
  --space-16: 64px;

  /* bề rộng nội dung */
  --content-narrow: 640px;
  --content-wide:   820px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: 'Noto Serif', serif;
  font-weight: 400;
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  line-height: 1.25;
  margin: 0;
  font-family: 'Noto Serif', serif;
  font-weight: 700;
  color: var(--foreground);
}

a { color: var(--primary); }
a:not(.khong-gach) { text-decoration-thickness: 1px; }

button { font-family: inherit; }

.chi-doc-man-hinh {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.lien-ket-bo-qua {
  position: absolute; top: -100px; left: var(--space-2); z-index: 100;
  background: var(--accent-gold); color: var(--foreground); padding: 10px var(--space-4);
  border-radius: var(--radius);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  font-weight: 700; font-size: 17px; letter-spacing: .02em;
  transition: top .15s ease;
}
.lien-ket-bo-qua:focus { top: var(--space-2); }

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* ===== khung trang ===== */

.khung {
  background: var(--background);
  min-height: 100vh;
}

/* ===== header + menu ===== */

.dau-trang {
  position: sticky; top: 0; z-index: 20;
  background: var(--primary); color: var(--primary-foreground);
}

.thanh-dau {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
}

/* Bấm vào con triện hoặc tên dòng họ đưa về trang chủ. */
.dau-trang__trang-chu {
  display: flex; align-items: center; gap: var(--space-3);
  flex: 1 1 auto; min-width: 0;
  color: inherit; text-decoration: none;
}

/* Con triện — DẤU HIỆU NHẬN DIỆN DUY NHẤT, giữ nguyên đặc tả cũ. Góc vuông
   bắt buộc, không theo hệ bo góc chung dù mọi thứ khác đều bo. */
.trien {
  width: 34px; height: 34px; flex: 0 0 34px;
  background: #C00015; color: #F5CE0F;
  font-family: 'Noto Serif SC', serif; font-weight: 700; font-size: 21px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #F5CE0F;
  border-radius: 0;
}

.ten-hieu {
  font-size: 14px; letter-spacing: .14em;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  font-weight: 700;
}

.nut-menu {
  flex: 0 0 auto;
  width: var(--tap-target); height: var(--tap-target);
  background: transparent; border: 1.5px solid var(--primary-foreground);
  border-radius: var(--radius);
  color: var(--primary-foreground); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background-color .15s ease;
}
.nut-menu:hover { background: rgba(250, 249, 245, .12); }

.nut-menu svg { width: 20px; height: 20px; }

.menu {
  display: none;
  background: var(--primary);
  border-top: 1px solid rgba(250, 249, 245, .18);
}
.menu.mo { display: block; }

.menu ul { list-style: none; margin: 0; padding: var(--space-2) 6px 14px; }

.menu a {
  display: flex; align-items: center;
  min-height: var(--tap-target);
  padding: 10px var(--space-3);
  color: var(--primary-foreground);
  text-decoration: none;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  font-weight: 600; font-size: 16px;
  letter-spacing: .02em;
  border-left: 4px solid transparent;
  border-radius: var(--radius);
  transition: background-color .15s ease;
}
.menu a:hover { background: rgba(250, 249, 245, .1); }
.menu a[aria-current="page"] {
  border-left-color: var(--accent-gold);
  color: var(--accent-gold);
  font-weight: 700;
}

/* ≥768px: menu trở thành hàng tab dạng viên thuốc trên nền --muted, đặc
   trưng shadcn — tách khỏi thanh đầu màu chính để nền --muted (be nhạt)
   không chìm vào nền đỏ nâu. */
@media (min-width: 768px) {
  .nut-menu { display: none; }
  .menu {
    display: block; background: var(--muted); border-top: 0;
    border-bottom: 1px solid var(--border);
  }
  .menu ul {
    display: flex; flex-wrap: wrap; gap: var(--space-1);
    padding: var(--space-2) var(--space-4);
  }
  .menu a {
    padding: 8px var(--space-4); border-left: 0;
    color: var(--muted-foreground); font-size: 14px; font-weight: 600;
    border-radius: 999px;
  }
  .menu a:hover { background: rgba(0, 0, 0, .04); color: var(--foreground); }
  .menu a[aria-current="page"] {
    background: var(--card); color: var(--foreground);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  }
}

/* ===== cảnh báo dữ liệu cũ ===== */

.canh-bao-cu {
  padding: var(--space-3) var(--space-4);
  background: var(--muted);
  border-bottom: 2px solid var(--accent-gold);
  color: var(--foreground);
  font-size: 16px;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  text-align: center;
}

/* ===== nội dung ===== */

main {
  padding: var(--space-6) var(--space-4) var(--space-16);
}

.khoi-trong { padding: var(--space-6) 0; }
.khoi-trong h1 { font-size: 28px; color: var(--foreground); margin-bottom: var(--space-2); }
.khoi-trong .ghi-chu { color: var(--muted-foreground); font-size: 17px; margin: 0; }

.trang-404 h1 { color: var(--primary); }

.ghi-chu.loi { color: var(--ring); }

/* ===== trang tĩnh dùng chung ===== */

.trang h1 {
  font-size: 28px; color: var(--foreground);
  margin: 0 0 var(--space-4); padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--accent-gold);
}

.bai-doc { max-width: var(--content-narrow); margin: 0 auto; }

/* câu đối */
.cd { text-align: center; padding: 0 0 var(--space-6); margin-bottom: var(--space-6); border-bottom: 2px solid var(--accent-gold); }
.cd--duoi { border-bottom: 0; border-top: 2px solid var(--accent-gold); padding: var(--space-6) 0 0; margin: var(--space-6) 0 0; }
.cd p {
  margin: 0 0 var(--space-2); font-size: 16px; line-height: 1.5;
  letter-spacing: .03em; color: var(--primary); font-weight: 700;
}
.cd p:last-child { margin-bottom: 0; }

/* ===== trang chủ ===== */
.trang-chu { max-width: var(--content-wide); margin: 0 auto; }
.trang-chu-hieu { text-align: center; }
.trang-chu-logo {
  width: 120px; height: 120px; object-fit: contain;
  margin: 0 auto var(--space-4); display: block; background: var(--muted);
  border-radius: var(--radius);
}
.trang-chu h1 { font-size: 38px; border-bottom: 0; padding-bottom: 0; margin: 0 0 var(--space-4); }

.trang-chu-nut {
  display: grid; grid-template-columns: 1fr; gap: var(--space-3);
  margin: var(--space-8) 0 0;
}
.trang-chu-nut__lk {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: 64px; padding: var(--space-4) var(--space-6);
  background: var(--card); color: var(--foreground); text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  font-weight: 700; font-size: 17px; letter-spacing: .01em;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.trang-chu-nut__lk:hover {
  background: var(--accent); border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
}
.trang-chu-nut__lk::after { content: '→'; font-family: 'Noto Serif', serif; font-weight: 700; color: var(--primary); }

@media (min-width: 560px) {
  .trang-chu-nut { grid-template-columns: 1fr 1fr; }
}

.nhan-muc {
  font-size: 13px; letter-spacing: .16em; text-transform: uppercase;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  font-weight: 700; color: var(--muted-foreground);
  margin: var(--space-8) 0 var(--space-3); padding-bottom: var(--space-2); border-bottom: 1px solid var(--border);
}

.gia-tri {
  border-left: 4px solid var(--primary); background: var(--muted);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-3);
}
.gia-tri b { display: block; font-size: 17px; letter-spacing: .04em; color: var(--primary); }
.gia-tri span { font-size: 16px; color: var(--muted-foreground); }

/* ===== nội dung Markdown từ cauHinh ===== */
.md { margin: var(--space-4) 0; }
.md > *:first-child { margin-top: 0; }
.md h2 {
  font-size: 23px; color: var(--primary);
  border-bottom: 2px solid var(--accent-gold); padding-bottom: var(--space-2);
  margin: var(--space-8) 0 var(--space-3);
}
.md h3 { font-size: 20px; color: var(--primary); margin: var(--space-6) 0 var(--space-2); }
.md p { margin: 0 0 var(--space-3); }
.md ul, .md ol { margin: 0 0 var(--space-3); padding-left: 22px; }
.md li { margin-bottom: var(--space-1); }
.md li > ul, .md li > ol { margin-top: var(--space-1); }
.md strong { font-weight: 700; }
.md blockquote {
  border-left: 4px solid var(--primary); background: var(--muted);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: var(--space-4) 0; padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  color: var(--muted-foreground); font-style: normal;
}
.md img { max-width: 100%; height: auto; display: block; margin: var(--space-4) 0; border-radius: var(--radius); }

.md table {
  display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: 0 0 var(--space-4); border-collapse: collapse; white-space: nowrap;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.md th, .md td {
  padding: var(--space-2) var(--space-4); border: 1px solid var(--border); text-align: left;
  font-size: 16px;
}
.md th {
  background: var(--muted); color: var(--primary);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif; font-weight: 700;
  font-size: 13px; letter-spacing: .04em; text-transform: uppercase;
}

/* ===== bộ văn hiến ===== */

.vh-hieu { text-align: center; margin: 0 0 var(--space-8); }
.vh-logo { width: 96px; height: 96px; object-fit: contain; margin: 0 auto var(--space-3); display: block; background: var(--muted); border-radius: var(--radius); }
.vh-ten-ho { font-size: 22px; color: var(--foreground); margin: 0; }

.vh-khoi { margin: var(--space-8) 0 0; }
.vh-anh { width: 100%; height: auto; display: block; background: var(--muted); border-radius: var(--radius); border: 1px solid var(--border); }

.vh-toc-ca {
  margin: 0 0 var(--space-3); background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-3) var(--space-4);
}
.vh-toc-ca:last-child { margin-bottom: 0; }
.vh-toc-ca__ten { margin: 0 0 var(--space-2); font-size: 16px; color: var(--foreground); font-weight: 700; }
.vh-toc-ca audio { width: 100%; display: block; }

.vh-lien-ket { display: flex; flex-direction: column; gap: var(--space-3); margin: var(--space-8) 0 0; }
.vh-lien-ket__lk {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: var(--tap-target); padding: var(--space-3) var(--space-4);
  background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
  color: var(--primary); text-decoration: none;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  font-weight: 700; font-size: 17px;
  transition: background-color .15s ease;
}
.vh-lien-ket__lk:hover { background: var(--accent); }
.vh-lien-ket__lk::after { content: '→'; font-family: 'Noto Serif', serif; font-weight: 700; }

/* ===== danh sách bài viết ===== */

.ds-bai { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.the-bai {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.the-bai:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }

.the-bai__lk {
  display: flex; gap: var(--space-4); align-items: flex-start;
  padding: var(--space-3); text-decoration: none; color: inherit;
  min-height: var(--tap-target);
}
.the-bai__lk:hover .the-bai__tieu-de { color: var(--primary); }

.the-bai__anh {
  width: 84px; height: 84px; flex: 0 0 84px;
  object-fit: cover; background: var(--muted); border-radius: var(--radius);
}
.the-bai__anh--trong { border: 1px solid var(--border); }

.the-bai__noi-dung { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }

.the-bai__nhan {
  align-self: flex-start;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--primary-foreground); background: var(--primary);
  border-radius: 999px; padding: 2px 10px;
}

.the-bai__tieu-de { font-size: 18px; color: var(--foreground); font-weight: 700; line-height: 1.3; }

.the-bai__mo-ta {
  font-size: 16px; color: var(--muted-foreground); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.the-bai__ngay {
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  font-size: 14px; color: var(--muted-foreground); letter-spacing: .02em;
}

/* ===== chi tiết bài viết ===== */

.duong-dan-nho {
  margin: 0 0 var(--space-4); font-size: 15px;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif; font-weight: 600;
}

.bai-chi-tiet__meta {
  margin: 0 0 var(--space-4); color: var(--muted-foreground); font-size: 15px;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
}

.bai-chi-tiet__anh { width: 100%; height: auto; display: block; margin: 0 0 var(--space-4); background: var(--muted); border-radius: var(--radius); }

/* ===== gia phả ===== */
/* Trang này thoát khỏi khung/lề chuẩn của .trang — sơ đồ chiếm trọn màn
   hình dưới header, cuộn/thu phóng để xem thay vì cuộn cả trang. Số âm
   phải khớp đúng padding của main ở trên (24 / 16 / 64). */

.trang.tp { margin: calc(var(--space-6) * -1) calc(var(--space-4) * -1) calc(var(--space-16) * -1); }

.tp-canvas { position: relative; overflow: hidden; background: var(--muted); }
.tp-cay-khung { width: 100%; height: 100%; }

.tp-thanh-cong-cu {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-3); background: var(--card); border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

/* Màn hình đủ rộng — tìm kiếm + điều khiển chung một hàng; hẹp (di động)
   thì giữ hai hàng như mặc định ở trên. */
@media (min-width: 768px) {
  .tp-thanh-cong-cu { flex-direction: row; align-items: flex-start; }
  .tp-tim-khoi { flex: 1 1 auto; }
  .tp-nut-dieu-khien { flex: 0 0 auto; }
}

.tp-tim-khoi { position: relative; }

.tp-tim-input {
  width: 100%; height: var(--tap-target); padding: 0 var(--space-3);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--foreground);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif; font-size: 16px;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.tp-tim-input::placeholder { color: var(--muted-foreground); }
.tp-tim-input:focus-visible { border-color: var(--ring); }

.tp-tim-ket-qua {
  position: absolute; left: 0; right: 0; z-index: 5;
  list-style: none; margin: var(--space-1) 0 0; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .1);
  max-height: 60vh; overflow-y: auto; overflow: hidden auto;
}
.tp-tim-ket-qua li { border-bottom: 1px solid var(--border); }
.tp-tim-ket-qua li:last-child { border-bottom: 0; }
.tp-tim-ket-qua a, .tp-tim-ket-qua button {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  width: 100%; min-height: var(--tap-target); padding: 10px var(--space-3);
  background: transparent; border: 0; color: var(--foreground); text-decoration: none;
  font-family: inherit; text-align: left; cursor: pointer;
  transition: background-color .15s ease;
}
.tp-tim-ket-qua a:hover, .tp-tim-ket-qua button:hover { background: var(--accent); }
.tp-tim-ten { font-size: 16px; font-weight: 600; }
.tp-tim-doi { flex: 0 0 auto; }
.tp-tim-rong { padding: var(--space-4); color: var(--muted-foreground); font-size: 16px; }

.tp-nut-dieu-khien { display: flex; gap: var(--space-2); }
.tp-nut-dieu-khien button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap-target); padding: 0 var(--space-4);
  background: transparent; color: var(--foreground); border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif; font-size: 14px; font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.tp-nut-dieu-khien button:hover { background: var(--accent); border-color: var(--primary); }
.tp-nut-icon { width: 18px; height: 18px; flex: 0 0 auto; }
#tp-nut-che-do { flex: 1; }
#tp-nut-che-do[aria-pressed="true"] { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }

.tp-duong-ve-to { margin: 0 0 var(--space-4); padding-bottom: var(--space-4); border-bottom: 1px solid var(--border); }
.tp-duong-ve-to__cuon {
  display: flex; align-items: center; gap: var(--space-1); margin-top: var(--space-2);
  overflow-x: auto; padding-bottom: var(--space-1); -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}
.tp-duong-ve-to__buoc {
  display: inline-flex; align-items: center; gap: var(--space-2); flex: 0 0 auto;
  min-height: var(--tap-target);
  font-size: 15px; color: var(--foreground); text-decoration: none; padding: var(--space-1) var(--space-2);
  border-radius: var(--radius);
}
.tp-duong-ve-to__buoc:hover { color: var(--primary); background: var(--accent); }
.tp-duong-ve-to__doi {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; flex: 0 0 auto; padding: 0 6px;
  background: var(--muted); color: var(--primary); border-radius: 999px;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif; font-size: 12px; font-weight: 700;
}
.tp-duong-ve-to__cham { color: var(--muted-foreground); flex: 0 0 auto; }

/* ===== sơ đồ gia phả — xổ ngang, đời thành cột ===== */
/* Kích thước node khớp DT_RONG_NODE/DT_CAO_GON/DT_CAO_CHI_TIET trong
   tocpha.js — đổi ở một chỗ thì phải đổi cả hai. */

.tp-dt-boc, .tp-dt-cuon { width: 100%; height: 100%; }

.tp-dt-cuon {
  position: relative; overflow: auto;
  padding: var(--space-4) var(--space-4) 40px;
}

.tp-dt-khung-zoom { position: relative; }
.tp-dt-vien { position: relative; }

.tp-dt-duong { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.tp-dt-nhanh { fill: none; stroke: var(--muted-foreground); stroke-width: 1.5px; }

/* Hàng nhãn "Đời N" — anh em của khung-zoom (không nằm trong .tp-dt-vien bị
   scale), dính ở đầu vùng cuộn (sticky theo trục dọc) trong khi vẫn trôi
   ngang cùng nội dung — kỹ thuật hàng tiêu đề dính chuẩn của bảng cuộn. Có
   chiều cao + nền thật (không phải chỉ overlay trong suốt) để tự đẩy toàn
   bộ cây xuống bằng dòng chảy DOM bình thường — node không bao giờ cuộn
   đè lên nhãn dù đang canh giữa ở bất kỳ vị trí nào trong cây. */
.tp-dt-hang-doi {
  position: sticky; top: 0; z-index: 4;
  height: 36px;
  background: var(--muted); border-bottom: 1px solid var(--border);
}
.tp-dt-nhan-doi {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  pointer-events: none;
}

.tp-dt-khoi {
  position: absolute; box-sizing: border-box; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
  padding: var(--space-3) var(--space-4);
  background: var(--card); color: var(--foreground);
  border: 1.5px solid var(--muted-foreground); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
  transition: left .3s ease, top .3s ease, opacity .25s ease, transform .25s ease, border-color .15s ease;
}
.tp-dt-khoi--co-nut-mo .tp-dt-the { padding-right: 32px; }
.tp-dt-khoi--moi { opacity: 0; transform: scale(.82); }
.tp-dt-khoi--thu {
  opacity: 0 !important; transform: scale(.82); pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
.tp-dt-khoi--goc { border-color: var(--primary); border-width: 2px; }
.tp-dt-khoi--chon { border-color: var(--primary); border-width: 2px; background: var(--muted); }

.tp-dt-the {
  width: 100%; height: 100%; text-align: left; background: transparent; border: 0; padding: 0;
  display: flex; flex-direction: column; justify-content: center; overflow: hidden;
  color: inherit; cursor: pointer; font-family: 'Be Vietnam Pro', system-ui, sans-serif;
}
.tp-dt-ten {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; flex: 0 0 auto;
  overflow: hidden; font-size: 16px; font-weight: 700; line-height: 1.3; overflow-wrap: break-word;
  color: var(--foreground);
}
.tp-dt-meta-nho {
  display: flex; flex-direction: column; gap: 2px; margin-top: 3px; flex: 0 0 auto;
}
.tp-dt-meta-dong {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500; line-height: 1.3; color: var(--muted-foreground);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tp-dt-meta-icon { width: 11px; height: 11px; flex: 0 0 auto; }

.tp-dt-nut-mo {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--primary); border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
  font-size: 15px; font-weight: 700; line-height: 1; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.tp-dt-nut-mo:hover, .tp-dt-nut-mo[aria-expanded="true"] { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }

/* ===== hồ sơ một người ===== */
/* Thiếu dữ liệu là mặc định — thẻ phải gọn gàng dù chỉ có tên và hiệu. */

.ho-so-the {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  border-top: 4px solid var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
  padding: var(--space-6) var(--space-4);
}

.ho-so-anh {
  width: 100%; max-width: 220px; height: auto; display: block;
  margin: 0 0 var(--space-4); background: var(--muted); border-radius: var(--radius);
}

.ho-so-ten { font-family: 'Noto Serif', serif; font-weight: 700; font-size: 23px; color: var(--foreground); }
.ho-so-meta { margin-top: var(--space-2); display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.ho-so-meta-text { font-size: 16px; color: var(--muted-foreground); }

/* Icon Lucide nhỏ mở đầu mỗi dòng dữ liệu — kích thước cố định, không co
   theo nội dung, màu chữ phụ. */
.ho-so-icon { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 3px; color: var(--muted-foreground); }

.ho-so-dong {
  display: flex; align-items: flex-start; gap: var(--space-2);
  margin-top: var(--space-2); font-size: 16px; color: var(--foreground); line-height: 1.6;
}
.ho-so-dong--dam { font-weight: 700; }
.ho-so-tieu-su {
  display: flex; align-items: flex-start; gap: var(--space-2);
  margin: var(--space-2) 0 0; font-size: 16px; color: var(--foreground); line-height: 1.6;
}

.ho-so-nut-map {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap-target);
  margin-top: var(--space-2); padding: 0 var(--space-4);
  border: 1px solid var(--primary); border-radius: var(--radius); color: var(--primary);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif; font-size: 15px; font-weight: 600;
  text-decoration: none;
  transition: background-color .15s ease;
}
.ho-so-nut-map .ho-so-icon { margin-top: 0; color: var(--primary); }
.ho-so-nut-map:hover { background: var(--accent); }

.ho-so-quan-he { margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--border); }

.ho-so-quan-he-hang {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2);
  margin-top: var(--space-3);
}
.ho-so-quan-he-hang:first-child { margin-top: 0; }
.ho-so-quan-he-hang .ho-so-icon { margin-top: 0; }
.ho-so-quan-he-nhan { flex: 0 0 auto; font-size: 15px; color: var(--muted-foreground); }
.ho-so-quan-he-lk {
  display: inline-flex; align-items: center; min-height: var(--tap-target);
  padding: 6px var(--space-3); background: var(--muted); border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground); font-weight: 600; font-size: 15px; text-decoration: none;
  transition: border-color .15s ease, color .15s ease;
}
.ho-so-quan-he-lk:hover { border-color: var(--primary); color: var(--primary); }

.ho-so-album { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.ho-so-album img { width: 84px; height: 84px; object-fit: cover; display: block; background: var(--muted); border-radius: var(--radius); }

/* nhãn nhỏ bo tròn cho đời / phái / ngành */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 999px;
  background: var(--muted); color: var(--muted-foreground);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  font-weight: 600; font-size: 12px; letter-spacing: .03em; line-height: 1.7;
  white-space: nowrap;
}
.badge-primary { background: var(--primary); color: var(--primary-foreground); }

/* ===== popup hồ sơ (bấm vào bất kỳ người nào trong cây) ===== */

.tp-popup {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: var(--space-4);
}
.tp-popup__nen { position: absolute; inset: 0; background: rgba(42, 24, 16, .55); }
.tp-popup__hop {
  position: relative; z-index: 1;
  width: 100%; max-width: var(--content-narrow); max-height: calc(100vh - 40px);
  overflow-y: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .16);
  padding: 44px var(--space-4) var(--space-4);
  animation: tp-popup-vao .18s ease;
}
@keyframes tp-popup-vao {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.tp-popup__dong {
  position: absolute; top: var(--space-2); right: var(--space-2); width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--muted); color: var(--foreground); border: 0; border-radius: 50%;
  font-size: 22px; line-height: 1;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.tp-popup__dong:hover { background: var(--primary); color: var(--primary-foreground); }
.tp-popup-noi-dung .ho-so-the { border: 0; border-top: 0; padding: 0; box-shadow: none; }

/* ===== kho tư liệu ===== */

.tl-thanh-cong-cu {
  display: flex; flex-direction: column; gap: var(--space-3);
  margin: var(--space-4) 0;
}
.tl-tim-input {
  width: 100%; height: var(--tap-target); padding: 0 var(--space-3);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--foreground);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif; font-size: 16px;
  transition: border-color .15s ease;
}
.tl-tim-input::placeholder { color: var(--muted-foreground); }
.tl-tim-input:focus-visible { border-color: var(--ring); }

.tl-loc { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.tl-loc__nut {
  min-height: var(--tap-target); padding: 0 var(--space-4);
  background: transparent; color: var(--foreground); border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.tl-loc__nut:hover { background: var(--accent); border-color: var(--primary); }
.tl-loc__nut[aria-pressed="true"] { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }

@media (min-width: 768px) {
  .tl-thanh-cong-cu { flex-direction: row; align-items: center; }
  .tl-tim-khoi { flex: 1 1 auto; }
}

/* Số cột tự co giãn theo bề rộng khung (auto-fill/minmax) — không cần
   media query riêng cho từng cỡ màn hình. */
.tl-luoi {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3); margin-top: var(--space-4);
}

.tl-o {
  display: flex; flex-direction: column; gap: var(--space-2);
  background: transparent; border: 0; padding: 0; cursor: pointer; text-align: left;
  font-family: inherit;
}
.tl-o[hidden] { display: none; }

.tl-khung-anh {
  position: relative; aspect-ratio: 1 / 1; overflow: hidden;
  background: var(--muted); border: 1px solid var(--border); border-radius: var(--radius);
}
.tl-khung-anh--video { aspect-ratio: 16 / 9; }
.tl-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tl-video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }

/* File chưa có trên R2 (hoặc lỗi tải) — giữ nguyên khung ô, làm mờ cả ô,
   tên file bên dưới (.tl-ten) là thứ duy nhất còn thấy rõ. */
.tl-o--loi { opacity: .5; cursor: default; }

.tl-ten {
  display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: 13px; color: var(--muted-foreground);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
}

.tl-lightbox {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: var(--space-4);
}
.tl-lightbox__nen { position: absolute; inset: 0; background: rgba(0, 0, 0, .85); }
.tl-lightbox__hop {
  position: relative; z-index: 1;
  width: 100%; max-width: 1100px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; align-items: center;
  animation: tp-popup-vao .18s ease;
}
.tl-lightbox__noi-dung {
  width: 100%; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
.tl-lightbox__img { max-width: 100%; max-height: calc(100vh - 140px); display: block; border-radius: var(--radius); }
.tl-lightbox__ten {
  margin: var(--space-3) 0 0; color: var(--primary-foreground); font-size: 15px; text-align: center;
}
.tl-lightbox__ghi-chu {
  margin: var(--space-1) 0 0; color: rgba(250, 249, 245, .72); font-size: 14px; text-align: center;
  max-width: 640px;
}
.tl-lightbox__dong {
  position: absolute; top: -52px; right: 0; width: var(--tap-target); height: var(--tap-target);
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: var(--card); color: var(--foreground); border: 0; font-size: 22px; line-height: 1;
  cursor: pointer; z-index: 2;
  transition: background-color .15s ease;
}
.tl-lightbox__dong:hover { background: var(--accent-gold); }

.tl-lightbox__truoc, .tl-lightbox__sau {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: var(--tap-target); height: var(--tap-target); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--foreground); border: 0; font-size: 28px; line-height: 1;
  cursor: pointer; z-index: 2;
  transition: background-color .15s ease;
}
.tl-lightbox__truoc { left: var(--space-2); }
.tl-lightbox__sau { right: var(--space-2); }
.tl-lightbox__truoc:hover, .tl-lightbox__sau:hover { background: var(--accent-gold); }

/* ===== footer ===== */

footer {
  padding: var(--space-6) var(--space-4);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 15px;
  color: var(--muted-foreground);
}

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