:root {
    --bg: #FAF6EE;
    --surface: #FFFFFF;
    --surface-warm: #F4ECDD;
    --ink: #221B17;
    --ink-muted: #5E5248;
    --crimson: #8C1D18;
    --crimson-dark: #68120E;
    --gold: #B6862C;
    --gold-soft: #EFE3C4;
    --border: #E5D9C3;
    --radius: 12px;
    --shadow: 0 6px 24px rgba(45, 28, 12, 0.07);
    --font-sans: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
    --font-serif: 'Noto Serif', Georgia, serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    font-size: 15px;
}
a { color: var(--crimson); text-decoration: none; }
a:hover { text-decoration: underline; }

.pv-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 18px;
}

/* Header */
.pv-header {
    background: var(--surface);
    border-bottom: 2px solid var(--gold-soft);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 10px rgba(45, 28, 12, 0.04);
}
.pv-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    gap: 16px;
}
.pv-brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    text-decoration: none !important;
    color: var(--ink);
}
.pv-seal {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--crimson);
    color: #FDF5E6;
    font-family: var(--font-serif);
    font-size: 24px;
    font-weight: 700;
    display: grid;
    place-items: center;
    border: 2px solid var(--gold);
    box-shadow: 0 2px 6px rgba(140, 29, 24, 0.25);
    flex-shrink: 0;
}
.pv-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.pv-brand-text strong {
    font-family: var(--font-serif);
    font-size: 19px;
    color: var(--crimson);
    letter-spacing: 0.2px;
}
.pv-brand-text small { font-size: 11.5px; color: var(--ink-muted); }

.pv-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pv-nav a {
    padding: 8px 13px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--ink);
    text-decoration: none;
    transition: background .15s, color .15s;
}
.pv-nav a:hover, .pv-nav a.active {
    background: var(--surface-warm);
    color: var(--crimson);
}
.pv-nav a.pv-nav-btn {
    background: var(--crimson);
    color: #FFF;
    margin-left: 6px;
}
.pv-nav a.pv-nav-btn:hover { background: var(--crimson-dark); color: #FFF; }
.pv-menu-toggle {
    display: none;
    background: var(--surface-warm);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 18px;
    cursor: pointer;
    color: var(--crimson);
}

/* Hero & 4-Tab Search */
.pv-hero {
    background:
        radial-gradient(circle at 12% 20%, rgba(182, 134, 44, 0.14), transparent 45%),
        radial-gradient(circle at 88% 15%, rgba(140, 29, 24, 0.12), transparent 45%),
        linear-gradient(180deg, #F5ECD9 0%, #FAF6EE 100%);
    border-bottom: 1px solid var(--border);
    padding: 40px 0 44px;
}
.pv-hero-head { text-align: center; max-width: 780px; margin: 0 auto 24px; }
.pv-kicker {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--gold);
    color: var(--crimson);
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 12px;
}
.pv-hero h1 {
    font-family: var(--font-serif);
    font-size: clamp(26px, 4vw, 38px);
    line-height: 1.25;
    margin: 0 0 10px;
    color: var(--crimson-dark);
}
.pv-hero-sub {
    margin: 0;
    color: var(--ink-muted);
    font-size: 15.5px;
}

.pv-search-box {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
    max-width: 980px;
    margin: 0 auto;
}
.pv-search-tabs {
    display: flex;
    background: var(--surface-warm);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.pv-search-tab {
    flex: 1 0 auto;
    padding: 13px 16px;
    border: none;
    background: transparent;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all .15s;
    white-space: nowrap;
}
.pv-search-tab:hover { color: var(--crimson); background: rgba(255,255,255,0.5); }
.pv-search-tab.active {
    background: var(--surface);
    color: var(--crimson);
    border-bottom-color: var(--crimson);
}
.pv-search-panel { padding: 20px; }
.pv-search-panel[hidden] { display: none; }

.pv-search-row {
    display: grid;
    grid-template-columns: 1fr 180px 180px auto;
    gap: 10px;
    align-items: stretch;
}
.pv-search-row-3 { grid-template-columns: 1fr 220px auto; }
.pv-search-row-4 { grid-template-columns: 180px 140px 140px 1fr auto; }

.pv-input, .pv-select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 14.5px;
    background: #FFF;
    color: var(--ink);
    outline: none;
    transition: border-color .15s;
}
.pv-input:focus, .pv-select:focus { border-color: var(--crimson); }

.pv-search-hints {
    margin-top: 12px;
    font-size: 13px;
    color: var(--ink-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.pv-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 11px;
    border-radius: 999px;
    background: var(--surface-warm);
    border: 1px solid var(--border);
    color: var(--ink);
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}
.pv-chip:hover {
    border-color: var(--crimson);
    color: var(--crimson);
    text-decoration: none;
}

/* Buttons */
.pv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    border: 1.5px solid transparent;
    cursor: pointer;
    text-decoration: none !important;
    transition: all .15s;
    white-space: nowrap;
}
.pv-btn-primary { background: var(--crimson); color: #FFF; }
.pv-btn-primary:hover { background: var(--crimson-dark); color: #FFF; }
.pv-btn-gold { background: var(--gold); color: #FFF; }
.pv-btn-gold:hover { background: #9B7020; color: #FFF; }
.pv-btn-outline { background: #FFF; color: var(--crimson); border-color: var(--crimson); }
.pv-btn-outline:hover { background: var(--surface-warm); }
.pv-btn-ghost { background: var(--surface-warm); color: var(--ink); border-color: var(--border); }
.pv-btn-ghost:hover { border-color: var(--crimson); color: var(--crimson); }
.pv-btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* Stats Bar */
.pv-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-top: 24px;
}
.pv-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.pv-stat-num {
    font-family: var(--font-serif);
    font-size: 26px;
    font-weight: 700;
    color: var(--crimson);
    line-height: 1.15;
}
.pv-stat-label { font-size: 13px; color: var(--ink-muted); margin-top: 4px; }

/* Sections */
.pv-section { padding: 40px 0; }
.pv-section-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.pv-section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.pv-section-head h2 {
    font-family: var(--font-serif);
    font-size: 24px;
    margin: 0;
    color: var(--crimson-dark);
}
.pv-section-head p { margin: 4px 0 0; color: var(--ink-muted); font-size: 14.5px; }

/* Lineage Cards */
.pv-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.pv-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.pv-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--gold);
}
.pv-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pv-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--surface-warm);
    color: var(--crimson);
    border: 1px solid var(--border);
}
.pv-badge-gold { background: #FDF4DC; color: #8A5E0A; border-color: #E5C982; }
.pv-badge-warn { background: #FDECEC; color: #991B1B; border-color: #F5C2C2; }
.pv-badge-verified { background: #E6F6EC; color: #166534; border-color: #86EFAC; }
.pv-related-box {
    margin-top: 20px;
    background: var(--surface);
    border: 1.5px solid var(--gold-soft);
    border-radius: var(--radius);
    padding: 20px;
}
.pv-related-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 13px 0;
    border-bottom: 1px dashed var(--border);
    flex-wrap: wrap;
}
.pv-related-item:last-child { border-bottom: none; padding-bottom: 0; }

.pv-card-title {
    font-family: var(--font-serif);
    font-size: 16.5px;
    font-weight: 700;
    line-height: 1.35;
    margin: 0;
}
.pv-card-title a { color: var(--ink); }
.pv-card-title a:hover { color: var(--crimson); text-decoration: none; }
.pv-card-meta {
    font-size: 13px;
    color: var(--ink-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.pv-card-desc {
    font-size: 13.5px;
    color: var(--ink-muted);
    margin: 0;
    flex: 1;
}
.pv-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}

/* Province pills */
.pv-province-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.pv-province-pill {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none !important;
}
.pv-province-pill span {
    background: var(--surface-warm);
    color: var(--crimson);
    font-size: 12px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
}
.pv-province-pill:hover { border-color: var(--crimson); background: #FFFDF8; }

/* Services Grid */
.pv-service-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.pv-service-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.pv-service-icon { font-size: 28px; line-height: 1; }
.pv-service-card h3 {
    font-family: var(--font-serif);
    font-size: 16.5px;
    margin: 0;
    color: var(--crimson-dark);
}
.pv-service-card p { font-size: 13.5px; color: var(--ink-muted); margin: 0; flex: 1; }

/* Lineage Detail Page */
.pv-breadcrumb {
    font-size: 13px;
    color: var(--ink-muted);
    margin: 0 0 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.pv-lineage-hero {
    background: linear-gradient(180deg, #F4EBDA 0%, #FAF6EE 100%);
    border-bottom: 1px solid var(--border);
    padding: 26px 0 22px;
}
.pv-lineage-hero h1 {
    font-family: var(--font-serif);
    font-size: clamp(22px, 3vw, 30px);
    color: var(--crimson-dark);
    margin: 0 0 10px;
}
.pv-lineage-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 14px;
    color: var(--ink-muted);
    margin-bottom: 16px;
}
.pv-tabs-bar {
    display: flex;
    gap: 6px;
    border-bottom: 2px solid var(--border);
    margin: 22px 0 20px;
    overflow-x: auto;
}
.pv-tab-btn {
    padding: 11px 18px;
    border: none;
    background: transparent;
    font-family: var(--font-sans);
    font-size: 14.5px;
    font-weight: 600;
    color: var(--ink-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
}
.pv-tab-btn.active {
    color: var(--crimson);
    border-bottom-color: var(--crimson);
    background: var(--surface);
    border-radius: 8px 8px 0 0;
}
.pv-tab-pane[hidden] { display: none; }

/* Tree Viewer */
.pv-tree-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    padding: 12px 14px;
}
.pv-tree-stage-wrap {
    position: relative;
    background: #FFFDF9;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 12px 12px;
    height: 620px;
    overflow: hidden;
}
.pv-tree-canvas {
    width: 100%;
    height: 100%;
    cursor: grab;
    user-select: none;
}
.pv-tree-canvas:active { cursor: grabbing; }
.pv-node-drawer {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 340px;
    max-width: calc(100% - 24px);
    max-height: calc(100% - 24px);
    overflow-y: auto;
    background: var(--surface);
    border: 1.5px solid var(--gold);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(34, 27, 23, 0.18);
    padding: 16px;
    z-index: 20;
}
.pv-node-drawer[hidden] { display: none; }

/* Narrative / Phả ký */
.pv-gen-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
}
.pv-gen-head {
    background: var(--surface-warm);
    padding: 10px 16px;
    font-family: var(--font-serif);
    font-weight: 700;
    color: var(--crimson-dark);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}
.pv-person-item {
    padding: 14px 16px;
    border-bottom: 1px solid #F1E8D8;
}
.pv-person-item:last-child { border-bottom: none; }
.pv-person-item:target { background: #FFF8E1; }
.pv-person-name {
    font-family: var(--font-serif);
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
}
.pv-person-bio {
    margin-top: 6px;
    font-size: 14px;
    color: #3A312A;
    white-space: pre-line;
}

/* Search Result Item */
.pv-result-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 12px;
}
.pv-path-crumb {
    font-size: 12.5px;
    color: var(--ink-muted);
    background: var(--bg);
    padding: 6px 10px;
    border-radius: 8px;
    margin: 8px 0;
}

/* Bai Vi & Cau Doi Preview */
.pv-culture-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.pv-baivi-preview {
    background: linear-gradient(180deg, #5A110E 0%, #3E0A08 100%);
    color: #F6D57A;
    border: 4px double #D8AE48;
    border-radius: 16px 16px 6px 6px;
    padding: 26px 22px;
    text-align: center;
    max-width: 300px;
    margin: 0 auto;
    box-shadow: 0 10px 26px rgba(62, 10, 8, 0.25);
    font-family: var(--font-serif);
}
.pv-baivi-top { font-size: 13px; letter-spacing: 2px; opacity: .88; margin-bottom: 10px; }
.pv-baivi-main { font-size: 22px; font-weight: 700; line-height: 1.45; margin: 12px 0; color: #FFE394; }
.pv-baivi-sub { font-size: 13.5px; line-height: 1.6; color: #F5E6C4; }

.pv-caudoi-box {
    background: #4E0D0A;
    color: #F8D97C;
    border: 3px double #D8AE48;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    font-family: var(--font-serif);
}
.pv-hoanhphi {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 3px;
    border-bottom: 1px solid rgba(216,174,72,0.4);
    padding-bottom: 10px;
    margin-bottom: 14px;
}
.pv-caudoi-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    font-size: 15px;
    line-height: 1.6;
}

/* Pagination */
.pv-pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 24px;
}
.pv-page-link {
    padding: 8px 13px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--ink);
    font-weight: 600;
    font-size: 13.5px;
}
.pv-page-link.active {
    background: var(--crimson);
    color: #FFF;
    border-color: var(--crimson);
}

/* Footer */
.pv-footer {
    background: #231915;
    color: #DFD4C3;
    padding-top: 42px;
    margin-top: 30px;
}
.pv-footer-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr 1fr;
    gap: 28px;
    padding-bottom: 32px;
}
.pv-brand-footer strong { color: #F5D57A; }
.pv-brand-footer small { color: #C7B9A5; }
.pv-footer-desc { font-size: 13.5px; color: #BFB29E; margin-top: 12px; }
.pv-footer h4 { color: #F5D57A; font-family: var(--font-serif); margin: 0 0 12px; font-size: 15.5px; }
.pv-footer ul { list-style: none; padding: 0; margin: 0; }
.pv-footer li { margin-bottom: 8px; font-size: 13.5px; }
.pv-footer a { color: #DFD4C3; }
.pv-footer a:hover { color: #F5D57A; }
.pv-footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 16px 0;
    font-size: 13px;
    color: #AFA18D;
}

/* Modal & Forms */
.pv-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(25, 16, 10, 0.58);
    display: grid;
    place-items: center;
    padding: 16px;
    z-index: 100;
}
.pv-modal-backdrop[hidden] { display: none; }
.pv-modal {
    background: var(--surface);
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    padding: 24px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.28);
    max-height: 92vh;
    overflow-y: auto;
}
.pv-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    border: none;
    background: var(--surface-warm);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
}
.pv-modal h3 { font-family: var(--font-serif); margin: 0 0 6px; color: var(--crimson-dark); }
.pv-modal-sub { margin: 0 0 16px; font-size: 13.5px; color: var(--ink-muted); }
.pv-form-row { margin-bottom: 12px; }
.pv-form-row label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 5px; }
.pv-form-row input, .pv-form-row textarea, .pv-form-row select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 9px;
    font-family: var(--font-sans);
    font-size: 14px;
}
.pv-form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pv-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.pv-form-msg { padding: 10px 12px; border-radius: 8px; font-size: 13.5px; margin-top: 8px; }
.pv-form-msg.ok { background: #E9F7EF; color: #145A32; border: 1px solid #A9DFBF; }
.pv-form-msg.err { background: #FDEDEC; color: #922B21; border: 1px solid #F5B7B1; }

/* Responsive */
@media (max-width: 960px) {
    .pv-card-grid { grid-template-columns: repeat(2, 1fr); }
    .pv-service-grid { grid-template-columns: repeat(2, 1fr); }
    .pv-footer-grid { grid-template-columns: 1fr 1fr; }
    .pv-search-row, .pv-search-row-3, .pv-search-row-4 { grid-template-columns: 1fr; }
    .pv-culture-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
    .pv-menu-toggle { display: inline-flex; }
    .pv-nav {
        display: none;
        position: absolute;
        top: 68px;
        left: 0;
        right: 0;
        background: var(--surface);
        border-bottom: 2px solid var(--gold-soft);
        padding: 12px 18px;
        flex-direction: column;
        align-items: stretch;
    }
    .pv-nav.open { display: flex; }
    .pv-nav a.pv-nav-btn { margin-left: 0; text-align: center; }
    .pv-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .pv-card-grid { grid-template-columns: 1fr; }
    .pv-service-grid { grid-template-columns: 1fr; }
    .pv-footer-grid { grid-template-columns: 1fr; }
    .pv-form-grid-2 { grid-template-columns: 1fr; }
    .pv-tree-stage-wrap { height: 480px; }
}


/* =========================================================================
   PHẢ ĐỒ VIỆT v2: SMART SEARCH, BÁCH GIA TÍNH, MỤC LỤC PHẢ HỆ & SÁCH PHẢ
   ========================================================================= */

/* 1. Unified Smart Search */
.pv-smart-search-wrap {
    max-width: 880px;
    margin: 0 auto 24px;
}
.pv-smart-form {
    position: relative;
}
.pv-smart-bar {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 2px solid var(--gold);
    border-radius: 14px;
    padding: 6px 6px 6px 14px;
    box-shadow: 0 10px 30px rgba(45, 28, 12, 0.14);
    gap: 8px;
}
.pv-smart-icon { font-size: 19px; flex-shrink: 0; }
.pv-smart-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: var(--font-sans);
    font-size: 15.5px;
    color: var(--ink);
    background: transparent;
    padding: 10px 4px;
    min-width: 0;
}
.pv-smart-submit {
    padding: 11px 22px;
    border-radius: 10px;
    font-size: 15px;
    flex-shrink: 0;
}
.pv-smart-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1.5px solid var(--gold);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(34, 27, 23, 0.18);
    z-index: 60;
    max-height: 430px;
    overflow-y: auto;
    text-align: left;
}
.pv-sd-group { border-bottom: 1px solid var(--border); padding: 6px 0; }
.pv-sd-group:last-of-type { border-bottom: none; }
.pv-sd-title {
    padding: 4px 14px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--ink-muted);
}
.pv-sd-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    color: var(--ink);
    text-decoration: none !important;
    font-size: 14px;
}
.pv-sd-item:hover { background: var(--surface-warm); color: var(--crimson-dark); }
.pv-sd-item small { color: var(--ink-muted); font-size: 12.5px; }
.pv-sd-item > span { font-size: 12.5px; color: var(--crimson); font-weight: 600; white-space: nowrap; }
.pv-sd-empty { padding: 14px; font-size: 13.5px; color: var(--ink-muted); text-align: center; }
.pv-sd-footer {
    display: flex;
    justify-content: space-between;
    padding: 9px 14px;
    background: var(--surface-warm);
    font-size: 13px;
    font-weight: 600;
}
.pv-smart-quick-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}
.pv-smart-quick-label { font-size: 13px; color: rgba(255,245,230,0.88); font-weight: 600; }

/* 2. Bách Gia Tính Surname Grid */
.pv-surname-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}
.pv-surname-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 16px 18px;
    border-radius: 12px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    text-decoration: none !important;
    text-align: left;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: transform .15s, border-color .15s, box-shadow .15s;
    min-height: 82px;
}
.pv-surname-card:hover {
    transform: translateY(-2px);
    border-color: var(--gold);
    box-shadow: var(--shadow);
}
.pv-surname-active {
    border-color: #D7BA83;
    background: linear-gradient(135deg, #FFFFFF 0%, #FDF8EE 100%);
}
.pv-surname-open {
    background: #FCFBF8;
    border-style: dashed;
}
.pv-surname-han {
    position: absolute;
    right: 10px;
    bottom: -8px;
    font-family: var(--font-serif);
    font-size: 56px;
    line-height: 1;
    color: rgba(182, 134, 44, 0.16);
    pointer-events: none;
    user-select: none;
}
.pv-surname-active .pv-surname-han { color: rgba(140, 29, 24, 0.14); }
.pv-surname-name {
    font-family: var(--font-serif);
    font-size: 17px;
    color: var(--crimson-dark);
    position: relative;
    z-index: 1;
}
.pv-surname-cnt {
    font-size: 13px;
    color: var(--ink-muted);
    margin-top: 3px;
    position: relative;
    z-index: 1;
    font-weight: 500;
}
.pv-surname-active .pv-surname-cnt { color: #7A4F08; font-weight: 600; }
.pv-surname-cta { color: var(--crimson); font-size: 12.5px; }

/* 3. Province Region Tabs */
.pv-region-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.pv-region-tab {
    padding: 8px 15px;
    border-radius: 999px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.pv-region-tab:hover { border-color: var(--gold); color: var(--crimson); }
.pv-region-tab.active {
    background: var(--crimson);
    border-color: var(--crimson);
    color: #FFF7E6;
}
.pv-prov-cnt {
    background: var(--surface-warm);
    color: var(--crimson-dark);
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

/* 4. Lineage Header Compact Row */
.pv-lineage-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.pv-lineage-quick-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* 5. Collapsible Directory Tree (Sơ đồ kiểu Mục lục) */
.pv-dir-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
}
.pv-dir-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 240px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 9px;
    padding: 6px 12px;
}
.pv-dir-search-box input {
    border: none;
    outline: none;
    background: transparent;
    width: 100%;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--ink);
}
.pv-dir-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.pv-dir-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
    gap: 18px;
    align-items: start;
}
.pv-dir-tree-panel {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    max-height: 760px;
    overflow: auto;
}
.pv-dir-note {
    background: #FFF9EB;
    border: 1px solid var(--gold);
    color: #6B460B;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13.5px;
    margin-bottom: 10px;
}
.pv-dir-ul {
    list-style: none;
    margin: 0;
    padding: 0 0 0 22px;
    position: relative;
}
.pv-dir-ul-root { padding-left: 0; }
.pv-dir-ul:not(.pv-dir-ul-root)::before {
    content: "";
    position: absolute;
    left: 9px;
    top: 0;
    bottom: 14px;
    border-left: 1.5px solid #D5C3A1;
}
.pv-dir-li { position: relative; }
.pv-dir-ul:not(.pv-dir-ul-root) > .pv-dir-li::before {
    content: "";
    position: absolute;
    left: -13px;
    top: 17px;
    width: 13px;
    border-top: 1.5px solid #D5C3A1;
}
.pv-dir-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 9px;
    border-radius: 8px;
    cursor: pointer;
    flex-wrap: wrap;
    margin: 2px 0;
    transition: background .12s;
}
.pv-dir-row:hover { background: var(--surface-warm); }
.pv-dir-row.selected {
    background: #FCEEEB;
    outline: 1.5px solid var(--crimson);
}
.pv-dir-row.matched { background: #FFF4CC; }
.pv-dir-toggle {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--crimson-dark);
    font-size: 10px;
    cursor: pointer;
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
}
.pv-dir-toggle:hover { background: var(--gold-soft); }
.pv-dir-leaf-dot {
    width: 22px;
    text-align: center;
    color: #B59B72;
    font-size: 16px;
    flex-shrink: 0;
}
.pv-dir-doi {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    flex-shrink: 0;
}
.pv-doi-1 { background: var(--crimson); color: #FFE7A3; }
.pv-doi-top { background: var(--gold-soft); color: #6E4609; }
.pv-doi-std { background: #F1ECE2; color: var(--ink-muted); }
.pv-dir-name { font-weight: 600; font-size: 14.5px; color: var(--ink); }
.pv-dir-gio { font-size: 12px; color: var(--crimson); font-weight: 500; }
.pv-dir-count { font-size: 12px; color: var(--ink-muted); margin-left: auto; }

.pv-dir-detail-panel {
    position: sticky;
    top: 84px;
    background: var(--surface);
    border: 1.5px solid #D7BA83;
    border-radius: 12px;
    padding: 18px;
    box-shadow: var(--shadow);
}
.pv-dir-detail-empty { color: var(--ink-muted); font-size: 14px; text-align: center; padding: 24px 8px; }
.pv-dir-path {
    background: var(--bg);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12.5px;
    line-height: 1.5;
    margin-bottom: 10px;
}
.pv-dir-path small { display: block; color: var(--ink-muted); margin-bottom: 2px; font-weight: 600; }
.pv-dir-meta-list { display: flex; flex-direction: column; gap: 4px; font-size: 14px; margin-bottom: 10px; }
.pv-dir-bio {
    background: var(--bg);
    border-left: 3px solid var(--gold);
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 12px;
}
.pv-dir-kids { margin-bottom: 14px; font-size: 13.5px; }
.pv-dir-kids-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pv-dir-detail-actions { display: flex; flex-direction: column; gap: 7px; }

/* Fullscreen Tree Mode */
#tab-sodo:fullscreen {
    background: var(--bg);
    padding: 14px;
    display: flex;
    flex-direction: column;
}
#tab-sodo:fullscreen .pv-tree-stage-wrap {
    flex: 1;
    height: auto;
}

/* 6. Printable Genealogy Book (Sách Gia Phả) */
.pv-book-print-header { display: none; text-align: center; border-bottom: 2px solid var(--crimson); padding-bottom: 12px; margin-bottom: 18px; }
.pv-book-layout {
    display: grid;
    grid-template-columns: 245px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}
.pv-book-toc {
    position: sticky;
    top: 84px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.pv-book-toc-head {
    padding: 14px 14px 12px;
    background: var(--surface-warm);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-serif);
    color: var(--crimson-dark);
}
.pv-book-toc-list { max-height: 520px; overflow-y: auto; padding: 6px; }
.pv-book-toc-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 10px;
    border-radius: 7px;
    font-size: 13.5px;
    color: var(--ink);
    text-decoration: none !important;
}
.pv-book-toc-item:hover { background: var(--surface-warm); color: var(--crimson); }
.pv-book-toc-item small { color: var(--ink-muted); font-weight: 600; }

.pv-book-chapter {
    background: #FFFDF8;
    border: 2px double #C9B38C;
    border-radius: 12px;
    margin-bottom: 22px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(45, 28, 12, 0.05);
}
.pv-book-chapter-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: linear-gradient(90deg, #8C1D18 0%, #A92822 100%);
    color: #FFE7A3;
}
.pv-book-chapter-head h2 {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 17px;
    letter-spacing: 0.4px;
}
.pv-book-chapter-head span { font-size: 13px; color: #F7E7C4; }
.pv-book-entries { padding: 6px 20px 14px; }
.pv-book-entry {
    padding: 14px 0;
    border-bottom: 1px dashed #DFD2BA;
}
.pv-book-entry:last-child { border-bottom: none; }
.pv-book-entry.pv-book-flash { background: #FFF4CC; border-radius: 8px; padding: 14px 10px; }
.pv-book-entry-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}
.pv-book-entry-name {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 17px;
    color: var(--crimson-dark);
}
.pv-book-num { color: var(--gold); margin-right: 4px; }
.pv-book-entry-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.pv-book-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    margin-top: 6px;
    font-size: 14px;
    color: #3A3028;
}
.pv-book-gio { color: var(--crimson); }
.pv-book-bio {
    margin-top: 8px;
    padding: 8px 12px;
    background: #FAF5EA;
    border-left: 3px solid #D5BA86;
    border-radius: 5px;
    font-size: 14.5px;
    line-height: 1.65;
    color: #2B231D;
}
.pv-book-children {
    margin-top: 8px;
    font-size: 13.5px;
    color: var(--ink-muted);
}

/* Responsive v2 */
@media (max-width: 960px) {
    .pv-surname-grid { grid-template-columns: repeat(2, 1fr); }
    .pv-dir-layout { grid-template-columns: 1fr; }
    .pv-dir-detail-panel { position: static; }
    .pv-book-layout { grid-template-columns: 1fr; }
    .pv-book-toc { position: static; }
}
@media (max-width: 540px) {
    .pv-smart-bar { flex-wrap: wrap; padding: 8px; }
    .pv-smart-submit { width: 100%; }
}

/* Print CSS for A4 Genealogy Book */
@media print {
    body { background: #FFFFFF !important; font-size: 12pt; }
    .pv-header, .pv-footer, .pv-no-print, .pv-modal-backdrop { display: none !important; }
    .pv-container { max-width: 100% !important; padding: 0 !important; }
    .pv-section { padding: 0 !important; }
    .pv-book-print-header { display: block !important; }
    .pv-book-layout { display: block !important; }
    .pv-book-chapter { border: 1px solid #999 !important; box-shadow: none !important; page-break-inside: auto; }
    .pv-book-chapter-head { background: #EFE3C4 !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .pv-book-entry { page-break-inside: avoid; }
}
