/* Trang tĩnh /luat — không dùng Tailwind/React. Màu, font lấy theo token của app (src/styles.css) và trang pháp lý. */
:root {
  --font-sans: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Merriweather", "Times New Roman", Georgia, serif;
  --font-mono: "DM Mono", monospace;
  --ink: #36131d;
  --muted: #7d5962;
  --line: #dec9cd;
  --paper: #fffdfa;
  --wash: #f7f3ed;
  --accent: #c20e35;
  --accent-dark: #92102e;
  --accent-soft: #f8dfe4;
  --warning: #8c5a16;
  --success: #2f7a4f;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--wash);
  color: var(--ink);
  font: 16px/1.75 var(--font-sans);
  font-synthesis: none;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-dark); }

/* Header: logo giống màn trợ lý (AppMark: LegalIcon + BrandWordmark). */
header.site { display: flex; justify-content: space-between; align-items: center; gap: 12px; max-width: 52rem; margin: 0 auto; padding: 12px 16px; font-size: 15px; }
header.site .brand { display: flex; align-items: center; gap: 12px; min-width: 0; text-decoration: none; }
.brand-icon { display: grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; color: #991b1b; border: 1px solid #e5e0d6; border-radius: 12px; }
.brand-mask { width: 25px; height: 25px; background-color: currentColor; -webkit-mask: url("/legal-icon-mask.png") no-repeat center / contain; mask: url("/legal-icon-mask.png") no-repeat center / contain; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; color: #8b1d1d; }
.brand-name small { font-size: 14px; font-weight: 600; color: #a8a29e; }
.brand-tagline { margin-top: 2px; font-size: 9.5px; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: #78716c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.site .nav { display: flex; gap: 20px; flex: 0 0 auto; font-weight: 600; text-decoration: none; }
header.site nav.nav a { color: var(--muted); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
header.site nav.nav a:hover { color: var(--accent-dark); }
header.site nav.nav a.on { color: var(--accent); border-bottom-color: var(--accent); }

/* Thẻ nội dung như .legal-doc-card */
main { max-width: 52rem; margin: 8px auto 0; padding: 2.25rem 2.75rem; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 28px rgba(54, 19, 29, 0.04); }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 0; margin: 0 0 1.25rem; font-size: 0.84rem; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin-right: 4px; }
.crumbs a { color: var(--muted); }
.kicker { margin: 0; font: 500 0.72rem/1.5 var(--font-mono); text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent); }
h1 { font-family: var(--font-serif); font-size: clamp(1.5rem, 2.6vw, 2rem); font-weight: 700; line-height: 1.3; letter-spacing: -0.02em; margin: 0.5rem 0 0.6rem; }
h2 { font-family: var(--font-serif); font-size: 1.15rem; font-weight: 700; line-height: 1.4; margin: 2rem 0 0.6rem; }
h3 { font-size: 0.95rem; font-weight: 600; margin: 1.25rem 0 0.4rem; color: var(--muted); }
.doc, .sub { margin: 0; font-size: 0.88rem; color: var(--muted); }
.doc a { color: var(--muted); }

/* Hộp hiệu lực */
.status { list-style: none; margin: 1.25rem 0 1.75rem; padding: 0.9rem 1.1rem; background: var(--wash); border: 1px solid var(--line); border-radius: 10px; font-size: 0.88rem; line-height: 1.6; }
.status li + li { margin-top: 0.35rem; }
.status .ok { color: var(--success); font-weight: 600; }
.status .off { color: var(--warning); font-weight: 600; }

/* Nguyên văn */
.text p { margin: 0 0 0.75rem; }
.text p.diem { padding-left: 1.25rem; }
/* Khoản/điểm đã bị sửa đổi, bãi bỏ: giữ nguyên văn cũ nhưng in mờ, ghi chú ngay bên dưới. */
.text .superseded { color: var(--muted); }
.text p.change { margin: -0.35rem 0 0.9rem; padding: 0.4rem 0.75rem; border-left: 3px solid var(--warning); background: #fbf3e6; font-size: 0.85rem; line-height: 1.55; }
.text p.change.diem { margin-left: 1.25rem; }
.table { overflow-x: auto; margin: 0 0 1rem; }
table { border-collapse: collapse; font-size: 0.9rem; width: 100%; }
th, td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
th { background: var(--wash); font-weight: 600; }
.notes, .amends { font-size: 0.88rem; }
.notes ul, .amends ul { padding-left: 1.1rem; }
.notes li, .amends li { margin: 0.3rem 0; color: var(--muted); }

.ask { margin: 2rem 0 0; }
.button { display: inline-block; padding: 0.7rem 1.25rem; border-radius: 10px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; }
.button:hover { background: var(--accent-dark); color: #fff; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); font-size: 0.9rem; font-weight: 600; }
.pager a { text-decoration: none; }

/* Trang văn bản, thư viện */
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 1.25rem 0; font-size: 0.9rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.toc ul, .library { padding-left: 1.1rem; }
.toc li, .library li { margin: 0.35rem 0; }
.toc a, .library a { text-decoration: none; }
.toc a:hover, .library a:hover { text-decoration: underline; }
.library .sub { display: block; }
.group h2 .sub { font-family: var(--font-sans); font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.filter input { width: 100%; max-width: 26rem; padding: 0.6rem 0.8rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font: inherit; font-size: 0.95rem; }
.filter input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* Nút nổi "Hỏi trợ lý" (trang Điều): góc phải dưới, ẩn khi nút cuối bài đã hiện. */
.ask-float { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 10; padding: 0.6rem 1rem; border-radius: 999px; background: var(--accent); color: #fff; font-size: 0.9rem; font-weight: 600; text-decoration: none; box-shadow: 0 6px 20px rgba(54, 19, 29, 0.25); transition: opacity 0.2s, transform 0.2s; }
.ask-float:hover { background: var(--accent-dark); color: #fff; }
.ask-float.is-hidden { opacity: 0; transform: translateY(8px); pointer-events: none; }

/* Cụm nổi ‹ Mục lục › (trang Điều, luat.js tạo): góc trái dưới, màu trung tính; popup mở ngay phía trên. */
.toc-dock { position: fixed; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 10; display: flex; align-items: center; padding: 3px; background: #fff; border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 6px 20px rgba(54, 19, 29, 0.12); }
.toc-step { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 999px; color: var(--muted); font-size: 1.25rem; line-height: 1; text-decoration: none; }
a.toc-step:hover { background: var(--wash); color: var(--ink); }
span.toc-step { opacity: 0.35; }
.toc-open { height: 34px; padding: 0 0.7rem; border: 0; border-radius: 999px; background: none; color: var(--ink); font: 600 0.9rem/1 var(--font-sans); cursor: pointer; }
.toc-open:hover, .toc-open[aria-expanded="true"] { background: var(--wash); }
.toc-pop { position: fixed; left: 16px; bottom: calc(66px + env(safe-area-inset-bottom, 0px)); z-index: 20; display: flex; flex-direction: column; width: min(24rem, calc(100vw - 32px)); max-height: min(70vh, 36rem); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(54, 19, 29, 0.18); }
.toc-pop[hidden] { display: none; }
.toc-pop-head { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0.5rem 0.4rem 1rem; font-size: 0.9rem; font-weight: 600; }
.toc-pop-head a { color: var(--ink); text-decoration: none; }
.toc-pop-head a:hover { text-decoration: underline; }
.toc-close { width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.toc-close:hover { background: var(--wash); color: var(--ink); }
/* 16px: Safari iOS không tự phóng to khi chạm vào ô. */
.toc-pop input { margin: 0 1rem 0.75rem; padding: 0.45rem 0.75rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); font: inherit; font-size: 1rem; }
.toc-pop input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.toc-pop-list { position: relative; overflow-y: auto; overscroll-behavior: contain; padding: 0 0.6rem 0.6rem; border-top: 1px solid var(--line); }
/* Danh sách màu trung tính như bản mẫu (stone), chỉ Điều đang đọc mang màu thương hiệu nhạt. */
.toc-pop-list h2 { margin: 0.8rem 0.4rem 0.25rem; font: 700 0.7rem/1.45 var(--font-sans); text-transform: uppercase; letter-spacing: 0.05em; color: #78716c; }
.toc-pop-list h3 { margin: 0.5rem 0.4rem 0.2rem; font: 600 0.68rem/1.45 var(--font-sans); text-transform: uppercase; letter-spacing: 0.03em; color: #a8a29e; }
.toc-pop-list ul { list-style: none; padding: 0; margin: 0; }
.toc-pop-list li { margin: 1px 0; font-size: 0.85rem; line-height: 1.45; }
.toc-pop-list li a { display: block; padding: 5px 0.6rem; border: 1px solid transparent; border-radius: 8px; color: #44403c; text-decoration: none; }
.toc-pop-list li a:hover { background: #fafaf9; border-color: #e7e5e4; color: #1c1917; }
.toc-pop-list a[aria-current="page"] { background: #fdf2f4; border-color: #f4c2cd; color: var(--ink); font-weight: 600; }
.toc-pop-note { margin: 0.9rem 0.4rem 0.25rem; font-size: 0.88rem; color: var(--muted); }
.has-toc-dock footer.site { padding-bottom: 5.5rem; } /* chừa chỗ cho hai nút nổi, không che chữ cuối trang */

/* Phong cách phẳng (website 1: thư viện, mục lục, trang Điều) — bỏ thẻ trắng, chữ nằm trên nền.
   .wide: thư viện + mục lục rộng 80rem, danh sách 2 cột. Website 2 (/tin, /hoi-dap) chưa dùng. */
body.flat { background: #fff; } /* trắng như /tin (body.news) để hai website cùng một nền */
.flat main { margin-top: 0; padding: 0.5rem 16px 0; background: none; border: 0; border-radius: 0; box-shadow: none; }
.wide header.site, .wide main, .wide footer.site { max-width: 80rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; padding-bottom: 0.9rem; margin-bottom: 1.5rem; border-bottom: 1.5px solid var(--line); }
.page-head h1 { margin: 0; }
.page-head .filter { margin: 0 0 0 auto; display: flex; align-items: center; gap: 10px; }
.page-head .meta { flex-basis: 100%; display: block; margin: 0; font-size: 0.88rem; color: var(--muted); }
.filter[hidden] { display: none; } /* các khối .filter dùng display:flex, không được đè hidden khi tắt JS */
.filter-count { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.wide .filter input { width: 22rem; max-width: 100%; padding: 0.45rem 0.75rem; font-size: 0.9rem; border-radius: 6px; }
.meta .ok, .library .ok { color: var(--success); font-weight: 500; }
.meta .off, .library .soon { color: var(--warning); font-weight: 500; }
.library .expired { color: #a33a3a; font-weight: 600; }
.library li.expired > a { text-decoration: line-through; }

.columns { column-count: 2; column-gap: 3rem; }
.columns .group { break-inside: avoid; margin-bottom: 1.75rem; }
.columns .group h2, .columns .chapter h2 { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 0.5rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--line); font: 700 0.82rem/1.45 var(--font-sans); text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); break-after: avoid; }
.columns .group h2 .count { color: var(--accent); }
.columns .library { list-style: none; padding: 0; margin: 0; }
.columns .library li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 0.9rem; line-height: 1.5; }
.columns .library li > a { font-weight: 600; }
.columns .library .sub { display: inline; flex: 0 0 auto; font-size: 0.8rem; text-align: right; font-variant-numeric: tabular-nums; }

.toc-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 1.25rem; }
.toc-bar .toc-title { margin: 0; font: 500 0.9rem/1.5 var(--font-sans); color: var(--muted); }
.toc-bar .toc-title strong { color: var(--ink); }
.toc-bar .filter { margin: 0; display: flex; align-items: center; gap: 10px; }
.columns .chapter { margin-bottom: 1.75rem; }
.columns .chapter h3 { margin: 0.6rem 0 0.25rem; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; color: var(--warning); break-after: avoid; }
.toc .columns ul { list-style: none; padding: 0; margin: 0; }
.toc .columns li { margin: 0; padding: 2px 0; font-size: 0.9rem; line-height: 1.5; break-inside: avoid; }

/* Trang Điều: hộp hiệu lực thành dòng thông tin có gạch chân như mục lục. */
.flat .status { margin: 1rem 0 1.75rem; padding: 0 0 0.9rem; background: none; border: 0; border-bottom: 1.5px solid var(--line); border-radius: 0; }

footer.site { max-width: 52rem; margin: 0 auto; padding: 1.5rem 16px 3rem; color: var(--muted); font-size: 0.82rem; }

@media (max-width: 640px) {
  main { margin: 0 10px; padding: 1.5rem 1.1rem; }
  header.site { padding: 10px 12px; }
}
@media (max-width: 860px) {
  .columns { column-count: 1; }
  .page-head .filter, .toc-bar .filter { flex: 1 1 100%; margin: 0.4rem 0 0; }
  .wide .filter input { width: 100%; }
  .columns .library li { flex-direction: column; gap: 0; }
  .columns .library .sub { text-align: left; }
}
@media (max-width: 640px) {
  .flat main { margin: 0; padding: 0.5rem 16px 0; }
  header.site { flex-wrap: wrap; row-gap: 6px; }
  header.site nav.nav { width: 100%; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; }
}
