/* Core Styling & Design System - 张氏家族谱数字化交互系统 */

:root {
    /* Premium Modern Dark Theme Colors */
    --bg-dark: #070708;
    --bg-card: rgba(20, 20, 24, 0.7);
    --bg-card-hover: rgba(28, 28, 34, 0.85);
    --bg-panel: rgba(15, 15, 18, 0.8);
    --border-color: rgba(255, 255, 255, 0.05);
    --border-hover: rgba(212, 175, 55, 0.45);
    --link-color: rgba(255, 255, 255, 0.12);
    --grid-line-color: rgba(255, 255, 255, 0.02);

    --text-primary: #f0f0f5;
    --text-secondary: #a0a0ab;
    --text-muted: #666670;

    /* Harmonious Accents */
    --gold: #d4af37;
    --gold-dark: #b8860b;
    --gold-glow: rgba(212, 175, 55, 0.2);

    --rose-gold: #f472b6;
    --rose-gold-dark: #db2777;
    --rose-gold-glow: rgba(244, 114, 182, 0.2);

    --crimson: #c82323;
    --crimson-hover: #e53935;
    --crimson-glow: rgba(200, 35, 35, 0.18);

    /* Master Design Gradients */
    --gold-gradient: linear-gradient(135deg, #fce0ad 0%, #dfb75c 50%, #b38515 100%);
    --crimson-gradient: linear-gradient(135deg, #e53935 0%, #c82323 50%, #900c0c 100%);
    --dark-obsidian-gradient: linear-gradient(135deg, rgba(24, 24, 28, 0.85) 0%, rgba(12, 12, 14, 0.95) 100%);
    --light-parchment-gradient: linear-gradient(135deg, #fbf7ef 0%, #f4edd9 100%);

    --success: #34d399;
    --info: #3b82f6;
    --warning: #f59e0b;

    /* Parchment Theme for Traditional View */
    --parchment-bg: #faf5eb;
    --parchment-card: #f5eedf;
    --parchment-border: #dcd1ba;
    --parchment-grid: rgba(200, 35, 35, 0.15);
    --parchment-text-primary: #2b2b2b;
    --parchment-text-secondary: #5c5c5c;

    /* Font Stacks */
    --font-ui: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    --font-serif: 'Noto Serif SC', "Georgia", "Times New Roman", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    --font-calligraphy: "KaiTi", "STKaiti", "华文楷体", "楷体", "Noto Serif SC", "PingFang SC", "Microsoft YaHei", sans-serif;

    /* Premium Animations & Motions */
    --transition-smooth: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
    --transition-fast: all 0.15s ease;
    --transition-elastic: all 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Global */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-ui);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* General Utility Class to Hide Elements */
.hidden:not(.app-loader) {
    display: none !important;
}

/* App Loader */
.app-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-dark);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.app-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
}

.loader-crest {
    font-family: var(--font-serif);
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--gold);
    width: 100px;
    height: 100px;
    line-height: 94px;
    border: 3px solid var(--gold);
    border-radius: 50%;
    margin: 0 auto 30px;
    background: rgba(212, 175, 55, 0.05);
    box-shadow: 0 0 30px var(--gold-glow);
    animation: crest-pulse 2s infinite ease-in-out;
}

.loader-bar {
    width: 240px;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin: 0 auto 15px;
    overflow: hidden;
}

.loader-progress {
    height: 100%;
    width: 30%;
    background: var(--gold);
    border-radius: 3px;
    animation: loading-bar 1.5s infinite ease-in-out;
}

.loader-content p {
    font-family: var(--font-serif);
    font-size: 1rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

@keyframes crest-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px var(--gold-glow); }
    50% { transform: scale(1.05); box-shadow: 0 0 40px rgba(212, 175, 55, 0.4); }
}

@keyframes loading-bar {
    0% { transform: translateX(-100%); width: 30%; }
    50% { width: 40%; }
    100% { transform: translateX(250%); width: 30%; }
}

/* Layout System */
.app-container {
    display: flex;
    height: 100%;
    width: 100vw;
    position: relative;
}

/* Sidebar Panel */
.app-sidebar {
    width: 380px;
    height: 100%;
    background: linear-gradient(180deg, rgba(15, 15, 17, 0.85) 0%, rgba(8, 8, 10, 0.95) 100%) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-right: 1px solid rgba(255, 255, 255, 0.05) !important;
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 5px 0 30px rgba(0,0,0,0.4) !important;
    transition: var(--transition-elastic) !important;
}

.app-sidebar.collapsed {
    width: 0;
    min-width: 0;
    opacity: 0;
    pointer-events: none;
    border-right: none;
    box-shadow: none;
    overflow: hidden;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(15, 15, 17, 0.9);
}

@media (min-width: 769px) {
    .app-sidebar > .sidebar-header {
        display: none;
    }
}

.crest-badge {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    border: 2px solid var(--gold);
    color: var(--gold);
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(212, 175, 55, 0.05);
}

.title-group h1 {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--gold);
}

.sub-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-top: 2px;
}

.sidebar-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    transition: var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gold);
    box-shadow: 0 0 6px var(--gold-glow);
}

/* Light Theme Scrollbars */
.traditional-book-theme ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.08);
}

.traditional-book-theme ::-webkit-scrollbar-thumb:hover {
    background: var(--crimson);
    box-shadow: 0 0 6px rgba(200, 35, 35, 0.3);
}


/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.02);
    transition: var(--transition-elastic);
}

.stat-card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 10px 25px rgba(212, 175, 55, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.03);
    transform: translateY(-4px) scale(1.02);
}

.stat-num {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--gold);
    display: block;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Sidebar Sections */
.sidebar-section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title i {
    color: var(--gold);
}

/* View Selectors */
.view-selectors {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.view-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition-fast);
}

.view-btn i {
    font-size: 1rem;
    color: var(--text-secondary);
    width: 20px;
}

.view-btn:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.2);
}

.view-btn.active {
    background: var(--gold-glow);
    border-color: var(--gold);
    color: var(--gold);
}

.view-btn.active i {
    color: var(--gold);
}

/* Traditional View Button Accent */
.view-btn.traditional:hover {
    border-color: rgba(200, 35, 35, 0.5);
}

.view-btn.traditional.active {
    background: var(--crimson-glow);
    border-color: var(--crimson);
    color: var(--crimson);
}

.view-btn.traditional.active i {
    color: var(--crimson);
}

/* Search Box & Dropdowns */
.search-box-wrapper {
    position: relative;
    margin-bottom: 16px;
}

#search-input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 40px 12px 38px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-fast);
}

#search-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.15);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.search-clear-btn {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    font-size: 1rem;
    padding: 4px;
}

.search-clear-btn:hover {
    color: var(--text-primary);
}

.search-results-dropdown {
    position: absolute;
    top: 105%;
    left: 0;
    right: 0;
    background: #18181b;
    border: 1px solid #2d2d34;
    border-radius: 8px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.search-results-dropdown.hidden {
    display: none;
}

.result-item {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item:hover {
    background: rgba(212, 175, 55, 0.08);
}

.result-name-group {
    display: flex;
    flex-direction: column;
}

.result-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.result-relation {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.result-gen {
    font-size: 0.7rem;
    background: #27272a;
    border-radius: 4px;
    padding: 2px 6px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.result-no-match {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Filters */
.filter-group {
    margin-bottom: 16px;
}

.filter-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-select {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

.form-select:focus {
    border-color: var(--gold);
}

/* Chips Filters */
.chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 6px 14px;
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-fast);
}

.chip-btn:hover {
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.chip-btn.active {
    background: rgba(212, 175, 55, 0.08);
    border-color: var(--gold);
    color: var(--gold);
}

/* Legends & Footer */
.legend-section {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.legend-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255,255,255,0.01);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
    border: 1px solid rgba(255,255,255,0.1);
}

.legend-color.normal { background: #2b303b; border-color: #5c6370; }
.legend-color.title-badge { background: #aa8322; border-color: var(--gold); }
.legend-color.adopted { background: #27272a; border-style: dashed; border-color: var(--text-secondary); }
.legend-color.no-heir { background: #3b2c2c; border-color: #ef4444; }
.legend-color.died-young { background: #222222; border-color: #4b5563; }

.meta-footer {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Main Area Layout */
.app-main {
    flex: 1;
    display: flex;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.pane {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: var(--transition-smooth);
}

/* Left Pane: Tree Visualizer */
.visualizer-pane {
    flex: 1;
    background: #0d0d0f;
    overflow: hidden;
}

.pane-controls {
    height: 70px;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(13, 13, 15, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 5;
}

.pane-title-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-sidebar-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.toggle-sidebar-btn:hover {
    background: rgba(212, 175, 55, 0.08);
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 10px var(--gold-glow);
}

.toggle-sidebar-btn:active {
    transform: scale(0.95);
}

.view-tag {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.05);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.view-tag.gold {
    background: rgba(212, 175, 55, 0.05);
    border-color: var(--gold);
    color: var(--gold);
}

.view-title {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.canvas-wrapper .zoom-controls {
    position: absolute;
    bottom: 24px;
    right: 24px;
    z-index: 99;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 6px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.canvas-wrapper .zoom-controls button {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.canvas-wrapper .zoom-controls button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--gold);
    transform: translateY(-2px);
}

.canvas-wrapper .zoom-controls button:active {
    transform: scale(0.95);
}

/* Canvas Canvas Wrapper */
.canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.canvas-wrapper:active {
    cursor: grabbing;
}

.watermark {
    position: absolute;
    bottom: 24px;
    left: 24px;
    font-family: var(--font-serif);
    font-size: 3.5rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.015);
    pointer-events: none;
    letter-spacing: 0.2em;
    user-select: none;
}

/* D3.js Styling */
.link {
    fill: none;
    stroke: var(--link-color);
    stroke-width: 1.5px;
    transition: stroke 0.3s ease, stroke-width 0.3s ease;
}

.link.highlighted {
    stroke: var(--gold);
    stroke-width: 2.5px;
}

.link.adoption-link {
    stroke: var(--text-secondary);
    stroke-dasharray: 4, 4;
}

.link.adoption-link.highlighted {
    stroke: var(--gold);
    stroke-width: 2.5px;
}

/* Animated Flow Overlay for Genealogy Lines (Gene/Neural Network Pulses) */
.link-flow {
    fill: none;
    stroke: var(--gold);
    stroke-width: 1.2px;
    stroke-linecap: round;
    opacity: 0.22; /* subtle background flow */
    pointer-events: none;
    stroke-dasharray: 6, 12;
    animation: gene-flow 2.2s linear infinite;
    transition: opacity 0.4s ease, stroke 0.4s ease, stroke-width 0.4s ease;
}

/* Light / Traditional Parchment Theme Overrides */
.traditional-book-theme .link-flow {
    stroke: var(--crimson);
    opacity: 0.18;
}

/* Sibling highlighting logic (When a path link is highlighted) */
.link.highlighted + .link-flow {
    opacity: 0.85 !important;
    stroke-width: 1.8px !important;
    stroke-dasharray: 8, 10 !important;
    animation-duration: 1.2s !important; /* Flows faster when highlighted */
    filter: drop-shadow(0 0 2px rgba(212, 175, 55, 0.6));
}

.traditional-book-theme .link.highlighted + .link-flow {
    filter: drop-shadow(0 0 2px rgba(200, 35, 35, 0.6)) !important;
}

/* Merged branch special flow styling */
.link-flow-merged-branch {
    stroke-dasharray: 4, 8;
    opacity: 0.15;
}

@keyframes gene-flow {
    to {
        stroke-dashoffset: -18;
    }
}

/* Tree Nodes styling */
.node {
    cursor: pointer;
}

/* Modern Card Nodes Styling */
.node-card-rect {
    fill: #0d0d0f;
    stroke: rgba(212, 175, 55, 0.28);
    stroke-width: 1.3px;
    rx: 4px;
    ry: 4px;
    transition: fill 0.45s var(--transition-elastic), stroke 0.45s var(--transition-elastic), filter 0.45s var(--transition-elastic);
}

.node:hover .node-card-rect {
    stroke: var(--gold);
    stroke-width: 1.8px;
    fill: #16161a;
    filter: drop-shadow(0 3px 8px rgba(212, 175, 55, 0.25)) drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
}

.node.selected .node-card-rect {
    fill: rgba(212, 175, 55, 0.09);
    stroke: var(--gold);
    stroke-width: 2.2px;
    filter: drop-shadow(0 0 15px rgba(212, 175, 55, 0.45)) drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
}

/* Light Theme Parchment Scroll Overrides */
.traditional-book-theme .node-card-rect {
    fill: #faf6ee !important;
    stroke: rgba(200, 35, 35, 0.35) !important;
    stroke-width: 1.3px !important;
    rx: 2px !important;
    ry: 2px !important;
    transition: fill 0.45s var(--transition-elastic), stroke 0.45s var(--transition-elastic), filter 0.45s var(--transition-elastic) !important;
}

.traditional-book-theme .node:hover .node-card-rect {
    stroke: var(--crimson) !important;
    stroke-width: 1.8px !important;
    fill: #fdfdfa !important;
    filter: drop-shadow(0 3px 8px rgba(200, 35, 35, 0.18)) !important;
}

.traditional-book-theme .node.selected .node-card-rect {
    fill: rgba(200, 35, 35, 0.06) !important;
    stroke: var(--crimson) !important;
    stroke-width: 2.2px !important;
    filter: drop-shadow(0 0 12px rgba(200, 35, 35, 0.35)) !important;
}

/* Card Text Labels */
.node-card-text {
    font-family: var(--font-serif);
    font-size: 0.82rem;
    font-weight: 600;
    fill: var(--text-primary);
    pointer-events: none;
    letter-spacing: 0.08em;
    transition: fill 0.3s var(--transition-smooth), font-weight 0.3s var(--transition-smooth);
}

.node:hover .node-card-text {
    fill: var(--gold);
}

.node.selected .node-card-text {
    fill: var(--gold);
    font-weight: 700;
}

.node.dimmed, .link.dimmed {
    opacity: 0.15;
}

.node.highlighted-search .node-card-rect {
    stroke: var(--gold);
    fill: rgba(212, 175, 55, 0.18);
    stroke-width: 2.2px;
    animation: search-pulse-card 1.5s infinite alternate;
}

@keyframes search-pulse-card {
    0% { filter: drop-shadow(0 0 2px var(--gold-glow)); }
    100% { filter: drop-shadow(0 0 12px var(--gold)); }
}

/* Card States based on Social sociological notations */
/* Disable default highlight for titled nodes to improve readability as requested */
/*
.node.badge-title .node-card-rect {
    stroke: var(--gold);
    fill: rgba(212, 175, 55, 0.06);
}
.node.badge-title .node-card-text {
    fill: var(--gold);
}
*/

.node.badge-adopted .node-card-rect {
    stroke: var(--text-secondary);
    stroke-dasharray: 4, 3;
}

.node.badge-no-heir .node-card-rect {
    stroke: var(--crimson);
    fill: rgba(200, 35, 35, 0.04);
}
.node.badge-no-heir .node-card-text {
    fill: #fca5a5;
}

.node.badge-died-young {
    opacity: 0.45;
}
.node.badge-died-young .node-card-rect {
    stroke: #3f3f46;
    fill: rgba(10, 10, 11, 0.85);
}
.node.badge-died-young .node-card-text {
    fill: var(--text-muted);
}

/* Female Member Node Cards (Modern Layouts) */
.node.gender-female .node-card-rect {
    stroke: var(--rose-gold);
    fill: rgba(244, 114, 182, 0.08);
}
.node.gender-female:hover .node-card-rect {
    stroke: var(--rose-gold);
    stroke-width: 1.8px;
    fill: rgba(244, 114, 182, 0.15);
    filter: drop-shadow(0 0 10px rgba(244, 114, 182, 0.4));
}
.node.gender-female.selected .node-card-rect {
    stroke: #fb7185;
    fill: rgba(251, 113, 133, 0.18);
    stroke-width: 2.2px;
    filter: drop-shadow(0 0 12px rgba(251, 113, 133, 0.45));
}
.node.gender-female .node-card-text {
    fill: var(--rose-gold);
}
.node.gender-female:hover .node-card-text,
.node.gender-female.selected .node-card-text {
    fill: #fb7185;
}

/* Merged Branch Node & Link Style Overrides (Darenzhuang branches) */
.node.merged-branch-node .node-card-rect {
    stroke: rgba(140, 150, 160, 0.45) !important;
    stroke-dasharray: 4, 3;
}
.node.merged-branch-node:hover .node-card-rect {
    stroke: rgba(160, 180, 200, 0.8) !important;
    stroke-dasharray: 4, 3;
    fill: rgba(140, 150, 160, 0.08) !important;
    filter: drop-shadow(0 3px 8px rgba(140, 150, 160, 0.35)) !important;
}
.node.merged-branch-node.selected .node-card-rect {
    stroke: rgba(170, 190, 210, 0.95) !important;
    stroke-dasharray: none !important; /* solid line on selection */
    fill: rgba(140, 150, 160, 0.15) !important;
    filter: drop-shadow(0 0 12px rgba(140, 150, 160, 0.55)) !important;
}

.traditional-book-theme .node.merged-branch-node .node-card-rect {
    stroke: rgba(120, 120, 120, 0.55) !important;
    stroke-dasharray: 3, 2 !important;
    fill: #fdfbf7 !important;
}
.traditional-book-theme .node.merged-branch-node:hover .node-card-rect {
    stroke: rgba(90, 90, 90, 0.85) !important;
    stroke-dasharray: 3, 2 !important;
    fill: #ffffff !important;
    filter: drop-shadow(0 3px 6px rgba(100, 100, 100, 0.15)) !important;
}
.traditional-book-theme .node.merged-branch-node.selected .node-card-rect {
    stroke: rgba(80, 80, 80, 0.95) !important;
    stroke-dasharray: none !important;
    fill: #f5f3eb !important;
    filter: drop-shadow(0 0 10px rgba(100, 100, 100, 0.25)) !important;
}

.link.link-merged-branch {
    stroke: rgba(140, 150, 160, 0.32) !important;
    stroke-dasharray: 3, 3;
}
.traditional-book-theme .link.link-merged-branch {
    stroke: rgba(110, 110, 110, 0.38) !important;
    stroke-dasharray: 2.5, 2.5;
}

/* D3 Collapse/Expand Toggles */
.collapse-toggle-btn {
    cursor: pointer;
    transition: transform 0.25s var(--transition-smooth);
}

/* Disable scale transformation on hover to prevent coordinate shifting & mouse cursor flickering in SVG */
/*
.collapse-toggle-btn:hover {
    transform: scale(1.25);
}
*/

.collapse-toggle-btn .toggle-btn-circle {
    fill: #141416;
    stroke: rgba(255, 255, 255, 0.35);
    stroke-width: 1.2px;
    transition: fill 0.25s var(--transition-smooth), stroke 0.25s var(--transition-smooth);
}

.node:hover .collapse-toggle-btn .toggle-btn-circle {
    stroke: rgba(255, 255, 255, 0.65);
}

.collapse-toggle-btn:hover .toggle-btn-circle {
    stroke: var(--gold) !important;
    fill: #1e1e22 !important;
    filter: drop-shadow(0 0 4px var(--gold-glow));
}

.collapse-toggle-btn .toggle-btn-text {
    font-family: var(--font-ui);
    font-size: 8px;
    font-weight: 800;
    fill: rgba(255, 255, 255, 0.75);
    user-select: none;
    pointer-events: none;
    transition: fill 0.25s var(--transition-smooth);
}

.collapse-toggle-btn:hover .toggle-btn-text {
    fill: var(--gold) !important;
}

/* Traditional Theme Overrides for D3 Collapse/Expand Toggles */
.traditional-book-theme .collapse-toggle-btn .toggle-btn-circle {
    fill: #fbf9f4;
    stroke: var(--crimson);
    stroke-width: 1.5px;
}

.traditional-book-theme .collapse-toggle-btn:hover .toggle-btn-circle {
    fill: #fdfcf7 !important;
    stroke: var(--crimson-hover) !important;
    filter: drop-shadow(-1px 2px 4px rgba(200, 35, 35, 0.15));
}

.traditional-book-theme .collapse-toggle-btn .toggle-btn-text {
    fill: var(--crimson);
}

.traditional-book-theme .collapse-toggle-btn:hover .toggle-btn-text {
    fill: var(--crimson-hover) !important;
}

/* Generation columns background vertical line indicators */
.gen-grid-line {
    stroke: var(--grid-line-color);
    stroke-width: 1px;
    stroke-dasharray: 4, 4;
}

.gen-header-text {
    font-family: var(--font-serif);
    font-size: 0.75rem;
    fill: var(--text-muted);
    letter-spacing: 0.1em;
    pointer-events: none;
    white-space: nowrap !important;
    inline-size: auto !important;
}

/* Right Pane: Split-screen Side Viewer Panel */
.side-viewer-pane {
    width: 480px;
    background: linear-gradient(180deg, rgba(15, 15, 17, 0.85) 0%, rgba(8, 8, 10, 0.95) 100%) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-left: 1px solid rgba(255, 255, 255, 0.05) !important;
    box-shadow: -5px 0 30px rgba(0,0,0,0.4) !important;
    z-index: 8;
    overflow: hidden;
    transition: var(--transition-elastic) !important;
}

.side-viewer-pane.collapsed {
    width: 0;
    border-left: none;
    box-shadow: none;
}

.border-bottom {
    border-bottom: 1px solid var(--border-color);
}

.close-viewer-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.close-viewer-btn:hover {
    color: var(--text-primary);
    transform: translateX(2px);
}

.close-viewer-btn .close-btn-text {
    display: none;
}

.close-viewer-btn .desktop-only-icon {
    display: inline-block;
}

.close-viewer-btn .mobile-only-icon {
    display: none;
}

/* Empty State Styling */
.viewer-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.03);
    margin-bottom: 24px;
    filter: drop-shadow(0 0 10px rgba(0,0,0,0.5));
}

.viewer-empty-state h3 {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.viewer-empty-state p {
    font-size: 0.85rem;
    line-height: 1.6;
    max-width: 280px;
}

/* Viewer Content Loading styling */
.viewer-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: calc(100% - 70px);
}

.viewer-content.hidden {
    display: none;
}

/* Viewer Tabs buttons */
.viewer-tabs {
    display: flex;
    background: rgba(0,0,0,0.15);
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 14px;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    transition: var(--transition-fast);
}

.tab-btn::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: transparent;
    transition: var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--gold);
    background: rgba(255,255,255,0.01);
}

.tab-btn.active::after {
    background: var(--gold);
}

/* Tab Content Panes */
.tab-pane {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: none;
}

.tab-pane.active {
    display: flex;
    flex-direction: column;
}

/* Profile Card Detail Area */
.profile-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 18px;
}

.profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--gold-glow);
    border: 2px solid var(--gold);
    color: var(--gold);
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.profile-avatar.female {
    background: var(--rose-gold-glow);
    border-color: var(--rose-gold);
    color: var(--rose-gold);
}

.profile-name-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-name-row h2 {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.gen-badge {
    font-size: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--gold);
}

.profile-relation {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.profile-details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-item.full-width {
    grid-column: span 2;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 8px;
    margin-top: 4px;
}

.detail-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.detail-val {
    font-size: 0.9rem;
    font-weight: 500;
}

.profile-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-section.hidden {
    display: none;
}

.profile-sec-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 2px solid var(--gold);
    padding-left: 8px;
}

/* --- Master-Class Life Timeline Styling --- */
.timeline-stepper {
    position: relative;
    padding-left: 20px;
    margin: 15px 0 5px 5px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Timeline Vertical Line */
.timeline-stepper::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background: linear-gradient(to bottom, var(--gold) 0%, rgba(212, 175, 55, 0.15) 100%);
    opacity: 0.7;
}

.traditional-book-theme .timeline-stepper::before {
    background: linear-gradient(to bottom, var(--vermilion, #c82323) 0%, rgba(200, 35, 35, 0.15) 100%);
}

.timeline-item {
    position: relative;
    display: flex;
    gap: 12px;
}

/* Dynamic dot node */
.timeline-dot-wrapper {
    position: absolute;
    left: -20px;
    top: 8px;
    width: 10px;
    height: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 8px var(--gold);
    z-index: 2;
    transition: var(--transition-elastic) !important;
}

.traditional-book-theme .timeline-dot {
    background: var(--vermilion, #c82323);
    box-shadow: 0 0 6px var(--vermilion, #c82323);
}

/* Breathing animation for the first (latest/birth) dot or active hover */
.timeline-item:hover .timeline-dot,
.timeline-item:first-child .timeline-dot {
    transform: scale(1.3);
    box-shadow: 0 0 12px var(--gold);
}

.traditional-book-theme .timeline-item:hover .timeline-dot,
.traditional-book-theme .timeline-item:first-child .timeline-dot {
    box-shadow: 0 0 10px var(--vermilion, #c82323);
}

/* Pulsing outer ring */
.timeline-item:first-child .timeline-dot::after {
    content: '';
    position: absolute;
    left: -4px;
    top: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--gold);
    opacity: 0.8;
    animation: timeline-pulse 2s infinite ease-out;
    pointer-events: none;
}

.traditional-book-theme .timeline-item:first-child .timeline-dot::after {
    border-color: var(--vermilion, #c82323);
}

@keyframes timeline-pulse {
    0% {
        transform: scale(0.6);
        opacity: 1;
    }
    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

/* Timeline Card */
.timeline-event-card {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 10px 12px;
    transition: var(--transition-elastic) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Dark theme specific glass elevation */
.timeline-event-card {
    background: linear-gradient(135deg, rgba(25, 25, 30, 0.4) 0%, rgba(15, 15, 20, 0.6) 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
}

.timeline-event-card:hover {
    transform: translateX(4px);
    border-color: rgba(212, 175, 55, 0.25) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 10px rgba(212, 175, 55, 0.05) !important;
}

/* Light theme (宣纸朱印) specific handmade parchment style */
.traditional-book-theme .timeline-event-card {
    background-color: rgba(250, 246, 238, 0.8) !important;
    background-image: radial-gradient(rgba(0, 0, 0, 0.015) 0.8px, transparent 0.8px), radial-gradient(rgba(0, 0, 0, 0.01) 0.8px, rgba(250, 246, 238, 0.8) 0.8px) !important;
    background-size: 8px 8px !important;
    background-position: 0 0, 4px 4px !important;
    border: 1px solid rgba(220, 209, 186, 0.75) !important;
    box-shadow: 0 3px 10px rgba(139, 0, 0, 0.02), inset 0 0 20px rgba(250, 245, 235, 0.6) !important;
}

.traditional-book-theme .timeline-event-card:hover {
    transform: translateX(4px);
    border-color: rgba(200, 35, 35, 0.35) !important;
    box-shadow: 0 5px 15px rgba(200, 35, 35, 0.06) !important;
}

/* Card Header */
.timeline-event-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.timeline-event-year {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.02em;
    background: rgba(212, 175, 55, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(212, 175, 55, 0.15);
}

.traditional-book-theme .timeline-event-year {
    color: var(--vermilion, #c82323);
    background: rgba(200, 35, 35, 0.05);
    border-color: rgba(200, 35, 35, 0.12);
}

.timeline-event-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.traditional-book-theme .timeline-event-title {
    color: var(--parchment-text-primary, #2c2c2c);
}

/* Card Body Desc */
.timeline-event-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}

.traditional-book-theme .timeline-event-desc {
    color: #555555;
}

/* Title Badge Styling */
.titles-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.title-badge-item {
    font-family: var(--font-serif);
    font-size: 0.8rem;
    background: rgba(212, 175, 55, 0.06);
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: 600;
}

/* Adoption details card styling */
.adoption-card {
    background: rgba(255,255,255,0.01);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    padding: 14px;
}

.adoption-content {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.adoption-link-ref {
    color: var(--gold);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}

/* Notes / biography paragraph text style */
.notes-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    font-size: 0.9rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.notes-content ul {
    list-style-type: none;
}

.notes-content li {
    position: relative;
    padding-left: 18px;
    margin-bottom: 8px;
}

.notes-content li:last-child {
    margin-bottom: 0;
}

.notes-content li::before {
    content: '▪';
    position: absolute;
    left: 2px;
    color: var(--gold);
}

.view-scan-action-btn {
    background: var(--gold);
    border: none;
    border-radius: 8px;
    padding: 14px;
    color: #121212;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    transition: var(--transition-fast);
}

.view-scan-action-btn:hover {
    background: #e5c158;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

/* Scanned Document Viewer styling */
.scan-viewer-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 400px;
}

.scan-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 8px 8px 0 0;
}

.scan-filename {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.scan-controls {
    display: flex;
    gap: 4px;
}

.scan-controls button {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.scan-controls button:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.scan-viewport {
    flex: 1;
    background: #080809;
    border: 1px solid var(--border-color);
    border-top: none;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    min-height: 350px;
}

.scan-viewport:active {
    cursor: grabbing;
}

.scan-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    pointer-events: auto;
    transform-origin: center center;
    transition: transform 0.1s ease-out;
}

.scan-loader {
    position: absolute;
    background: rgba(0,0,0,0.8);
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--gold);
    display: flex;
    align-items: center;
    gap: 8px;
}

.scan-loader.hidden {
    display: none;
}

.scan-tips {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ========================================== */
/* TRADITIONAL CLASSIC CHINESE VIEW STYLE     */
/* ========================================== */

.traditional-book-theme {
    --bg-dark: var(--parchment-bg);
    --bg-card: var(--parchment-card);
    --bg-card-hover: #fdfcf7;
    --bg-panel: var(--parchment-card);
    --border-color: var(--parchment-border);
    --border-hover: var(--crimson);
    --text-primary: var(--parchment-text-primary);
    --text-secondary: var(--parchment-text-secondary);
    --text-muted: #8c7e65;
    --gold: var(--crimson);
    --gold-dark: #a01818;
    --gold-glow: rgba(200, 35, 35, 0.15);

    --rose-gold: #c2185b;
    --rose-gold-hover: #ad1457;
    --rose-gold-dark: #880e4f;
    --rose-gold-glow: rgba(194, 24, 91, 0.05);

    --link-color: var(--parchment-border);
    --grid-line-color: rgba(0, 0, 0, 0.05);

    background-color: var(--parchment-bg) !important;
}

.traditional-book-theme .visualizer-pane {
    background: var(--parchment-bg) !important;
}

/* Grid layout for traditional printed block style background - Light Theme */
.layout-traditional-book.traditional-book-theme .canvas-wrapper {
    background-color: var(--parchment-bg);
    background-image:
        linear-gradient(90deg, var(--parchment-grid) 1px, transparent 1px),
        linear-gradient(var(--parchment-grid) 1px, transparent 1px);
    background-size: 140px 100%;
    background-position: right top;
}

/* Grid layout for traditional printed block style background - Dark Theme */
.layout-traditional-book:not(.traditional-book-theme) .canvas-wrapper {
    background-color: var(--bg-dark);
    background-image:
        linear-gradient(90deg, rgba(212, 175, 55, 0.08) 1px, transparent 1px),
        linear-gradient(rgba(212, 175, 55, 0.08) 1px, transparent 1px);
    background-size: 140px 100%;
    background-position: right top;
}

.traditional-book-theme .watermark {
    color: rgba(200, 35, 35, 0.035);
    font-size: 5rem;
}

.traditional-book-theme .pane-controls {
    background: var(--parchment-card) !important;
    border-bottom: 1px solid var(--parchment-border);
}

.traditional-book-theme .toggle-sidebar-btn {
    background: var(--parchment-bg);
    border-color: var(--parchment-border);
    color: var(--parchment-text-secondary);
}

.traditional-book-theme .toggle-sidebar-btn:hover {
    background: rgba(200, 35, 35, 0.04);
    border-color: var(--crimson);
    color: var(--crimson);
    box-shadow: none;
}

.traditional-book-theme .pane-controls .view-title {
    color: var(--parchment-text-primary);
}

.traditional-book-theme .canvas-wrapper .zoom-controls {
    background: var(--parchment-card);
    border-color: var(--parchment-border);
    box-shadow: -4px 4px 15px rgba(139, 0, 0, 0.15);
}

.traditional-book-theme .canvas-wrapper .zoom-controls button {
    color: var(--parchment-text-primary);
}

.traditional-book-theme .canvas-wrapper .zoom-controls button:hover {
    background: rgba(139, 0, 0, 0.05);
    color: var(--crimson);
}

/* App Header & Navigation - Light Theme */
.traditional-book-theme .app-header {
    background: var(--parchment-card) !important;
    border-bottom: 1px solid var(--parchment-border);
    box-shadow: 0 4px 20px rgba(139, 0, 0, 0.05);
}

.traditional-book-theme .nav-btn {
    border-radius: 30px !important;
    transition: var(--transition-elastic) !important;
}

.traditional-book-theme .nav-btn:hover {
    color: var(--parchment-text-primary);
    background: rgba(200, 35, 35, 0.04) !important;
    border-color: rgba(200, 35, 35, 0.15) !important;
    transform: translateY(-1px);
}

.traditional-book-theme .nav-btn.active {
    color: var(--crimson) !important;
    background: linear-gradient(135deg, rgba(200, 35, 35, 0.08) 0%, rgba(144, 12, 12, 0.03) 100%) !important;
    border-color: rgba(200, 35, 35, 0.6) !important;
    box-shadow: 0 4px 12px rgba(200, 35, 35, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
}

.traditional-book-theme .nav-btn.active i {
    color: var(--crimson) !important;
    transform: scale(1.15) translateY(-1px);
}


/* Sidebar & Side Viewer Panels - Light Theme Desktop Fix */
.traditional-book-theme .app-sidebar {
    background: var(--parchment-bg);
    border-right: 1px solid var(--parchment-border);
    box-shadow: 5px 0 20px rgba(0, 0, 0, 0.08);
}

.traditional-book-theme .side-viewer-pane {
    background: var(--parchment-bg);
    border-left: 1px solid var(--parchment-border);
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.08);
}

/* Female Member Node overrides in Light Theme */
.traditional-book-theme .node.gender-female .node-card-rect {
    stroke: var(--rose-gold);
    fill: rgba(194, 24, 91, 0.04);
}
.traditional-book-theme .node.gender-female:hover .node-card-rect {
    stroke: var(--rose-gold-hover);
    fill: rgba(194, 24, 91, 0.08);
    filter: drop-shadow(0 0 10px rgba(194, 24, 91, 0.2));
}
.traditional-book-theme .node.gender-female.selected .node-card-rect {
    stroke: var(--rose-gold-hover);
    fill: rgba(194, 24, 91, 0.12);
    filter: drop-shadow(0 0 12px rgba(194, 24, 91, 0.25));
}
.traditional-book-theme .node.gender-female .node-card-text {
    fill: var(--rose-gold);
}
.traditional-book-theme .node.gender-female:hover .node-card-text,
.traditional-book-theme .node.gender-female.selected .node-card-text {
    fill: var(--rose-gold-hover);
}

/* Special States overrides in Light Theme */
.traditional-book-theme .node.badge-no-heir .node-card-text {
    fill: var(--crimson);
}
.traditional-book-theme .node.badge-died-young .node-card-rect {
    stroke: var(--parchment-border);
    fill: rgba(245, 238, 223, 0.6);
}
.traditional-book-theme .node.badge-died-young .node-card-text {
    fill: #8c7e65;
}

/* D3 Elements in Traditional Mode */
.layout-traditional-book.traditional-book-theme .link {
    stroke: var(--crimson);
    stroke-width: 2px;
}

.layout-traditional-book.traditional-book-theme .link.highlighted {
    stroke: var(--crimson-hover);
    stroke-width: 3.5px;
}

.layout-traditional-book.traditional-book-theme .link.adoption-link {
    stroke: var(--crimson);
    stroke-dasharray: 4, 3;
}

.layout-traditional-book.traditional-book-theme .link.adoption-link.highlighted {
    stroke: var(--crimson-hover);
    stroke-width: 3.5px;
}

/* Dark theme traditional layout overrides */
.layout-traditional-book:not(.traditional-book-theme) .link {
    stroke: var(--gold);
    stroke-opacity: 0.35;
    stroke-width: 2px;
}

.layout-traditional-book:not(.traditional-book-theme) .link.highlighted {
    stroke: var(--gold);
    stroke-opacity: 1;
    stroke-width: 3.5px;
}

.layout-traditional-book:not(.traditional-book-theme) .link.adoption-link {
    stroke: var(--gold);
    stroke-dasharray: 4, 3;
}

.layout-traditional-book:not(.traditional-book-theme) .link.adoption-link.highlighted {
    stroke: var(--gold);
    stroke-width: 3.5px;
}

/* Traditional Node Rectangles */
.layout-traditional-book.traditional-book-theme .node rect {
    fill: #fdfbf7;
    stroke: rgba(200, 35, 35, 0.45);
    stroke-width: 2px;
    rx: 2;
    ry: 2;
    transition: var(--transition-elastic);
}

.layout-traditional-book.traditional-book-theme .node:hover rect {
    fill: #fefdfb;
    stroke: var(--crimson);
    stroke-width: 2.8px;
    filter: drop-shadow(-2px 4px 10px rgba(200, 35, 35, 0.2));
}

.layout-traditional-book.traditional-book-theme .node.selected rect {
    fill: rgba(200, 35, 35, 0.05);
    stroke: var(--crimson);
    stroke-width: 3.2px;
    filter: drop-shadow(-3px 6px 15px rgba(200, 35, 35, 0.35));
}

/* Dark theme traditional node rectangles */
.layout-traditional-book:not(.traditional-book-theme) .node rect {
    fill: #0a0a0c;
    stroke: rgba(212, 175, 55, 0.35);
    stroke-width: 1.8px;
    rx: 2;
    ry: 2;
    transition: var(--transition-elastic);
}

.layout-traditional-book:not(.traditional-book-theme) .node:hover rect {
    fill: #141418;
    stroke: var(--gold);
    stroke-width: 2.5px;
    filter: drop-shadow(-2px 4px 10px rgba(212, 175, 55, 0.25));
}

.layout-traditional-book:not(.traditional-book-theme) .node.selected rect {
    fill: rgba(212, 175, 55, 0.08);
    stroke: var(--gold);
    stroke-width: 3px;
    filter: drop-shadow(-3px 6px 15px rgba(212, 175, 55, 0.45));
}

/* Vertical Text inside Nodes */
.layout-traditional-book.traditional-book-theme .node .traditional-plaque-text {
    font-family: var(--font-serif);
    font-weight: 700;
    fill: var(--parchment-text-primary);
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: 0.9rem;
    letter-spacing: 0.15em;
    dominant-baseline: central;
    text-anchor: middle;
}

.layout-traditional-book.traditional-book-theme .node:hover .traditional-plaque-text {
    fill: var(--crimson-hover);
}

.layout-traditional-book.traditional-book-theme .node.selected .traditional-plaque-text {
    fill: var(--crimson-hover);
    font-weight: 900;
    font-size: 1rem;
}

/* Dark theme traditional vertical text */
.layout-traditional-book:not(.traditional-book-theme) .node .traditional-plaque-text {
    font-family: var(--font-serif);
    font-weight: 700;
    fill: var(--text-primary);
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: 0.9rem;
    letter-spacing: 0.15em;
    dominant-baseline: central;
    text-anchor: middle;
}

.layout-traditional-book:not(.traditional-book-theme) .node:hover .traditional-plaque-text,
.layout-traditional-book:not(.traditional-book-theme) .node.selected .traditional-plaque-text {
    fill: var(--gold);
}

/* Female Member Node Plaque (Traditional Layout) */
.layout-traditional-book.traditional-book-theme .node.gender-female rect {
    stroke: #db2777;
    fill: #fdf2f8;
}
.layout-traditional-book.traditional-book-theme .node.gender-female:hover rect {
    stroke-width: 3.2px;
    filter: drop-shadow(-2px 4px 6px rgba(219, 39, 119, 0.2));
}
.layout-traditional-book.traditional-book-theme .node.gender-female.selected rect {
    stroke: #ec4899;
    stroke-width: 3.8px;
    filter: drop-shadow(-3px 5px 12px rgba(219, 39, 119, 0.35));
}
.layout-traditional-book.traditional-book-theme .node.gender-female .traditional-plaque-text {
    fill: #9d174d;
}
.layout-traditional-book.traditional-book-theme .node.gender-female:hover .traditional-plaque-text,
.layout-traditional-book.traditional-book-theme .node.gender-female.selected .traditional-plaque-text {
    fill: #db2777;
}

/* Dark theme traditional female member node plaque */
.layout-traditional-book:not(.traditional-book-theme) .node.gender-female rect {
    stroke: var(--rose-gold);
    fill: rgba(244, 114, 182, 0.05);
}
.layout-traditional-book:not(.traditional-book-theme) .node.gender-female:hover rect {
    stroke-width: 3.2px;
    filter: drop-shadow(-2px 4px 6px rgba(244, 114, 182, 0.2));
}
.layout-traditional-book:not(.traditional-book-theme) .node.gender-female.selected rect {
    stroke: var(--rose-gold-dark);
    stroke-width: 3.8px;
    filter: drop-shadow(-3px 5px 12px rgba(244, 114, 182, 0.35));
}
.layout-traditional-book:not(.traditional-book-theme) .node.gender-female .traditional-plaque-text {
    fill: var(--rose-gold);
}
.layout-traditional-book:not(.traditional-book-theme) .node.gender-female:hover .traditional-plaque-text,
.layout-traditional-book:not(.traditional-book-theme) .node.gender-female.selected .traditional-plaque-text {
    fill: var(--rose-gold-dark);
}

/* Badges / Status inside Traditional Rect */
.layout-traditional-book.traditional-book-theme .node.badge-adopted rect {
    stroke-dasharray: 4, 4;
}

.layout-traditional-book.traditional-book-theme .node.badge-no-heir rect {
    background: #faf2f2;
}

.layout-traditional-book.traditional-book-theme .node.badge-died-young {
    opacity: 0.45;
}

.layout-traditional-book.traditional-book-theme .node.badge-died-young rect {
    stroke: #7c7c7c;
}

.layout-traditional-book.traditional-book-theme .node.badge-died-young .traditional-plaque-text {
    fill: #666666;
}

/* Dark theme traditional badges */
.layout-traditional-book:not(.traditional-book-theme) .node.badge-adopted rect {
    stroke-dasharray: 4, 4;
}

.layout-traditional-book:not(.traditional-book-theme) .node.badge-no-heir rect {
    background: rgba(200, 35, 35, 0.05);
}

.layout-traditional-book:not(.traditional-book-theme) .node.badge-died-young {
    opacity: 0.45;
}

.layout-traditional-book:not(.traditional-book-theme) .node.badge-died-young rect {
    stroke: #3f3f46;
}

.layout-traditional-book:not(.traditional-book-theme) .node.badge-died-young .traditional-plaque-text {
    fill: var(--text-muted);
}

/* Traditional grid lines & generation headers */
.layout-traditional-book.traditional-book-theme .gen-grid-line {
    stroke: var(--crimson);
    stroke-opacity: 0.15;
    stroke-width: 1px;
}

.layout-traditional-book.traditional-book-theme .gen-header-text {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 0.85rem;
    fill: var(--crimson);
    letter-spacing: 0.15em;
}

/* Dark theme traditional grid lines & generation headers */
.layout-traditional-book:not(.traditional-book-theme) .gen-grid-line {
    stroke: var(--gold);
    stroke-opacity: 0.15;
    stroke-width: 1px;
}

.layout-traditional-book:not(.traditional-book-theme) .gen-header-text {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 0.85rem;
    fill: var(--gold);
    letter-spacing: 0.15em;
}

/* ========================================================== */
/* TRADITIONAL THEME - HOME PAGE ADAPTATIONS                  */
/* ========================================================== */

/* 6.1 Hero Section Custom Styling in Parchment Theme */
.traditional-book-theme .home-hero {
    background: linear-gradient(135deg, var(--parchment-card) 0%, #ebe2ce 100%) !important;
    border: 1px solid var(--parchment-border) !important;
    box-shadow: 0 10px 30px rgba(139, 0, 0, 0.05) !important;
}

.traditional-book-theme .hero-overlay {
    background: linear-gradient(to right, rgba(250, 245, 235, 0.98) 35%, rgba(250, 245, 235, 0.2) 100%) !important;
}

.traditional-book-theme .home-hero::before {
    opacity: 0.22 !important; /* Make golden crest background watermark beautifully visible on paper */
}

.traditional-book-theme .hero-title {
    color: var(--parchment-text-primary) !important;
    text-shadow: none !important; /* Clean ink-on-paper look, no dark drop shadow */
}

.traditional-book-theme .hero-subtitle {
    color: var(--crimson) !important;
}

.traditional-book-theme .hero-description {
    color: var(--parchment-text-secondary) !important;
}

.traditional-book-theme .hero-crest {
    border-color: var(--crimson) !important;
    color: var(--crimson) !important;
    background: rgba(200, 35, 35, 0.03) !important;
    box-shadow: 0 0 15px rgba(200, 35, 35, 0.1) !important;
}

.traditional-book-theme .hero-btn {
    background: var(--crimson) !important;
    border-color: var(--crimson) !important;
    color: #ffffff !important; /* Critical contrast fix: white text on crimson button */
    box-shadow: 0 4px 15px rgba(200, 35, 35, 0.15) !important;
}

.traditional-book-theme .hero-btn:hover {
    background: var(--crimson-hover) !important;
    border-color: var(--crimson-hover) !important;
    color: #ffffff !important;
    box-shadow: 0 6px 20px rgba(200, 35, 35, 0.35) !important;
}

/* 6.2 Scroll Content Legibility Adaptation */
.traditional-book-theme .scroll-content {
    color: var(--parchment-text-primary) !important;
}

.traditional-book-theme .scroll-content strong {
    color: var(--crimson) !important; /* Highlight historical ancestor/place names in elegant crimson */
}

/* 6.3 Committee Table Adaptation */
.traditional-book-theme .committee-table th {
    color: var(--parchment-text-primary) !important;
    background: rgba(200, 35, 35, 0.03) !important;
    border-bottom: 2px solid var(--crimson) !important;
}

.traditional-book-theme .committee-table td {
    color: var(--parchment-text-primary) !important;
    border-bottom: 1px solid var(--parchment-border) !important;
}

.traditional-book-theme .committee-table td strong {
    color: var(--crimson) !important; /* Highlight committee locations/roles in crimson */
}

.traditional-book-theme .committee-table tbody tr:hover {
    background: rgba(200, 35, 35, 0.015) !important;
}

/* 6.4 Stats Dashboard Adaptation */
.traditional-book-theme .home-stat-card {
    background: rgba(139, 0, 0, 0.01) !important;
    border-color: var(--parchment-border) !important;
    box-shadow: 0 2px 8px rgba(139, 0, 0, 0.02) !important;
}

.traditional-book-theme .home-stat-card:hover {
    background: rgba(200, 35, 35, 0.03) !important;
    border-color: var(--crimson) !important;
    box-shadow: 0 4px 15px rgba(200, 35, 35, 0.08) !important;
}

.traditional-book-theme .home-stat-card .stat-label {
    color: var(--parchment-text-secondary) !important;
}

/* 6.5 Generation Sequence Badges Adaptation */
.traditional-book-theme .gen-chain-group {
    background: rgba(200, 35, 35, 0.02) !important;
    border-color: rgba(200, 35, 35, 0.08) !important;
}

.traditional-book-theme .gen-chain-group:hover {
    background: rgba(200, 35, 35, 0.04) !important;
    border-color: rgba(200, 35, 35, 0.2) !important;
}

.traditional-book-theme .gen-chain-badge {
    background: #ffffff !important; /* Traditional stamp white backing */
    border: 1.5px solid var(--crimson) !important;
    color: var(--crimson) !important;
    box-shadow: 0 2px 8px rgba(139, 0, 0, 0.08) !important;
}

.traditional-book-theme .gen-chain-badge:hover {
    background: var(--crimson) !important;
    border-color: var(--crimson) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(200, 35, 35, 0.3) !important;
}

.traditional-book-theme .gen-chain-badge .gen-num {
    color: var(--parchment-text-secondary) !important;
}

.traditional-book-theme .gen-chain-badge:hover .gen-num {
    color: rgba(255, 255, 255, 0.8) !important; /* Turn white on hover */
}

/* 7.3 Organic Parchment Woven Textures & Muddy-Gold Deckled Surfaces */
.traditional-book-theme .home-card,
.traditional-book-theme .stat-card,
.traditional-book-theme .home-stat-card,
.traditional-book-theme .app-sidebar,
.traditional-book-theme .side-viewer-pane {
    background-color: var(--parchment-card) !important;
    background-image:
        radial-gradient(rgba(139, 0, 0, 0.015) 0.8px, transparent 0.8px),
        radial-gradient(rgba(139, 0, 0, 0.01) 0.8px, var(--parchment-card) 0.8px) !important;
    background-size: 8px 8px !important;
    background-position: 0 0, 4px 4px !important;
    border: 1px solid rgba(220, 209, 186, 0.85) !important;
    box-shadow: 0 6px 20px rgba(139, 0, 0, 0.02), inset 0 0 40px rgba(250, 245, 235, 0.75) !important;
    transition: var(--transition-elastic) !important;
}

.traditional-book-theme .home-card:hover,
.traditional-book-theme .stat-card:hover,
.traditional-book-theme .home-stat-card:hover {
    transform: translateY(-5px) scale(1.006) !important;
    border-color: var(--crimson) !important;
    box-shadow: 0 12px 30px rgba(200, 35, 35, 0.08), inset 0 0 40px rgba(250, 245, 235, 0.65) !important;
}

/* Magnifier lens on scan image */
.scan-magnifier-lens {
    position: absolute;
    border: 2px solid var(--gold);
    border-radius: 50%;
    cursor: none;
    /* size of magnifier lens */
    width: 150px;
    height: 150px;
    display: none;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 10;
}

/* Responsiveness overrides */
@media (max-width: 1024px) {
    .app-sidebar {
        width: 320px;
    }
    .side-viewer-pane {
        width: 400px;
    }
}

/* Title badge for active filters */
.title-with-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    animation: badge-fade-in 0.3s ease-out;
}

@keyframes badge-fade-in {
    from { opacity: 0; transform: translateY(-3px); }
    to { opacity: 1; transform: translateY(0); }
}

.filter-badge.hidden {
    display: none !important;
}

#clear-all-filters-btn {
    background: none;
    border: none;
    color: var(--gold);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0 2px;
    display: flex;
    align-items: center;
    transition: var(--transition-fast);
}

#clear-all-filters-btn:hover {
    color: var(--text-primary);
    transform: scale(1.15);
}

/* Sidebar profile card buttons */
.profile-actions-row {
    display: flex;
    gap: 8px;
    margin: 16px 0;
}

.action-btn-secondary {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    padding: 9px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.action-btn-secondary:hover {
    background: rgba(212, 175, 55, 0.08);
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 10px var(--gold-glow);
}

.action-btn-secondary.active {
    background: rgba(212, 175, 55, 0.16);
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 12px var(--gold-glow);
}

/* Lineage Flow Stepper */
.lineage-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.04);
    padding: 10px;
    border-radius: 6px;
    margin-top: 8px;
}

.lineage-node {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    padding: 3px 7px;
    border-radius: 4px;
    font-size: 0.76rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.lineage-node:hover {
    background: rgba(212, 175, 55, 0.08);
    border-color: var(--gold);
    color: var(--gold);
}

.lineage-node.current {
    background: rgba(212, 175, 55, 0.15);
    border-color: var(--gold);
    color: var(--gold);
    font-weight: 600;
}

.lineage-arrow {
    color: var(--text-muted);
    font-size: 0.65rem;
    user-select: none;
}

/* Traditional Book Theme overrides */
.traditional-book-theme .filter-badge {
    background: rgba(200, 35, 35, 0.08);
    border-color: var(--crimson);
    color: var(--crimson);
}

.traditional-book-theme #clear-all-filters-btn {
    color: var(--crimson);
}

.traditional-book-theme #clear-all-filters-btn:hover {
    color: var(--crimson-hover);
}

.traditional-book-theme .action-btn-secondary {
    background: rgba(0, 0, 0, 0.02);
    border-color: var(--parchment-border);
    color: var(--parchment-text-primary);
}

.traditional-book-theme .action-btn-secondary:hover {
    background: rgba(200, 35, 35, 0.04);
    border-color: var(--crimson);
    color: var(--crimson);
    box-shadow: none;
}

.traditional-book-theme .action-btn-secondary.active {
    background: rgba(200, 35, 35, 0.08);
    border-color: var(--crimson);
    color: var(--crimson);
    box-shadow: none;
}

.traditional-book-theme .lineage-flow {
    background: rgba(0, 0, 0, 0.01);
    border-color: var(--parchment-border);
}

.traditional-book-theme .lineage-node {
    background: rgba(0, 0, 0, 0.02);
    border-color: var(--parchment-border);
    color: var(--parchment-text-secondary);
}

.traditional-book-theme .lineage-node:hover {
    background: rgba(200, 35, 35, 0.05);
    border-color: var(--crimson);
    color: var(--crimson);
}

.traditional-book-theme .lineage-node.current {
    background: rgba(200, 35, 35, 0.08);
    border-color: var(--crimson);
    color: var(--crimson);
}

/* No results placeholder styles */
.no-results-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    color: var(--text-muted);
    font-family: var(--font-ui);
    animation: badge-fade-in 0.3s ease-out;
}

.no-results-placeholder .placeholder-content {
    text-align: center;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border-color);
    padding: 40px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.no-results-placeholder i {
    font-size: 3rem;
    color: rgba(212, 175, 55, 0.3);
    margin-bottom: 20px;
    display: block;
}

.no-results-placeholder p {
    font-size: 0.95rem;
    margin-bottom: 24px;
    color: var(--text-secondary);
}

.no-results-placeholder button {
    margin: 0 auto;
}

/* Traditional Book Theme adapter for placeholder */
.traditional-book-theme .no-results-placeholder .placeholder-content {
    background: #faf7ed;
    border: 1px solid var(--parchment-border);
    box-shadow: none;
}

.traditional-book-theme .no-results-placeholder i {
    color: var(--crimson);
    opacity: 0.4;
}

.traditional-book-theme .no-results-placeholder p {
    color: var(--parchment-text-primary);
}

@media (max-width: 768px) {
    .canvas-wrapper .zoom-controls {
        display: flex !important;
        bottom: 16px;
        right: 16px;
        padding: 4px;
        border-radius: 8px;
        gap: 4px;
    }
    .canvas-wrapper .zoom-controls button {
        width: 32px;
        height: 32px;
        border-radius: 6px;
    }

    /* Sidebars float as sliding overlays */
    .app-sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 320px;
        z-index: 1000;
        box-shadow: 10px 0 30px rgba(0,0,0,0.6);
        transform: translateX(0);
    }

    .app-sidebar.collapsed {
        transform: translateX(-100%);
        width: 320px !important;
        opacity: 0;
        pointer-events: none;
        box-shadow: none;
        border-right: none;
    }

    .side-viewer-pane {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        z-index: 1100; /* overlay above everything when active */
        border-left: none;
        box-shadow: -10px 0 30px rgba(0,0,0,0.5);
        transform: translateX(0);
    }

    .side-viewer-pane.collapsed {
        transform: translateX(100%);
        width: 100% !important;
        box-shadow: none;
        border-left: none;
    }

    /* GPU layer promotion for smooth pan/zoom on touch */
    .main-g {
        will-change: transform;
    }

    /* Layout adjustments for main panel to occupy full width */
    .app-main {
        width: 100%;
    }

    /* Pane controls adjustments for mobile */
    .pane-controls {
        height: 60px;
        padding: 0 16px;
    }

    .view-title {
        font-size: 0.95rem;
    }

    .view-tag {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    .close-viewer-btn {
        background: rgba(212, 175, 55, 0.1) !important;
        border: 1px solid rgba(212, 175, 55, 0.25) !important;
        color: var(--gold) !important;
        font-size: 0.82rem !important;
        padding: 5px 12px !important;
        border-radius: 20px !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
    }

    .traditional-book-theme .close-viewer-btn {
        background: rgba(200, 35, 35, 0.05) !important;
        border-color: rgba(200, 35, 35, 0.25) !important;
        color: var(--crimson) !important;
    }

    .close-viewer-btn:hover {
        transform: none !important;
    }

    .close-viewer-btn .close-btn-text {
        display: inline !important;
        font-family: var(--font-ui);
        font-weight: 600;
    }

    .close-viewer-btn .desktop-only-icon {
        display: none !important;
    }

    .close-viewer-btn .mobile-only-icon {
        display: inline-block !important;
    }

    /* Details profile responsive grid display */
    .profile-details-grid {
        grid-template-columns: 1fr;
    }

    .detail-item.full-width {
        grid-column: span 1;
    }

    /* traditional book theme positioning overlays */
    .traditional-book-theme .app-sidebar {
        background: var(--parchment-bg);
        border-right: 1px solid var(--parchment-border);
        box-shadow: 5px 0 20px rgba(0,0,0,0.15);
    }

    .traditional-book-theme .side-viewer-pane {
        background: var(--parchment-bg);
        border-left: 1px solid var(--parchment-border);
        box-shadow: -5px 0 20px rgba(0,0,0,0.15);
    }

    /* Fix horizontal scroll issues on Locations, Relations and Admin pages on mobile */
    .locations-scrollable,
    .relation-scrollable,
    .admin-scrollable {
        padding: 16px 16px 30px !important;
    }

    .locations-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .location-card {
        padding: 16px !important;
    }

    .map-title-bar {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
        padding: 10px 16px !important;
    }

    .map-title-bar small {
        display: block !important;
    }

    /* Avoid title-with-tag horizontal overflow on all pages on mobile */
    .title-with-tag {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
    }
}

/* ============================================================================
   Header Navigation Bar (Sticky Header)
   ============================================================================ */
.app-header {
    height: 70px;
    background: rgba(15, 15, 17, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 32px;
    z-index: 100;
    flex-shrink: 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-logo .logo-crest {
    width: 38px;
    height: 38px;
    border: 2px solid var(--gold);
    color: var(--gold);
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 900;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(212, 175, 55, 0.05);
    box-shadow: 0 0 10px var(--gold-glow);
}

.header-logo .logo-text h2 {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.1em;
    line-height: 1.2;
}

.header-logo .logo-text span {
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    display: block;
}

.header-nav {
    display: flex;
    gap: 8px;
    position: absolute;
    right: 32px;
    top: 0;
    height: 70px;
    align-items: center;
    z-index: 101;
}

.nav-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 8px 18px;
    border-radius: 30px; /* Fully rounded pill shape */
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-elastic);
}

.nav-btn i {
    font-size: 0.9rem;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nav-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.nav-btn.active {
    color: var(--gold);
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15) 0%, rgba(179, 133, 21, 0.04) 100%) !important;
    border-color: rgba(212, 175, 55, 0.55) !important;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.nav-btn.active i {
    transform: scale(1.15) translateY(-1px);
    color: var(--gold);
}

/* ============================================================================
   Tab Layout Containers
   ============================================================================ */
.app-pages-container {
    flex: 1;
    position: relative;
    width: 100vw;
    height: calc(100vh - 70px);
    overflow: hidden;
    background: var(--bg-dark);
}

.page-content {
    display: none !important;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: absolute;
    top: 0;
    left: 0;
}

.page-content.active {
    display: flex !important;
    animation: page-fade-in 0.45s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@keyframes page-fade-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-scrollable {
    flex: 1;
    overflow-y: auto;
    width: 100%;
    height: 100%;
    padding: 30px;
    box-sizing: border-box;
}

/* ============================================================================
   Page 1: Homepage Styles
   ============================================================================ */
.home-scrollable {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 24px 32px 48px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* Lineage Gate Card */
.lineage-gate-card {
    flex-shrink: 0 !important; /* 确保弹性盒子绝不压缩此门禁卡片 */
    min-height: 480px !important; /* 确立安全的最小显示高度支撑所有输入框 */
}

/* Hero Section */
.home-hero {
    position: relative;
    border-radius: 16px;
    min-height: 400px;
    height: auto;
    background: linear-gradient(135deg, #181512 0%, #0d0d0f 100%);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 50px 60px;
    flex-shrink: 0; /* 避免在 flex 容器高度不足时被压缩 */
}

/* Sub-watermark calligraphic clan emblem background */
.home-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('assets/images/zhang_bg.svg');
    background-size: contain;
    background-position: right 60px center;
    background-repeat: no-repeat;
    opacity: 0.16;
    transition: var(--transition-smooth);
    pointer-events: none;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to right, rgba(10, 10, 11, 0.95) 40%, rgba(10, 10, 11, 0.3) 100%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 650px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.hero-crest {
    font-family: var(--font-serif);
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--gold);
    width: 60px;
    height: 60px;
    border: 2px solid var(--gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(212, 175, 55, 0.05);
    margin-bottom: 20px;
    box-shadow: 0 0 20px var(--gold-glow);
}

.hero-title {
    font-family: var(--font-serif);
    font-size: 3rem;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: 0.15em;
    margin-bottom: 8px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.hero-subtitle {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--gold);
    letter-spacing: 0.1em;
    margin-bottom: 16px;
}

.hero-description {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 28px;
}

.hero-btn {
    background: var(--gold);
    border: 1px solid var(--gold);
    color: #141416;
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 12px 28px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 20px var(--gold-glow);
}

.hero-btn:hover {
    background: var(--gold-dark);
    border-color: var(--gold-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(212, 175, 55, 0.45);
}

.hero-btn:active {
    transform: translateY(0);
}

/* Home Layout Grid */
.home-layout-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 32px;
    flex-shrink: 0; /* 避免在 flex 容器中被压缩 */
}

.home-left-col, .home-right-col {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.home-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px 28px;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.03), inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    transition: var(--transition-elastic);
}

.home-card:hover {
    transform: translateY(-4px) scale(1.005);
    border-color: var(--border-hover);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05), inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.home-card .card-title {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.home-card .card-title i {
    font-size: 1.1rem;
}

/* Preface / Relocation Text */
.scroll-card {
    position: relative;
}

.scroll-content {
    font-family: var(--font-serif);
    font-size: 0.95rem; /* 略微放大字号以利于中老年族人及学术阅读 */
    color: #d1d1d6; /* 暖灰象牙白色，大幅减弱纯白在暗色背景下的刺眼光晕 */
    line-height: 1.85;
}

.scroll-content p {
    margin-bottom: 16px;
    text-indent: 2em;
    text-align: justify; /* 两端对齐，营造传统线装谱书般的工整学术版式 */
}

.scroll-content p:last-child {
    margin-bottom: 0;
}

/* Stats dashboard */
.home-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.home-stat-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px 16px;
    text-align: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.01);
    transition: var(--transition-elastic);
}

.home-stat-card:hover {
    border-color: var(--border-hover);
    background: rgba(212, 175, 55, 0.03) !important;
    box-shadow: 0 10px 25px rgba(212, 175, 55, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.02);
    transform: translateY(-4px) scale(1.02);
}

.home-stat-card .stat-num {
    font-size: 2.2rem;
    margin-bottom: 6px;
}

/* Generation Sequence Chain */
.generation-intro {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.gen-chain-container {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 20px;
}

.gen-chain-group {
    display: flex;
    gap: 6px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 6px 8px;
    border-radius: 28px;
    align-items: center;
    position: relative;
    flex-wrap: nowrap;
    margin-bottom: 16px;
    transition: var(--transition-smooth);
}

.gen-chain-group:hover {
    background: rgba(200, 35, 35, 0.03);
    border-color: rgba(200, 35, 35, 0.25);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.gen-chain-badge {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(200, 35, 35, 0.05);
    border: 1.5px solid rgba(200, 35, 35, 0.3);
    color: var(--crimson-hover);
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: default;
    transition: var(--transition-smooth);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.gen-chain-badge:hover {
    transform: translateY(-4px) scale(1.05);
    background: var(--crimson);
    border-color: var(--crimson);
    color: #ffffff;
    box-shadow: 0 4px 15px var(--crimson-glow);
}

.gen-chain-badge .gen-num {
    position: absolute;
    bottom: -18px;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-weight: normal;
    white-space: nowrap;
}

.gen-chain-badge:hover .gen-num {
    color: var(--text-secondary);
}

/* Committee Table */
.committee-table-wrapper {
    overflow-x: auto;
}

.committee-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.committee-table th, .committee-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.committee-table th {
    font-weight: 600;
    color: var(--gold);
    background: rgba(255, 255, 255, 0.01);
}

.committee-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.01);
}

.committee-table td strong {
    color: var(--text-primary);
}

/* ============================================================================
   Page Header Shared Component
   ============================================================================ */
.tab-page-header {
    margin-bottom: 28px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.title-with-tag {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.title-with-tag h2 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
}

.title-with-tag h2 i {
    margin-right: 6px;
}

.page-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ============================================================================
   Page 3: Locations Gazetteer Styles
   ============================================================================ */
.locations-scrollable {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 32px 40px 48px;
    box-sizing: border-box;
}

.locations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
}

.location-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    transition: var(--transition-smooth);
}

.location-card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    transform: translateY(-3px);
}

.location-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 14px;
    margin-bottom: 16px;
}

.location-card-header .loc-title {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.location-card-header .loc-title i {
    color: var(--gold);
}

.location-card-header .loc-badge {
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid var(--gold);
    color: var(--gold);
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.location-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    margin-bottom: 20px;
}

.location-detail-row {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.location-detail-row strong {
    color: var(--text-primary);
}

.location-origin-box {
    background: rgba(255,255,255,0.01);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.location-origin-box strong {
    color: var(--gold);
}

.location-link-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-fast);
}

.location-link-btn:hover {
    background: var(--gold-glow);
    border-color: var(--gold);
    color: var(--gold);
}

.location-link-btn i {
    font-size: 0.9rem;
}

/* Disabled Location Card and Pending Styles */
.location-card-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: rgba(20, 20, 22, 0.4) !important;
    border-color: rgba(255, 255, 255, 0.03) !important;
    backdrop-filter: blur(4px);
    pointer-events: none; /* Disable all pointer interactions inside the card except maybe tooltip if any */
}

.location-card-disabled * {
    pointer-events: none; /* Prevent inner elements from receiving cursor events */
}

.location-card-disabled:hover {
    transform: none !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25) !important;
    border-color: rgba(255, 255, 255, 0.03) !important;
}

.location-card-header .loc-badge.badge-pending {
    background: rgba(255, 255, 255, 0.02);
    border-color: var(--text-muted);
    color: var(--text-muted);
}

.location-link-btn:disabled {
    background: rgba(255, 255, 255, 0.01) !important;
    border-color: rgba(255, 255, 255, 0.03) !important;
    color: var(--text-muted) !important;
    cursor: not-allowed !important;
    pointer-events: none;
}


/* ============================================================================
   Page 4: Relationship Calculator Styles
   ============================================================================ */
.relation-scrollable {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 32px 40px 48px;
    box-sizing: border-box;
}

.relation-calculator-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 900px;
    margin: 0 auto;
}

.relation-grid-layout {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 24px;
    max-width: 1000px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .relation-grid-layout {
        grid-template-columns: 1fr;
    }
}

.locate-myself-card,
.relation-calculator-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 25px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-sizing: border-box;
}

.traditional-book-theme .locate-myself-card,
.traditional-book-theme .relation-calculator-card {
    background: var(--parchment-card) !important;
    border-color: var(--parchment-border) !important;
    box-shadow: 0 4px 20px rgba(139, 0, 0, 0.05) !important;
}

.card-title-sub {
    font-family: var(--font-display);
    font-size: 1.15rem;
    color: var(--gold);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.traditional-book-theme .card-title-sub {
    color: var(--crimson) !important;
}

.card-desc-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

/* Locate search wrapper styles */
.locate-search-wrapper {
    position: relative;
    width: 100%;
}
#locate-self-input {
    width: 100%;
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    padding: 12px 40px 12px 38px !important;
    color: var(--text-primary) !important;
    font-family: var(--font-ui) !important;
    font-size: 0.9rem !important;
    outline: none !important;
    transition: var(--transition-fast) !important;
    box-sizing: border-box !important;
}

#locate-self-input:focus {
    border-color: var(--gold) !important;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2) !important;
}

/* Traditional Book Theme Adaptation for locate input */
.traditional-book-theme #locate-self-input {
    background: #faf7ed !important;
    border-color: var(--parchment-border) !important;
    color: var(--parchment-text-primary) !important;
}

.traditional-book-theme #locate-self-input:focus {
    border-color: var(--crimson) !important;
    box-shadow: 0 0 10px rgba(200, 35, 35, 0.15) !important;
}
.locate-search-wrapper .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.88rem;
    pointer-events: none;
}

/* Locate person detail card */
.locate-person-detail-card {
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.3s ease;
}

.traditional-book-theme .locate-person-detail-card {
    border-color: var(--parchment-border) !important;
    background: rgba(139, 0, 0, 0.02) !important;
}

.locate-person-detail-card .detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding-bottom: 8px;
}
.traditional-book-theme .locate-person-detail-card .detail-header {
    border-bottom-color: rgba(139, 0, 0, 0.08) !important;
}

.locate-person-detail-card .detail-name {
    font-family: var(--font-serif);
    font-weight: bold;
    font-size: 1.25rem;
    color: var(--text-primary);
}
.locate-person-detail-card .detail-gen-badge {
    background: rgba(212, 175, 55, 0.15);
    color: var(--gold);
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
}
.traditional-book-theme .locate-person-detail-card .detail-gen-badge {
    background: rgba(139, 0, 0, 0.08) !important;
    color: var(--crimson) !important;
}

.locate-person-detail-card .detail-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
}
.locate-person-detail-card .detail-row {
    line-height: 1.5;
}
.locate-person-detail-card .detail-row strong {
    color: var(--text-secondary);
}
.locate-person-detail-card .detail-row p {
    margin: 4px 0 0 0;
    padding: 8px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 4px;
    color: var(--text-primary);
    max-height: 80px;
    overflow-y: auto;
    font-family: var(--font-serif);
    line-height: 1.6;
}
.traditional-book-theme .locate-person-detail-card .detail-row p {
    background: rgba(0, 0, 0, 0.01) !important;
    border-color: rgba(0, 0, 0, 0.04) !important;
}

.locate-person-detail-card .detail-actions {
    display: flex;
    gap: 12px;
    margin-top: 6px;
}
.locate-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.locate-tree-btn {
    background: var(--gold);
    color: #111 !important;
    border: 1px solid var(--gold);
}
.locate-tree-btn:hover {
    background: #e5bd3d;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.locate-book-btn {
    background: transparent;
    color: var(--gold) !important;
    border: 1px solid var(--gold);
}
.locate-book-btn:hover {
    background: rgba(212, 175, 55, 0.1);
}

.traditional-book-theme .locate-tree-btn {
    background: var(--crimson) !important;
    color: #fff !important;
    border-color: var(--crimson) !important;
}
.traditional-book-theme .locate-tree-btn:hover {
    background: var(--crimson-hover) !important;
    box-shadow: 0 0 10px rgba(139, 0, 0, 0.2) !important;
}
.traditional-book-theme .locate-book-btn {
    color: var(--crimson) !important;
    border-color: var(--crimson) !important;
}
.traditional-book-theme .locate-book-btn:hover {
    background: rgba(139, 0, 0, 0.05) !important;
}

.relation-calculator-card .calc-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 12px;
}
.relation-calculator-card .calc-swap-btn {
    transform: rotate(90deg);
    align-self: center;
    margin: -4px 0;
}

.calculator-inputs-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 4px 25px rgba(0,0,0,0.3);
}

.calc-row {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 24px;
}

.calc-person-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.calc-person-box label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calc-search-wrapper {
    margin-bottom: 0;
}

.calc-search-wrapper input {
    width: 100%;
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    padding: 12px 105px 12px 14px !important;
    color: var(--text-primary) !important;
    font-family: var(--font-ui) !important;
    font-size: 0.88rem !important;
    outline: none !important;
    transition: var(--transition-fast) !important;
    box-sizing: border-box !important;
}

.calc-search-wrapper input:focus {
    border-color: var(--gold) !important;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.25) !important;
}

/* Traditional Book Theme Adaptation */
.traditional-book-theme .calc-search-wrapper input {
    background: #faf7ed !important;
    border-color: var(--parchment-border) !important;
    color: var(--parchment-text-primary) !important;
}

.traditional-book-theme .calc-search-wrapper input:focus {
    border-color: var(--crimson) !important;
    box-shadow: 0 0 10px rgba(200, 35, 35, 0.15) !important;
}

.calc-load-selected-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.2);
    color: var(--gold);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.calc-load-selected-btn:hover {
    background: var(--gold-glow);
    border-color: var(--gold);
}

.selected-person-badge {
    background: rgba(212, 175, 55, 0.06);
    border: 1.2px solid rgba(212, 175, 55, 0.3);
    border-radius: 6px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: badge-appear 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes badge-appear {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.selected-person-badge .name {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gold);
}

.selected-person-badge .gen {
    font-size: 0.72rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-secondary);
}

.selected-person-badge .remove-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 1rem;
    transition: var(--transition-fast);
}

.selected-person-badge .remove-btn:hover {
    color: var(--crimson-hover);
}

.calc-swap-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-top: 20px;
    transition: var(--transition-fast);
}

.calc-swap-btn:hover {
    background: rgba(212, 175, 55, 0.05);
    border-color: var(--gold);
    color: var(--gold);
}

.calculate-btn {
    width: 100%;
    background: var(--gold);
    border: 1px solid var(--gold);
    color: #141416;
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px var(--gold-glow);
}

.calculate-btn:hover {
    background: var(--gold-dark);
    border-color: var(--gold-dark);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.35);
}

/* Results panel */
.calculator-results-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 4px 25px rgba(0,0,0,0.3);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: card-slide-down 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@keyframes card-slide-down {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Classical background scroll header overlay */
.calculator-results-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(to right, var(--crimson) 0%, var(--gold) 50%, var(--crimson) 100%);
}

.results-crest {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--gold);
    width: 50px;
    height: 50px;
    border: 2px solid var(--gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(212, 175, 55, 0.05);
    margin-bottom: 12px;
}

.results-title {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.1em;
    margin-bottom: 24px;
}

.results-verdict-row {
    display: flex;
    width: 100%;
    gap: 20px;
    margin-bottom: 20px;
}

.verdict-box {
    flex: 1;
    background: rgba(255,255,255,0.01);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 8px;
    padding: 18px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.verdict-box .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.verdict-box .verdict-val {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    font-weight: 700;
}

.relation-meta-info {
    font-size: 0.82rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    margin-bottom: 28px;
}

.relation-pathway-section {
    width: 100%;
    border-top: 1px solid var(--border-color);
    padding-top: 24px;
}

.relation-pathway-section h4 {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    color: var(--gold);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.relation-pathway-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    padding: 20px;
}

.path-step-node {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.path-step-node.start {
    border-color: var(--gold);
    background: rgba(212, 175, 55, 0.03);
}

.path-step-node.end {
    border-color: var(--success);
    background: rgba(52, 211, 153, 0.03);
}

.path-step-node .node-name {
    font-family: var(--font-serif);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.path-step-node .node-gen {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.path-arrow {
    color: var(--text-muted);
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.path-arrow i {
    font-size: 0.85rem;
}

.path-arrow .arrow-relation {
    font-size: 0.6rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ============================================================================
   Page 5: Preface Document Reader Styles
   ============================================================================ */
.preface-scrollable {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 32px 40px 48px;
    box-sizing: border-box;
}

.preface-paper-container {
    max-width: 100%;
    width: fit-content;
    margin: 0 auto;
    background-color: var(--parchment-bg);
    border: 1px solid var(--parchment-border);
    border-radius: 12px;
    padding: 48px 64px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    background-image: radial-gradient(rgba(212, 175, 55, 0.03) 1px, transparent 0);
    background-size: 24px 24px;
    overflow-x: auto;
    writing-mode: vertical-rl; /* Enable native vertical layout and scrolling starting from right */
    box-sizing: border-box;
}

.preface-traditional-layout {
    display: block; /* Pure block layout */
    width: max-content;
    margin: 0 auto;
    color: var(--parchment-text-primary);
}

/* Traditional vertical Chinese reading layout flowing Right-to-Left */
.preface-vertical-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: var(--font-serif);
    line-height: 2.8;
    letter-spacing: 0.18em;
    font-size: 1.15rem;
    height: 480px;
    display: block; /* Pure block layout to stack columns horizontally */
    width: max-content; /* Ensure width expands to fit all vertical columns */
    margin: 0 auto;
}

.preface-vertical-text h3 {
    font-size: 1.8rem;
    font-weight: 900;
    margin-right: 15px;
    margin-left: 50px;
    color: var(--crimson);
    letter-spacing: 0.25em;
    text-align: start; /* Align to the top of the column */
    display: inline-block; /* Enable shrink-wrap width calculation */
    height: 100%;
}

.preface-vertical-text p {
    text-align: justify;
    text-indent: 2em;
    margin-left: 36px;
    height: 100%;
    display: inline-block; /* Enable shrink-wrap width calculation */
    vertical-align: top; /* Align columns to the top */
}

.preface-marginalia {
    color: var(--crimson);
    font-family: "Kaiti", "STKaiti", serif;
    font-size: 0.82em;
    border: 1.2px dashed rgba(200, 35, 35, 0.5);
    padding: 2px 6px;
    margin: 0 6px;
    writing-mode: vertical-rl;
    text-orientation: upright;
    display: inline-block;
    vertical-align: top;
    background-color: rgba(200, 35, 35, 0.05);
    border-radius: 4px;
    letter-spacing: 0.05em;
    font-weight: bold;
}

@media (max-width: 768px) {
    .preface-marginalia {
        writing-mode: horizontal-tb !important;
        display: inline-block !important;
        margin: 4px 0 !important;
        vertical-align: middle !important;
    }
}

.preface-vertical-text p.signature {
    margin-left: 50px;
    color: var(--parchment-text-secondary);
    font-size: 0.95rem;
    text-align: end; /* Align to the bottom of the column */
    height: 100%;
    text-indent: 0;
    display: inline-block; /* Enable shrink-wrap width calculation */
    vertical-align: top; /* Align columns to the top */
}

/* Adjustments for responsive display on Home layouts */
@media (max-width: 1024px) {
    .home-layout-grid {
        grid-template-columns: 1fr;
    }

    .home-hero {
        padding: 48px 32px;
        height: auto !important;
        min-height: auto;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
    }

    .home-hero::before {
        background-position: center;
        background-size: 80%;
        opacity: 0.09;
    }

    .hero-title {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {
    html, body {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
    }

    .app-header {
        padding: 0 16px !important;
        flex-direction: row !important;
        height: 54px !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        border-bottom: 1px solid var(--border-color) !important;
        gap: 0 !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: #0f0f11 !important; /* 避免移动端包含块特性导致 fixed 底部导航条渲染在顶部 */
    }

    .header-logo .logo-crest {
        width: 32px !important;
        height: 32px !important;
        font-size: 1.1rem !important;
        border-radius: 4px !important;
    }

    .header-logo .logo-text h2 {
        font-size: 1.1rem !important;
    }

    .header-logo .logo-text span {
        font-size: 0.62rem !important;
    }

    .app-pages-container {
        height: calc(100vh - 54px - 60px) !important;
        margin-bottom: 60px !important;
    }

    .header-nav {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important; /* Reset desktop top: 0 */
        height: 60px !important;
        background: rgba(15, 15, 17, 0.96) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border-top: 1px solid var(--border-color) !important;
        border-bottom: none !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: space-around !important;
        align-items: center !important;
        padding: 0 !important;
        z-index: 1000 !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4) !important;
        margin: 0 !important;
        overflow-x: visible !important;
    }

    .nav-btn {
        flex: 1 !important;
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 4px !important;
        background: transparent !important;
        border: none !important;
        padding: 6px 0 !important;
        color: var(--text-secondary) !important;
        font-size: 0.7rem !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    .nav-btn i {
        font-size: 1.25rem !important;
        transition: transform 0.2s ease !important;
    }

    .nav-btn:hover {
        background: transparent !important;
        border-color: transparent !important;
        color: var(--text-primary) !important;
    }

    .nav-btn.active {
        color: var(--gold) !important;
        background: transparent !important;
        border-color: transparent !important;
        box-shadow: none !important;
    }

    .nav-btn.active i {
        transform: scale(1.1) !important;
        color: var(--gold) !important;
    }

    .home-scrollable {
        padding: 16px 12px 24px !important;
        gap: 20px !important;
        overflow-y: auto !important;
        height: 100% !important;
    }

    .home-hero {
        padding: 36px 20px 48px !important;
        border-radius: 12px !important;
        height: auto !important;
        min-height: auto !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center !important;
        flex-shrink: 0 !important; /* 强力防挤压：确保在 flex 容器中不被缩减高度 */
    }

    .home-hero::before {
        background-position: center !important;
        background-size: 95% !important;
        opacity: 0.07 !important;
    }

    .home-layout-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
        flex-shrink: 0 !important; /* 强力防挤压：确保在 flex 容器中不被缩减高度 */
    }

    .hero-crest {
        width: 48px;
        height: 48px;
        font-size: 1.6rem;
        margin-bottom: 12px;
    }

    .hero-title {
        font-size: 1.85rem;
        letter-spacing: 0.08em;
    }

    .hero-subtitle {
        font-size: 0.9rem;
        margin-bottom: 10px;
    }

    .hero-description {
        font-size: 0.82rem;
        margin-bottom: 18px;
        line-height: 1.55;
    }

    .hero-btn {
        padding: 10px 20px;
        font-size: 0.82rem;
    }

    .home-card {
        padding: 18px 16px !important;
        gap: 16px !important;
    }

    .scroll-content {
        font-size: 0.88rem !important; /* 移动端字号优化，防拥挤 */
        line-height: 1.75 !important;
    }

    .committee-table th, .committee-table td {
        padding: 10px 8px !important;
        font-size: 0.78rem !important;
    }

    .gen-chain-container {
        gap: 28px 12px !important; /* 增大垂直间隙，确保绝对定位的“xx世”数字不与下排胶囊边框物理遮挡 */
        justify-content: center !important;
    }

    .gen-chain-group {
        margin-bottom: 8px !important;
        padding: 5px 8px !important;
        gap: 4px !important;
    }

    .gen-chain-badge {
        width: 38px !important;
        height: 38px !important;
        font-size: 0.95rem !important;
    }

    .gen-chain-badge .gen-num {
        bottom: -20px !important;
        font-size: 0.62rem !important;
    }

    .preface-paper-container {
        padding: 24px 16px !important;
        overflow-x: hidden !important; /* 剔除无意义的横向多余滚动 */
        writing-mode: horizontal-tb !important; /* Reset vertical writing mode on mobile */
    }

    .preface-traditional-layout {
        width: auto !important; /* Reset desktop max-content constraint */
    }

    .preface-vertical-text {
        height: auto !important;
        width: auto !important; /* Reset desktop max-content constraint */
        writing-mode: horizontal-tb !important;
        line-height: 1.8 !important;
        font-size: 0.94rem !important;
    }

    .preface-vertical-text p {
        display: block !important; /* Reset inline-block on mobile */
        margin-left: 0 !important; /* Reset desktop vertical spacer margin */
        margin-bottom: 16px !important;
        text-align: justify !important;
        color: var(--parchment-text-primary) !important;
        height: auto !important; /* Reset vertical height constraint */
    }

    .preface-vertical-text h3 {
        display: block !important; /* Reset inline-block on mobile */
        margin-left: 0 !important;
        margin-right: 0 !important; /* Reset desktop vertical spacer margin */
        margin-bottom: 20px !important;
        text-align: center !important;
    }

    .preface-vertical-text p.signature {
        display: block !important; /* Reset inline-block on mobile */
        margin-left: 0 !important; /* Reset desktop vertical spacer margin */
        margin-right: 0 !important;
        margin-top: 20px !important;
        text-align: right !important;
        height: auto !important; /* Reset vertical height constraint */
    }

    .calc-row {
        flex-direction: column;
        gap: 16px;
    }

    .calc-swap-btn {
        margin-top: 0;
        transform: rotate(90deg);
    }

    /* Lineage Card Modal Mobile Overrides */
    .lineage-card-container {
        flex-direction: column !important;
        height: 92vh !important;
        width: 95% !important;
    }

    .lineage-card-sidebar {
        width: 100% !important;
        flex: 1 !important;
        height: auto !important;
        overflow-y: auto !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color) !important;
        padding: 15px 20px !important;
        order: 2;
        scrollbar-width: thin;
        scrollbar-color: rgba(212, 175, 55, 0.2) transparent;
        will-change: transform;
        transform: translate3d(0, 0, 0);
        -webkit-transform: translate3d(0, 0, 0);
    }

    .lineage-card-sidebar::-webkit-scrollbar {
        width: 4px !important;
    }

    .lineage-card-sidebar::-webkit-scrollbar-thumb {
        background: rgba(212, 175, 55, 0.2) !important;
        border-radius: 2px !important;
    }

    .lineage-card-preview-area {
        flex-grow: 0 !important;
        flex-shrink: 0 !important;
        height: 38vh !important;
        padding: 10px !important;
        order: 1;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #0f0f11 !important;
        border-bottom: 1px solid var(--border-color) !important;
    }

    .modal-sidebar-desc {
        display: none !important;
    }

    /* Compact theme grid on mobile: 2 columns */
    .theme-buttons-group {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .theme-buttons-group .theme-btn {
        width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        padding: 8px 10px !important;
        font-size: 0.78rem !important;
        justify-content: flex-start !important;
        align-items: center !important;
        text-align: left !important;
        border-radius: 6px !important;
    }

    /* Compact copywriter grid on mobile: 3 columns with vertical stacking */
    .theme-buttons {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
        width: 100% !important;
    }

    .theme-buttons .theme-btn {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        padding: 8px 4px !important;
        font-size: 0.72rem !important;
        gap: 4px !important;
        border-radius: 6px !important;
        width: 100% !important;
    }

    .theme-buttons .theme-btn i {
        font-size: 1rem !important;
        margin: 0 !important;
    }

    /* Balanced action buttons grid: 2 columns, last child spans both */
    .action-buttons-group {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        margin-top: 15px !important;
        margin-bottom: 12px !important;
        width: 100% !important;
    }

    .modal-action-btn {
        width: 100% !important;
        padding: 10px !important;
        font-size: 0.78rem !important;
        border-radius: 6px !important;
        box-sizing: border-box !important;
    }

    .modal-action-btn:last-child {
        grid-column: span 2 !important;
    }

    .card-tips {
        margin-bottom: 8px !important;
        font-size: 0.7rem !important;
    }

    .modal-close-btn {
        width: 100% !important;
        padding: 10px !important;
        font-size: 0.8rem !important;
        border-radius: 6px !important;
    }
}

/* Lineage Card Modal Styles - Desktop/Global */
.action-btn-share {
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: #000 !important;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    transition: var(--transition-fast);
    box-shadow: 0 4px 15px var(--gold-glow);
}

.action-btn-share:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
    background: linear-gradient(135deg, var(--gold), #ffdf7a);
}

.action-btn-share:active {
    transform: translateY(0);
}

.lineage-card-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lineage-card-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.lineage-card-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 11, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.lineage-card-container {
    position: relative;
    width: 90%;
    max-width: 1000px;
    height: 85vh;
    background: rgba(20, 20, 22, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    z-index: 2;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lineage-card-modal.active .lineage-card-container {
    transform: scale(1);
}

.lineage-card-sidebar {
    width: 360px;
    padding: 30px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: rgba(15, 15, 17, 0.6);
    flex-shrink: 0;
    position: relative;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.2) transparent;
    /* Hardware acceleration / GPU Layer Promotion to eliminate scroll lag */
    will-change: transform;
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

.lineage-card-sidebar::-webkit-scrollbar {
    width: 4px;
}

.lineage-card-sidebar::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.2);
    border-radius: 2px;
}


.modal-sidebar-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.modal-crest-badge {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--gold);
    width: 48px;
    height: 48px;
    line-height: 44px;
    text-align: center;
    border: 2px solid var(--gold);
    border-radius: 50%;
    background: rgba(212, 175, 55, 0.05);
    box-shadow: 0 0 15px var(--gold-glow);
}

.modal-sidebar-title-group {
    display: flex;
    flex-direction: column;
}

.modal-sidebar-title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    color: var(--text-primary);
}

.modal-sidebar-subtitle {
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.modal-sidebar-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.theme-selector-group {
    margin-bottom: 25px;
}

.control-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 500;
}

.theme-category-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 3px;
    gap: 2px;
    margin-bottom: 15px;
}

.category-tab {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 8px 0;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 17px;
    cursor: pointer;
    text-align: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-ui);
}

.category-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.category-tab.active {
    background: linear-gradient(135deg, var(--gold-dark, #b8860b), var(--gold, #d4af37));
    color: #000 !important;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.theme-buttons-container {
    position: relative;
    width: 100%;
}

.theme-buttons-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    animation: fadeInTab 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-buttons-group.hidden {
    display: none !important;
}

@keyframes fadeInTab {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.theme-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.theme-btn {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition-fast);
}

.theme-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.theme-btn.active {
    background: rgba(212, 175, 55, 0.1);
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.15);
}

.action-buttons-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    margin-top: auto;
}

.modal-action-btn {
    padding: 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-ui);
    transition: var(--transition-fast);
}

.modal-action-btn.primary {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: #000 !important;
    border: none;
    box-shadow: 0 4px 15px var(--gold-glow);
}

.modal-action-btn.primary:hover {
    background: linear-gradient(135deg, var(--gold), #ffdf7a);
    transform: translateY(-1px);
}

.modal-action-btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.modal-action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--text-secondary);
}

.card-tips {
    display: flex;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 20px;
}

.card-tips i {
    font-size: 0.9rem;
    flex-shrink: 0;
}

.modal-close-btn {
    padding: 10px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font-ui);
    transition: var(--transition-fast);
}

.modal-close-btn:hover {
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
}

.lineage-card-preview-area {
    flex-grow: 1;
    background: #0f0f11;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    overflow: hidden;
}

.poster-scroll-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.poster-scroll-wrapper svg {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    background: #000;
}

/* ========================================== */
/* ADMIN BACKEND DASHBOARD STYLING           */
/* ========================================== */

.admin-scrollable {
    flex: 1;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 30px 45px 50px;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.2) transparent;
}

.admin-scrollable::-webkit-scrollbar {
    width: 6px;
}
.admin-scrollable::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.2);
    border-radius: 3px;
}

.admin-dashboard-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
}



/* Directory Panel */
.admin-directory-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

.directory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.directory-header h3 {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.directory-header h3 i {
    color: var(--gold);
}

/* Button UI */
.admin-btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: var(--font-ui);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    outline: none;
}

.admin-btn.primary-btn {
    background: var(--gold);
    color: #000;
}

.admin-btn.primary-btn:hover {
    background: #e5be3b;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

.admin-btn.secondary-btn {
    background: rgba(255,255,255,0.03);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.admin-btn.secondary-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(212, 175, 55, 0.05);
}

.admin-btn.danger-btn {
    background: rgba(200, 35, 35, 0.1);
    color: var(--crimson-hover);
    border: 1px solid rgba(200, 35, 35, 0.2);
}

.admin-btn.danger-btn:hover {
    background: var(--crimson);
    color: #fff;
    border-color: var(--crimson);
}

/* Search Filters Row */
.directory-search-filters {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.directory-search-filters input {
    flex: 1;
    min-width: 250px;
    padding: 11px 16px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.directory-search-filters input:focus {
    border-color: var(--gold);
    outline: none;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.1);
}

.directory-search-filters select {
    width: 180px;
    padding: 11px 16px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.directory-search-filters select:focus {
    border-color: var(--gold);
    outline: none;
}

/* Directory Table */
.directory-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0,0,0,0.15);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.admin-table th:first-child,
.admin-table td:first-child {
    display: none !important;
}

.admin-table th {
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.admin-table td {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.9rem;
    color: var(--text-primary);
    vertical-align: middle;
}

.admin-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.015);
}

.admin-table tr:last-child td {
    border-bottom: none;
}

/* Mini row actions */
.admin-table .row-actions {
    display: flex;
    gap: 8px;
}

.admin-table .row-actions button {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Pagination */
.admin-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 24px;
    padding-top: 10px;
}

.admin-pagination #admin-page-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-width: 100px;
    text-align: center;
}

.admin-pagination .pager-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: rgba(255,255,255,0.02);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.admin-pagination .pager-btn:hover:not(:disabled) {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(212, 175, 55, 0.05);
}

.admin-pagination .pager-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

/* Form Search Autocomplete Dropdowns within Form Fields */
.form-search-wrapper {
    position: relative;
    width: 100%;
}

.form-dropdown {
    position: absolute;
    top: 105%;
    left: 0;
    right: 0;
    max-height: 200px !important;
    background: #141416 !important;
    border: 1px solid var(--gold) !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.6) !important;
    z-index: 1050 !important;
}

/* Member Editor Overlay / Modal */
.editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: opacity 0.35s ease;
}

.editor-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

.editor-modal {
    background: var(--bg-card);
    border: 1.5px solid var(--gold);
    border-radius: 14px;
    width: 720px;
    max-width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(212, 175, 55, 0.15);
    animation: modalScaleIn 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@keyframes modalScaleIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.editor-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border-color);
}

.editor-modal-header h3 {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    color: var(--gold);
    letter-spacing: 1px;
}

.editor-modal-header .close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    transition: var(--transition-fast);
    padding: 4px;
}

.editor-modal-header .close-btn:hover {
    color: var(--crimson-hover);
}

.editor-modal form {
    padding: 28px;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.editor-modal form::-webkit-scrollbar {
    width: 6px;
}
.editor-modal form::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.col-span-2 {
    grid-column: span 2;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group label .required {
    color: var(--crimson-hover);
    margin-right: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 11px 14px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    transition: var(--transition-fast);
    width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--gold);
    outline: none;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.15);
}

/* Sub-grid for conditional adoption elements */
.form-subgrid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    background: rgba(212, 175, 55, 0.03);
    border: 1px dashed rgba(212, 175, 55, 0.2);
    padding: 20px;
    border-radius: 8px;
    margin-top: 8px;
}

.form-subgrid.hidden {
    display: none !important;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* ============================================================================
   数字化后台管理登录/验证系统 (Management Auth / Login UI)
   ============================================================================ */
.admin-login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    max-width: 480px;
    margin: 60px auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3), 0 0 30px rgba(212, 175, 55, 0.05);
    text-align: center;
    backdrop-filter: blur(10px);
    transition: var(--transition-smooth);
}

.login-header {
    margin-bottom: 30px;
}

.login-lock-icon {
    font-size: 3rem;
    color: var(--gold);
    width: 80px;
    height: 80px;
    line-height: 74px;
    border: 2px solid var(--gold);
    border-radius: 50%;
    margin: 0 auto 20px;
    background: rgba(212, 175, 55, 0.05);
    box-shadow: 0 0 20px var(--gold-glow);
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-header h3 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.login-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.login-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper .input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 1rem;
}

.password-input-wrapper input {
    padding: 14px 45px 14px 40px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    transition: var(--transition-fast);
    width: 100%;
}

.password-input-wrapper input:focus {
    border-color: var(--gold);
    outline: none;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.15);
}

.password-toggle-btn {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    transition: var(--transition-fast);
}

.password-toggle-btn:hover {
    color: var(--text-primary);
}

.login-message {
    font-size: 0.85rem;
    padding: 10px 14px;
    border-radius: 6px;
    text-align: left;
}

.login-message.error {
    background: rgba(200, 35, 35, 0.1);
    border: 1px solid rgba(200, 35, 35, 0.3);
    color: var(--crimson-hover);
}

.login-message.success {
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.3);
    color: var(--success);
}

.login-btn {
    padding: 14px;
    font-size: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: 100%;
    cursor: pointer;
}

/* Logout Button styling inside admin page */
.admin-logout-btn-container {
    display: flex;
    align-items: center;
}

.admin-logout-btn {
    background: transparent;
    border: 1px solid rgba(200, 35, 35, 0.4);
    color: var(--crimson-hover);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

.admin-logout-btn:hover {
    background: rgba(200, 35, 35, 0.1);
    border-color: var(--crimson);
}

/* Gender Badge styles for Admin Member Table */
.gender-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}
.gender-badge.male {
    background: rgba(212, 175, 55, 0.12);
    color: var(--gold);
    border: 1px solid rgba(212, 175, 55, 0.25);
}
.gender-badge.female {
    background: rgba(244, 114, 182, 0.12);
    color: var(--rose-gold);
    border: 1px solid rgba(244, 114, 182, 0.25);
}

/* Spouse details card styling */
.spouse-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px dashed var(--gold);
    border-radius: 8px;
    padding: 14px;
}

.spouse-content {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.profile-card.female .spouse-card {
    border-color: var(--rose-gold);
}

.profile-card.female .profile-sec-title {
    border-left-color: var(--rose-gold);
}

/* ============================================================================
   Master-Class Admin Panel Tools & Theme Configurations
   ============================================================================ */
#global-theme-toggle {
    display: none !important;
}

.admin-top-grid {
    display: grid;
    grid-template-columns: 4fr 5fr;
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 1200px) {
    .admin-top-grid {
        grid-template-columns: 1fr;
    }
}

.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: space-between;
}

.admin-card .card-section-title {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--gold);
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
    padding-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.traditional-book-theme .admin-card .card-section-title {
    color: var(--crimson) !important;
    border-bottom-color: rgba(200, 35, 35, 0.15) !important;
}

.stats-tools-card .stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

@media (max-width: 480px) {
    .stats-tools-card .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stats-tools-card .stat-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.traditional-book-theme .stats-tools-card .stat-item {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.04);
}

.stats-tools-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.traditional-book-theme .stats-tools-card .stat-label {
    color: rgba(0, 0, 0, 0.6);
}

.stats-tools-card .stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--gold);
    font-family: var(--font-serif);
}

.traditional-book-theme .stats-tools-card .stat-value {
    color: var(--crimson) !important;
}

.stats-tools-card .tools-actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.admin-btn.compact {
    padding: 6px 12px;
    font-size: 0.8rem;
    height: auto;
    min-height: 32px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.settings-card .settings-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

@media (max-width: 768px) {
    .settings-card .settings-columns {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.setting-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-col:not(:last-child) {
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    padding-right: 16px;
}

.traditional-book-theme .setting-col:not(:last-child) {
    border-right-color: rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
    .setting-col:not(:last-child) {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        padding-right: 0;
        padding-bottom: 12px;
    }
    .traditional-book-theme .setting-col:not(:last-child) {
        border-bottom-color: rgba(0, 0, 0, 0.05);
    }
}

.setting-col .setting-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.9;
}

.traditional-book-theme .setting-col .setting-title {
    color: var(--parchment-text-primary);
}

.setting-col .theme-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.theme-select-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition-fast);
    width: 100%;
}

.theme-select-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.traditional-book-theme .theme-select-btn {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.06);
    color: var(--parchment-text-primary);
}

.traditional-book-theme .theme-select-btn:hover {
    background: rgba(200, 35, 35, 0.04) !important;
    border-color: rgba(200, 35, 35, 0.15) !important;
    color: var(--crimson-hover, #c82323);
}

.theme-select-btn.active[data-theme="dark-gold"] {
    color: var(--gold) !important;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15) 0%, rgba(179, 133, 21, 0.04) 100%) !important;
    border-color: rgba(212, 175, 55, 0.55) !important;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.12);
}

.traditional-book-theme .theme-select-btn.active[data-theme="light-parchment"] {
    color: var(--crimson) !important;
    background: linear-gradient(135deg, rgba(200, 35, 35, 0.08) 0%, rgba(144, 12, 12, 0.03) 100%) !important;
    border-color: rgba(200, 35, 35, 0.6) !important;
    box-shadow: 0 4px 12px rgba(200, 35, 35, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
}

.setting-col .checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.compact-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-family: var(--font-ui);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    transition: var(--transition-fast);
}

.compact-toggle-label:hover {
    color: var(--text-primary);
}

.traditional-book-theme .compact-toggle-label {
    color: var(--parchment-text-primary);
}

.compact-toggle-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--gold);
}

.traditional-book-theme .compact-toggle-label input[type="checkbox"] {
    accent-color: var(--crimson);
}

.editor-evidence-section {
    margin-top: 8px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

.editor-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gold);
    font-weight: 700;
}

.editor-evidence-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
}

.source-field-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    min-height: 42px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.source-field-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.source-field-option input[type="checkbox"] {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--gold);
}

@media (max-width: 640px) {
    .editor-evidence-grid {
        grid-template-columns: 1fr;
    }

    .editor-evidence-grid .col-span-2 {
        grid-column: span 1;
    }
}


/* --- Admin Timeline Section Styles --- */
.admin-timeline-section {
    margin-top: 15px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.admin-timeline-list {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 8px;
    margin-top: 10px;
}

.admin-timeline-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 12px;
    transition: var(--transition-fast);
}

.traditional-book-theme .admin-timeline-item {
    background: rgba(0, 0, 0, 0.02);
}

.admin-timeline-item:hover {
    border-color: var(--gold);
}

.traditional-book-theme .admin-timeline-item:hover {
    border-color: var(--crimson);
}

.admin-timeline-fields {
    flex: 1;
    display: grid;
    grid-template-columns: 120px 1fr 1fr;
    gap: 8px;
}

.admin-timeline-fields input,
.admin-timeline-fields textarea {
    width: 100%;
}

.admin-btn-delete-event {
    background: transparent;
    border: none;
    color: var(--crimson-hover, #c82323);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 6px;
    border-radius: 4px;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
}

.admin-btn-delete-event:hover {
    background: rgba(200, 35, 35, 0.1);
    color: #ff4d4d;
}

/* ==========================================================================
   宗族人口与代际数据大屏分析 (Demographics Dashboard)
   ========================================================================== */

#page-dashboard {
    display: none;
    width: 100%;
    height: 100%;
    overflow: hidden;
}
#page-dashboard.active {
    display: block;
}
.dashboard-scrollable {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 24px;
    box-sizing: border-box;
}
.dashboard-hero-card {
    position: relative;
    width: 100%;
    height: 140px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(20, 20, 24, 0.95), rgba(40, 40, 48, 0.9));
    border: 1px solid rgba(212, 175, 55, 0.2);
    overflow: hidden;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    padding: 0 40px;
    box-sizing: border-box;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: var(--transition-elastic);
}
.traditional-book-theme .dashboard-hero-card {
    background: radial-gradient(circle, rgba(253, 251, 247, 0.98) 0%, rgba(244, 238, 225, 0.95) 100%);
    border: 1px solid rgba(139, 0, 0, 0.2);
    box-shadow: 0 6px 20px rgba(139, 0, 0, 0.05);
}
.dashboard-hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: radial-gradient(rgba(212, 175, 55, 0.05) 1px, transparent 1px);
    background-size: 16px 16px;
    pointer-events: none;
}
.traditional-book-theme .dashboard-hero-overlay {
    background-image: radial-gradient(rgba(139, 0, 0, 0.04) 1px, transparent 1px);
}
.dashboard-hero-content {
    position: relative;
    z-index: 2;
}
.dashboard-hero-content h3 {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--gold);
    margin: 0 0 6px 0;
    letter-spacing: 2px;
    text-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
}
.traditional-book-theme .dashboard-hero-content h3 {
    color: var(--crimson);
    text-shadow: none;
}
.dashboard-hero-content p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 0;
}
.dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.dashboard-kpi-card {
    display: flex;
    align-items: center;
    padding: 20px;
    background: rgba(20, 20, 24, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: var(--transition-elastic);
}
.traditional-book-theme .dashboard-kpi-card {
    background: rgba(252, 250, 242, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}
.dashboard-kpi-card:hover {
    transform: translateY(-4px);
    border-color: rgba(212, 175, 55, 0.4);
    box-shadow: 0 8px 30px rgba(212, 175, 55, 0.15);
}
.traditional-book-theme .dashboard-kpi-card:hover {
    border-color: rgba(139, 0, 0, 0.3);
    box-shadow: 0 8px 25px rgba(139, 0, 0, 0.08);
}
.dashboard-kpi-card .kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: rgba(212, 175, 55, 0.1);
    color: var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-right: 16px;
    flex-shrink: 0;
}
.traditional-book-theme .dashboard-kpi-card .kpi-icon {
    background: rgba(139, 0, 0, 0.05);
    color: var(--crimson);
}
.dashboard-kpi-card .kpi-info {
    display: flex;
    flex-direction: column;
}
.dashboard-kpi-card .kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.dashboard-kpi-card .kpi-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}
.dashboard-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}
.dashboard-chart-box {
    background: rgba(20, 20, 24, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
    transition: var(--transition-elastic);
    display: flex;
    flex-direction: column;
    min-height: 380px;
}
.traditional-book-theme .dashboard-chart-box {
    background: rgba(252, 250, 242, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.03);
}
.dashboard-chart-box:hover {
    border-color: rgba(212, 175, 55, 0.25);
    box-shadow: 0 8px 32px rgba(212, 175, 55, 0.1);
}
.traditional-book-theme .dashboard-chart-box:hover {
    border-color: rgba(139, 0, 0, 0.15);
    box-shadow: 0 8px 24px rgba(139, 0, 0, 0.05);
}
.dashboard-chart-box.full-width {
    grid-column: span 2;
}
.dashboard-chart-box h4 {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 3px solid var(--gold);
    padding-left: 10px;
}
.traditional-book-theme .dashboard-chart-box h4 {
    border-left-color: var(--crimson);
}
.dashboard-chart-box .chart-container {
    flex: 1;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dashboard-tooltip {
    position: absolute;
    padding: 8px 12px;
    background: rgba(10, 10, 12, 0.9);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: #fff;
    border-radius: 6px;
    font-size: 0.8rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}
.traditional-book-theme .dashboard-tooltip {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(139, 0, 0, 0.3);
    color: #333;
    box-shadow: 0 4px 12px rgba(139, 0, 0, 0.15);
}
.longevity-honor-roll-container {
    width: 100%;
    overflow-x: auto;
    padding: 8px 0;
}
.longevity-honor-roll-list {
    display: flex;
    gap: 20px;
    padding: 10px 4px;
    list-style: none;
    margin: 0;
    scroll-snap-type: x mandatory;
}
.longevity-honor-item {
    flex: 0 0 240px;
    background: linear-gradient(135deg, rgba(30, 28, 22, 0.8), rgba(15, 14, 11, 0.9));
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    scroll-snap-align: start;
    transition: var(--transition-elastic);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.traditional-book-theme .longevity-honor-item {
    background: radial-gradient(circle, rgba(254, 253, 249, 1) 0%, rgba(247, 241, 228, 0.9) 100%);
    border: 1px dashed rgba(139, 0, 0, 0.3);
    box-shadow: 0 4px 12px rgba(139, 0, 0, 0.03);
}
.longevity-honor-item:hover {
    transform: scale(1.03) translateY(-4px);
    border-color: var(--gold);
    box-shadow: 0 8px 24px rgba(212, 175, 55, 0.2);
}
.traditional-book-theme .longevity-honor-item:hover {
    border-color: var(--crimson);
    box-shadow: 0 8px 20px rgba(139, 0, 0, 0.08);
}
.honor-rank-stamp {
    font-family: 'Noto Serif SC', serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gold);
    border: 1px solid var(--gold);
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 12px;
    text-shadow: 0 0 5px rgba(212, 175, 55, 0.3);
}
.traditional-book-theme .honor-rank-stamp {
    color: var(--crimson);
    border: 2px solid var(--crimson);
    border-radius: 2px;
    padding: 2px 8px;
    font-weight: 900;
    background: rgba(139, 0, 0, 0.02);
    transform: rotate(-3deg);
    text-shadow: none;
    box-shadow: inset 0 0 2px rgba(139, 0, 0, 0.1);
}
.honor-name {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.honor-gen {
    font-size: 0.85rem;
    color: var(--gold);
    margin-bottom: 6px;
}
.traditional-book-theme .honor-gen {
    color: var(--crimson);
}
.honor-years {
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.honor-burial {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
    padding: 4px 10px;
    border-radius: 20px;
    width: 100%;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.traditional-book-theme .honor-burial {
    background: rgba(0, 0, 0, 0.02);
}

@media (max-width: 1024px) {
    .dashboard-kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .dashboard-charts-grid {
        grid-template-columns: 1fr;
    }
    .dashboard-chart-box.full-width {
        grid-column: span 1;
    }
}
@media (max-width: 768px) {
    .dashboard-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-scrollable {
        padding: 16px;
    }
    .dashboard-hero-card {
        padding: 0 20px;
        height: 120px;
    }
    .dashboard-hero-content h3 {
        font-size: 1.4rem;
    }
    .header-nav {
        padding: 0 4px !important;
    }
    .header-nav .nav-btn {
        font-size: 0.65rem !important;
        padding: 4px 2px !important;
        gap: 2px !important;
    }
    .header-nav .nav-btn i {
        font-size: 1.1rem !important;
    }
    .header-nav #global-theme-toggle {
        display: none !important;
    }
    .header-nav button[data-tab="dashboard"] {
        display: none !important;
    }
    .header-nav button[data-tab="admin"] {
        display: none !important;
    }
}
@media (max-width: 480px) {
    .dashboard-kpi-grid {
        grid-template-columns: 1fr;
    }
}

.nav-btn.dashboard-disabled {
    display: none !important;
}

/* ==========================================================================
   11. Traditional Pedigree Export Page Styles (传统谱书排版与物理打印)
   ========================================================================== */

#page-pedigree {
    background: var(--bg-darker);
    min-height: 100%;
}

.pedigree-scrollable {
    padding: 30px;
    height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
}

/* Control Panel */
.pedigree-controls-card {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 20px 24px;
    background: rgba(20, 20, 24, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    transition: var(--transition-elastic);
}

body.traditional-book-theme .pedigree-controls-card {
    background: var(--parchment-card-bg) !important;
    border: 1px solid rgba(139, 0, 0, 0.15) !important;
    box-shadow: var(--shadow-sm);
}

.pedigree-controls-card .control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pedigree-controls-card .control-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

body.traditional-book-theme .pedigree-controls-card .control-group label {
    color: var(--parchment-text-secondary);
}

.pedigree-controls-card .control-group select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 6px;
    outline: none;
    font-family: var(--font-ui);
    cursor: pointer;
    min-width: 180px;
    transition: all 0.3s ease;
}

body.traditional-book-theme .pedigree-controls-card .control-group select {
    background: #fbf9f4 !important;
    border: 1px solid #d4cbb5 !important;
    color: var(--parchment-text-primary) !important;
}

.pedigree-controls-card .control-group select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

body.traditional-book-theme .pedigree-controls-card .control-group select:focus {
    border-color: var(--crimson) !important;
    box-shadow: 0 0 10px rgba(200, 35, 35, 0.1) !important;
}

.pedigree-controls-card .action-group {
    margin-left: auto;
}

.pedigree-action-btn {
    background: linear-gradient(135deg, var(--gold) 0%, #b38515 100%);
    border: none;
    color: #111;
    font-weight: bold;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-ui);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
    transition: var(--transition-elastic);
}

.pedigree-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

body.traditional-book-theme .pedigree-action-btn {
    background: linear-gradient(135deg, var(--crimson) 0%, #900c0c 100%) !important;
    color: #fff !important;
    box-shadow: 0 4px 15px rgba(200, 35, 35, 0.25) !important;
}

body.traditional-book-theme .pedigree-action-btn:hover {
    box-shadow: 0 6px 20px rgba(200, 35, 35, 0.35) !important;
}

/* Book Viewport */
.pedigree-book-viewport {
    width: 100%;
    overflow-x: auto;
    padding: 20px 0;
    box-sizing: border-box;
}

.pedigree-preview-container {
    display: flex;
    gap: 40px;
    width: max-content;
    padding: 10px;
    box-sizing: border-box;
}

/* Traditional Chinese Book Page Mockup */
.pedigree-page {
    position: relative;
    width: 794px; /* A4 Ratio Width */
    height: 1123px; /* A4 Ratio Height */
    background: rgba(20, 20, 24, 0.6);
    border: 2px solid rgba(212, 175, 55, 0.3);
    border-radius: 4px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition-elastic);
    flex-shrink: 0;
}

/* Adjust page size dynamically based on orientation mode */
.pedigree-landscape .pedigree-page {
    width: 1123px !important;
    height: 794px !important;
}
.pedigree-portrait .pedigree-page {
    width: 794px !important;
    height: 1123px !important;
}

body.traditional-book-theme .pedigree-page,
body.pedigree-print-color .pedigree-page{
    background: var(--parchment-bg) !important;
    background-image: var(--parchment-pattern) !important;
    border: 2px solid #8b0000 !important;
    box-shadow: 0 10px 30px rgba(139, 0, 0, 0.08) !important;
}

/* Pedigree Cover Page Styling */
.cover-content-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    position: relative;
    padding: 40px;
    box-sizing: border-box;
}

.cover-main-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 3px double var(--crimson);
    width: 84%;
    height: 90%;
    padding: 30px;
    box-sizing: border-box;
    position: relative;
    background: rgba(212, 175, 55, 0.015);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

body.dark-gold .cover-main-wrapper {
    border-color: var(--gold);
    background: rgba(212, 175, 55, 0.005);
}

.cover-main-wrapper::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    border: 1px solid rgba(139, 0, 0, 0.25);
    pointer-events: none;
}
body.dark-gold .cover-main-wrapper::before {
    border-color: rgba(212, 175, 55, 0.25);
}

.cover-main-wrapper::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    bottom: 6px;
    border: 1px solid rgba(139, 0, 0, 0.12);
    pointer-events: none;
}
body.dark-gold .cover-main-wrapper::after {
    border-color: rgba(212, 175, 55, 0.12);
}

/* Seamless auspicious background cloud watermark */
.cover-bg-clouds {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cpath d='M20 50c0-8.3 6.7-15 15-15 1.5 0 3 .2 4.4.7C42 31.7 47.7 28 54 28c8.8 0 16 7.2 16 16 0 1.2-.1 2.3-.4 3.4C71.8 45.8 74.3 45 77 45c7.2 0 13 5.8 13 13s-5.8 13-13 13H20c-11 0-20-9-20-20s9-20 20-20z' fill='%238b0000' fill-opacity='0.025'%3E%3C/path%3E%3C/svg%3E");
    opacity: 0.95;
    pointer-events: none;
}

body.dark-gold .cover-bg-clouds {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cpath d='M20 50c0-8.3 6.7-15 15-15 1.5 0 3 .2 4.4.7C42 31.7 47.7 28 54 28c8.8 0 16 7.2 16 16 0 1.2-.1 2.3-.4 3.4C71.8 45.8 74.3 45 77 45c7.2 0 13 5.8 13 13s-5.8 13-13 13H20c-11 0-20-9-20-20s9-20 20-20z' fill='%23d4af37' fill-opacity='0.035'%3E%3C/path%3E%3C/svg%3E") !important;
}



/* Cover Corner Fret Border Ornaments */
.cover-corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: var(--crimson);
    border-style: solid;
    pointer-events: none;
    z-index: 4;
}
.corner-top-left {
    top: 16px;
    left: 16px;
    border-width: 2px 0 0 2px;
}
.corner-top-left::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 8px;
    height: 8px;
    border: 1px solid var(--crimson);
    border-width: 1px 0 0 1px;
}
.corner-top-right {
    top: 16px;
    right: 16px;
    border-width: 2px 2px 0 0;
}
.corner-top-right::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border: 1px solid var(--crimson);
    border-width: 1px 1px 0 0;
}
.corner-bottom-left {
    bottom: 16px;
    left: 16px;
    border-width: 0 0 2px 2px;
}
.corner-bottom-left::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 4px;
    width: 8px;
    height: 8px;
    border: 1px solid var(--crimson);
    border-width: 0 0 1px 1px;
}
.corner-bottom-right {
    bottom: 16px;
    right: 16px;
    border-width: 0 2px 2px 0;
}
.corner-bottom-right::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border: 1px solid var(--crimson);
    border-width: 0 1px 1px 0;
}

body.dark-gold .cover-corner,
body.dark-gold .cover-corner::after {
    border-color: var(--gold) !important;
}
body.pedigree-print-bw .cover-corner,
body.pedigree-print-bw .cover-corner::after {
    border-color: #000 !important;
}

/* Ornate Side Couplets */
.cover-couplet {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-family: var(--font-calligraphy);
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--parchment-text-secondary);
    letter-spacing: 0.35em;
    opacity: 0.65;
    z-index: 4;
}
.couplet-left {
    left: 45px;
}
.couplet-right {
    right: 45px;
}
body.traditional-book-theme .cover-couplet,
body.pedigree-print-color .cover-couplet {
    color: #5c4033 !important; /* Authentic sepia ink text */
}
body.pedigree-print-bw .cover-couplet {
    color: #000 !important;
}

/* Silk bookmark vertical title container */
.cover-title-bookmark {
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-family: var(--font-calligraphy);
    border: 3px double var(--crimson);
    background: #faf7ed;
    padding: 18px 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.14), inset 0 0 15px rgba(139, 0, 0, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 3px;
    z-index: 5;
}

body.dark-gold .cover-title-bookmark {
    border: 3px double var(--gold);
    background: #1f1b17;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}
body.pedigree-print-bw .cover-title-bookmark {
    border-color: #000 !important;
    background: #fff !important;
    box-shadow: none !important;
}

.bookmark-inner-border {
    border: 1px solid rgba(139, 0, 0, 0.22);
    padding: 10px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}
body.dark-gold .bookmark-inner-border {
    border-color: rgba(212, 175, 55, 0.22);
}
body.pedigree-print-bw .bookmark-inner-border {
    border-color: #000 !important;
}

.cover-title-text {
    font-size: 2.3rem;
    font-weight: 900;
    color: var(--crimson);
    letter-spacing: 0.2em;
    margin: 0;
    line-height: 1.2;
    text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.9);
    white-space: nowrap;
}
body.dark-gold .cover-title-text {
    color: var(--gold) !important;
    text-shadow: none;
}
body.pedigree-print-bw .cover-title-text {
    color: #000 !important;
    text-shadow: none;
}

/* Ornate Traditional Bottom Wave Motif */
.cover-bottom-waves {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: 50%;
    height: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='30' viewBox='0 0 100 30'%3E%3Cpath d='M0 30c5-5 10-10 20-10s15 5 20 10 10-10 20-10 15 5 20 10v0H0z' fill='%238b0000' fill-opacity='0.035'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: repeat-x;
    background-size: contain;
    opacity: 0.8;
    pointer-events: none;
    z-index: 3;
}
body.dark-gold .cover-bottom-waves {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='30' viewBox='0 0 100 30'%3E%3Cpath d='M0 30c5-5 10-10 20-10s15 5 20 10 10-10 20-10 15 5 20 10v0H0z' fill='%23d4af37' fill-opacity='0.06'%3E%3C/path%3E%3C/svg%3E") !important;
}

.cover-meta-info {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    font-family: var(--font-serif);
    font-size: 0.9rem;
    color: var(--parchment-text-secondary);
    letter-spacing: 0.1em;
    z-index: 4;
}

body.pedigree-print-bw .cover-meta-info {
    color: #000 !important;
}

.cover-seal {
    display: none !important; /* Obsolete style, hidden */
}

/* Vertical Parentheses and Annotations in Su-style */
.name-annotation-wrapper {
    font-size: 0.82em;
    color: var(--crimson);
    font-weight: normal;
    text-orientation: mixed !important;
}

body.pedigree-print-bw .name-annotation-wrapper {
    color: #000 !important;
}

.name-parenthesis {
    text-orientation: mixed !important;
    font-family: inherit;
}

/* Divider / Insert Page Styling */
.divider-content-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    position: relative;
    padding: 60px;
    box-sizing: border-box;
}

.divider-main-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 3px double var(--crimson);
    width: 80%;
    height: 85%;
    padding: 40px;
    box-sizing: border-box;
    position: relative;
    background: rgba(212, 175, 55, 0.01);
}

.divider-main-wrapper::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border: 1px solid rgba(139, 0, 0, 0.15);
    pointer-events: none;
}

body.pedigree-print-bw .divider-main-wrapper {
    border-color: #000 !important;
    background: #fff !important;
}

body.pedigree-print-bw .divider-main-wrapper::before {
    border-color: #000 !important;
}

.divider-title-box {
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-family: var(--font-serif);
    border: 2px solid var(--crimson);
    padding: 25px 15px;
    background: #fff;
    box-shadow: 0 4px 15px rgba(139, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
}

body.traditional-book-theme .divider-title-box,
body.pedigree-print-color .divider-title-box {
    background: #faf7ed;
}

body.pedigree-print-bw .divider-title-box {
    border-color: #000 !important;
    background: #fff !important;
}

.divider-title-text {
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--crimson);
    letter-spacing: 0.15em;
    line-height: 1.3;
}

body.pedigree-print-bw .divider-title-text {
    color: #000 !important;
}

.divider-desc-box {
    width: 85%;
    margin-top: 10px;
    text-align: justify;
    line-height: 2;
    font-family: var(--font-serif);
    color: var(--parchment-text-primary);
    font-size: 1.15rem;
    text-indent: 2.3em;
}

body.pedigree-print-bw .divider-desc-text {
    color: #000 !important;
}

.divider-seal {
    display: none !important; /* HIDE completely to ensure elegant, clean print on paper without digital stamps */
    position: absolute;
    top: 25px;
    right: 25px;
    border: 2px solid var(--crimson);
    color: var(--crimson);
    padding: 4px 10px;
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: bold;
    transform: rotate(5deg);
    border-radius: 3px;
    opacity: 0.8;
}

body.pedigree-print-bw .divider-seal {
    border-color: #000 !important;
    color: #000 !important;
}

/* Alternating Margins & Gutters for physical thread binding */
.pedigree-page:nth-child(odd) {
    padding-left: 80px !important;
    padding-right: 40px !important;
}
.pedigree-page:nth-child(odd) .pedigree-page-border {
    left: 50px !important;
    right: 20px !important;
}
.pedigree-page:nth-child(odd) .pedigree-page-middle-crease {
    left: calc(50px + (100% - 70px) / 2) !important;
}

.pedigree-page:nth-child(even) {
    padding-left: 40px !important;
    padding-right: 80px !important;
}
.pedigree-page:nth-child(even) .pedigree-page-border {
    left: 20px !important;
    right: 50px !important;
}
.pedigree-page:nth-child(even) .pedigree-page-middle-crease {
    left: calc(20px + (100% - 70px) / 2) !important;
}

/* Thread Binding Stitch Indicators */
.pedigree-page-stitches {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40px;
    pointer-events: none;
    z-index: 15;
}
.pedigree-page:nth-child(odd) .pedigree-page-stitches {
    left: 0;
}
.pedigree-page:nth-child(even) .pedigree-page-stitches {
    right: 0;
}

/* Punched Stitch Holes */
.stitch-hole {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #2b180d;
    border-radius: 50%;
    box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.85), 0 1px 1px rgba(255, 255, 255, 0.25);
    z-index: 17;
}
.pedigree-page:nth-child(odd) .stitch-hole {
    left: 20px;
}
.pedigree-page:nth-child(even) .stitch-hole {
    right: 20px;
}

.stitch-hole.hole-1 { top: 8%; }
.stitch-hole.hole-2 { top: 29%; }
.stitch-hole.hole-3 { top: 50%; }
.stitch-hole.hole-4 { top: 71%; }
.stitch-hole.hole-5 { top: 92%; }

/* Connecting Thread Line */
.pedigree-page-stitches .stitch-line {
    position: absolute;
    top: 8%;
    bottom: 8%;
    width: 2.5px;
    background: #8b4513; /* SaddleBrown thread */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 0 1px rgba(139, 69, 19, 0.8);
    z-index: 16;
}
.pedigree-page:nth-child(odd) .stitch-line {
    left: 23px;
}
.pedigree-page:nth-child(even) .stitch-line {
    right: 23px;
}

/* Horizontal Edge Wrap Thread */
.stitch-hole::after {
    content: '';
    position: absolute;
    top: 3px;
    width: 24px;
    height: 2px;
    background: #8b4513;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    z-index: 16;
}
.pedigree-page:nth-child(odd) .stitch-hole::after {
    right: 4px; /* points leftwards to the page edge */
}
.pedigree-page:nth-child(even) .stitch-hole::after {
    left: 4px; /* points rightwards to the page edge */
}

/* Corner Wrap Vertical Threads for Hole 1 and Hole 5 */
.pedigree-page-stitches .stitch-hole.hole-1::before {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 2.5px;
    height: 100px; /* extends all the way to the top */
    background: #8b4513;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    z-index: 16;
}
.pedigree-page:nth-child(odd) .stitch-hole.hole-1::before {
    left: 3px;
}
.pedigree-page:nth-child(even) .stitch-hole.hole-1::before {
    right: 3px;
}

.pedigree-page-stitches .stitch-hole.hole-5::before {
    content: '';
    position: absolute;
    top: 4px;
    width: 2.5px;
    height: 100px; /* extends all the way to the bottom */
    background: #8b4513;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    z-index: 16;
}
.pedigree-page:nth-child(odd) .stitch-hole.hole-5::before {
    left: 3px;
}
.pedigree-page:nth-child(even) .stitch-hole.hole-5::before {
    right: 3px;
}

/* Print borders & grids inside pages */
.pedigree-page-border {
    position: absolute;
    top: 20px;
    bottom: 20px;
    border: 1px solid rgba(212, 175, 55, 0.2);
    pointer-events: none;
}

body.traditional-book-theme .pedigree-page-border,
body.pedigree-print-color .pedigree-page-border{
    border: 1px solid rgba(139, 0, 0, 0.15) !important;
}

/* Middle Folding Line (版心 & 鱼口) */
.pedigree-page-middle-crease {
    position: absolute;
    top: 20px;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    border-left: 1px solid rgba(212, 175, 55, 0.12); /* Changed to traditional solid fine line */
    border-right: 1px solid rgba(212, 175, 55, 0.12); /* Changed to traditional solid fine line */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 30px 0;
    box-sizing: border-box;
    pointer-events: none;
}

body.traditional-book-theme .pedigree-page-middle-crease,
body.pedigree-print-color .pedigree-page-middle-crease{
    border-left: 1px solid rgba(139, 0, 0, 0.12) !important; /* Changed to ultra-fine solid line for authentic book printing */
    border-right: 1px solid rgba(139, 0, 0, 0.12) !important; /* Changed to ultra-fine solid line for authentic book printing */
}

/* Traditional Chinese folding indicator (鱼口) */
.fish-mouth {
    width: 12px;
    height: 12px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(212, 175, 55, 0.4);
    box-sizing: border-box;
}

.fish-mouth.bottom {
    border-top: none;
    border-bottom: 6px solid rgba(212, 175, 55, 0.4);
}

body.traditional-book-theme .fish-mouth,
body.pedigree-print-color .fish-mouth{
    border-top-color: rgba(139, 0, 0, 0.4) !important;
}
body.traditional-book-theme .fish-mouth.bottom,
body.pedigree-print-color .fish-mouth.bottom{
    border-bottom-color: rgba(139, 0, 0, 0.4) !important;
}

.page-center-title {
    writing-mode: vertical-rl;
    font-family: var(--font-calligraphy);
    font-size: 0.75rem;
    color: rgba(212, 175, 55, 0.5);
    letter-spacing: 0.2em;
}

body.traditional-book-theme .page-center-title {
    color: rgba(139, 0, 0, 0.4) !important;
}

body.pedigree-print-color .page-center-title,
body.pedigree-print-bw .page-center-title {
    display: none !important; /* Hide to prevent messy name overlaps during printing/export */
}

/* Page Header & Footer */
.pedigree-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
    padding-bottom: 8px;
    z-index: 2;
}

body.traditional-book-theme .pedigree-page-header,
body.pedigree-print-color .pedigree-page-header{
    border-bottom: 1px solid rgba(139, 0, 0, 0.15) !important;
}

.pedigree-page-header .header-left {
    font-family: var(--font-calligraphy);
    font-size: 0.9rem;
    color: var(--gold);
}

body.traditional-book-theme .pedigree-page-header .header-left,
body.pedigree-print-color .pedigree-page-header .header-left{
    color: var(--crimson) !important;
}

.pedigree-page-header .header-right {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

body.traditional-book-theme .pedigree-page-header .header-right,
body.pedigree-print-color .pedigree-page-header .header-right{
    color: var(--parchment-text-secondary) !important;
}

.pedigree-page-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid rgba(212, 175, 55, 0.15);
    padding-top: 8px;
    z-index: 2;
}

body.traditional-book-theme .pedigree-page-footer,
body.pedigree-print-color .pedigree-page-footer{
    border-top: 1px solid rgba(139, 0, 0, 0.15) !important;
}

.pedigree-page-footer span {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-calligraphy);
}

body.traditional-book-theme .pedigree-page-footer span,
body.pedigree-print-color .pedigree-page-footer span{
    color: var(--parchment-text-secondary) !important;
}

/* Content Frame */
.pedigree-page-content {
    flex: 1;
    margin: 20px 0;
    position: relative;
    z-index: 2;
    overflow: hidden;
}

/* Sushi Layout: Su-style vertical suspended pedigree chart */
.sushi-format .pedigree-page-content {
    position: relative;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

/* Generation horizontal rows background grid */
.sushi-gen-row {
    position: absolute;
    left: 0;
    right: 0;
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
    box-sizing: border-box;
    pointer-events: none; /* Let clicks pass to member nodes */
}
.sushi-gen-row:last-child {
    border-bottom: none;
}
body.traditional-book-theme .sushi-gen-row,
body.pedigree-print-color .sushi-gen-row{
    border-bottom: 1px solid rgba(139, 0, 0, 0.12) !important;
}

/* Generation vertical titles on the right side of each row */
.sushi-row-title {
    position: absolute;
    right: 25px;
    top: 50%;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    text-orientation: upright;
    white-space: nowrap !important;
    font-family: var(--font-calligraphy);
    font-weight: bold;
    font-size: 0.95rem;
    color: var(--gold);
    user-select: none;
}
body.traditional-book-theme .sushi-row-title,
body.pedigree-print-color .sushi-row-title{
    color: var(--crimson) !important;
}

/* Member Nodes: plain calligraphy text, no borders or background */
.sushi-member-node {
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-family: var(--font-calligraphy);
    color: var(--text-primary) !important;
    font-size: 1.05rem;
    letter-spacing: 0.1em;
    display: flex;
    flex-direction: row; /* Aligns inline child spans vertically */
    align-items: center;
    justify-content: flex-start;
    position: absolute;
    cursor: pointer;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    min-height: unset !important;
    transition: color 0.2s ease, transform 0.2s ease;
}

.sushi-member-node:hover {
    color: var(--gold) !important;
    transform: translateX(50%) scale(1.05) !important; /* Keep translateX(50%) centering active! */
}

body.traditional-book-theme .sushi-member-node,
body.pedigree-print-color .sushi-member-node{
    color: #1a1a1a !important; /* Traditional black ink */
}

body.traditional-book-theme .sushi-member-node:hover,
body.pedigree-print-color .sushi-member-node:hover{
    color: var(--crimson) !important;
}

/* Sub-spans within the member node for vertical prefix, name, and suffix flow */
.sushi-member-node .node-relation {
    font-size: 0.82rem;
    opacity: 0.75;
    margin-bottom: 3px;
    display: inline-block;
}

.sushi-member-node .node-name {
    font-size: 1.25rem;
    font-weight: bold;
    display: inline-block;
}

.sushi-member-node .node-status {
    font-size: 0.82rem;
    color: #a27b2e; /* Muted gold/bronze for status */
    margin-top: 3px;
    display: inline-block;
}

body.traditional-book-theme .sushi-member-node .node-status,
body.pedigree-print-color .sushi-member-node .node-status{
    color: #8b0000 !important; /* Crimson red for status suffixes like 少亡 or 乏嗣 */
}

/* Suspended lines linking nodes (SVG absolute layout overlay) */
.sushi-page-connector-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.sushi-line {
    stroke: rgba(212, 175, 55, 0.45);
    stroke-width: 1.5;
    fill: none;
}

body.traditional-book-theme .sushi-line,
body.pedigree-print-color .sushi-line{
    stroke: rgba(139, 0, 0, 0.25) !important;
    stroke-width: 1.5 !important;
}

/* Sushi page continuation links ("接下页") */
.sushi-continuation-link {
    font-size: 0.68rem;
    color: var(--gold);
    opacity: 0.85;
    letter-spacing: 0px;
    line-height: 1.1;
    font-family: var(--font-calligraphy);
    cursor: pointer;
    transition: opacity 0.2s ease, color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
    margin-top: 6px;
    padding: 4px 2px;
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 2px;
    background: rgba(212, 175, 55, 0.05);
    text-align: center;
    box-sizing: border-box;
    white-space: nowrap;
}

.sushi-continuation-link:hover {
    opacity: 1;
    color: var(--gold) !important;
    border-color: var(--gold) !important;
    background: rgba(212, 175, 55, 0.15);
}

body.traditional-book-theme .sushi-continuation-link,
body.pedigree-print-color .sushi-continuation-link {
    color: var(--crimson) !important;
    border-color: rgba(139, 0, 0, 0.45);
    background: rgba(139, 0, 0, 0.04);
}

body.traditional-book-theme .sushi-continuation-link:hover,
body.pedigree-print-color .sushi-continuation-link:hover {
    color: var(--crimson) !important;
    border-color: var(--crimson) !important;
    background: rgba(139, 0, 0, 0.12);
}

/* Sushi page father continuation links ("系某某公（接某页）") */
.sushi-father-link {
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-family: var(--font-calligraphy);
    font-size: 0.72rem;
    line-height: 1.15;
    color: var(--gold);
    opacity: 0.85;
    position: absolute;
    cursor: pointer;
    text-align: center;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.sushi-father-link:hover {
    color: #ffdf7a !important;
    opacity: 1;
    text-decoration: underline;
}

body.traditional-book-theme .sushi-father-link:hover,
body.pedigree-print-color .sushi-father-link:hover {
    color: #b22222 !important;
}

.sushi-father-link div {
    display: block;
}

.sushi-father-link .father-name {
    font-weight: bold;
    font-size: 0.76rem;
}

.sushi-father-link .father-page {
    font-size: 0.65rem;
    opacity: 0.75;
}

body.traditional-book-theme .sushi-father-link,
body.pedigree-print-color .sushi-father-link {
    color: var(--crimson) !important;
}

/* Vertical connection line below the father-link */
.sushi-father-link::after {
    content: '';
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 18px;
    background: rgba(212, 175, 55, 0.4);
}

.pedigree-portrait .sushi-father-link::after {
    bottom: -30px;
    height: 30px;
}

body.traditional-book-theme .sushi-father-link::after,
body.pedigree-print-color .sushi-father-link::after {
    background: rgba(139, 0, 0, 0.3) !important;
}

body.pedigree-print-bw .sushi-father-link {
    color: #000000 !important;
}

body.pedigree-print-bw .sushi-father-link::after {
    background: #000000 !important;
}

/* Sushi Father Hover Tooltip */
.sushi-father-tooltip {
    position: absolute;
    z-index: 10000;
    width: 320px;
    background: #faf7ed;
    background-image: radial-gradient(rgba(139, 0, 0, 0.03) 1px, transparent 1px);
    background-size: 12px 12px;
    border: 2px solid #8b0000;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), inset 0 0 12px rgba(139, 0, 0, 0.05);
    color: #2b2b2b;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    line-height: 1.5;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sushi-father-tooltip.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Tooltip Layout and Typography */
.sushi-father-tooltip .tooltip-header {
    border-bottom: 1px double rgba(139, 0, 0, 0.3);
    padding-bottom: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sushi-father-tooltip .tooltip-title {
    font-family: 'Noto Serif SC', serif;
    font-weight: 700;
    font-size: 1rem;
    color: #8b0000;
}

.sushi-father-tooltip .tooltip-gen {
    font-size: 0.75rem;
    background: rgba(139, 0, 0, 0.08);
    color: #8b0000;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.sushi-father-tooltip .tooltip-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sushi-father-tooltip .tooltip-item {
    display: flex;
    justify-content: space-between;
}

.sushi-father-tooltip .tooltip-label {
    color: #666;
    font-weight: 500;
}

.sushi-father-tooltip .tooltip-value {
    font-weight: bold;
    color: #111;
    text-align: right;
}

/* Lineage Chain stepper */
.sushi-father-tooltip .tooltip-lineage-title {
    font-family: 'Noto Serif SC', serif;
    font-size: 0.8rem;
    color: #8b0000;
    margin-top: 12px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    border-top: 1px dashed rgba(139, 0, 0, 0.15);
    padding-top: 8px;
}

.sushi-father-tooltip .tooltip-lineage-flow {
    font-family: var(--font-calligraphy);
    font-size: 0.78rem;
    color: #555;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(139, 0, 0, 0.1);
    padding: 6px 10px;
    border-radius: 4px;
    line-height: 1.4;
    white-space: normal;
    word-break: break-all;
}

/* Tooltip Buttons / Actions */
.sushi-father-tooltip .tooltip-actions {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px dashed rgba(139, 0, 0, 0.15);
    padding-top: 10px;
}

.sushi-father-tooltip .tooltip-btn-primary {
    background: linear-gradient(135deg, #8b0000 0%, #600000 100%);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.sushi-father-tooltip .tooltip-btn-primary:hover {
    box-shadow: 0 4px 10px rgba(139, 0, 0, 0.25);
    transform: translateY(-1px);
}

.sushi-father-tooltip .tooltip-btn-secondary {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #555;
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
}

.sushi-father-tooltip .tooltip-btn-secondary:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #111;
}

/* Dark Theme overrides for tooltip */
body.dark-gold .sushi-father-tooltip {
    background: #181512;
    background-image: radial-gradient(rgba(212, 175, 55, 0.03) 1px, transparent 1px);
    background-size: 12px 12px;
    border: 2px solid var(--gold);
    color: #e0dcd3;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 12px rgba(212, 175, 55, 0.05);
}

body.dark-gold .sushi-father-tooltip .tooltip-header {
    border-bottom: 1px double rgba(212, 175, 55, 0.3);
}

body.dark-gold .sushi-father-tooltip .tooltip-title {
    color: var(--gold);
}

body.dark-gold .sushi-father-tooltip .tooltip-gen {
    background: rgba(212, 175, 55, 0.1);
    color: var(--gold);
}

body.dark-gold .sushi-father-tooltip .tooltip-label {
    color: #aaa;
}

body.dark-gold .sushi-father-tooltip .tooltip-value {
    color: #fff;
}

body.dark-gold .sushi-father-tooltip .tooltip-lineage-title {
    color: var(--gold);
    border-top: 1px dashed rgba(212, 175, 55, 0.15);
}

body.dark-gold .sushi-father-tooltip .tooltip-lineage-flow {
    color: #ccc;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(212, 175, 55, 0.1);
}

body.dark-gold .sushi-father-tooltip .tooltip-actions {
    border-top: 1px dashed rgba(212, 175, 55, 0.15);
}

body.dark-gold .sushi-father-tooltip .tooltip-btn-primary {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: #000;
}

body.dark-gold .sushi-father-tooltip .tooltip-btn-primary:hover {
    box-shadow: 0 4px 10px rgba(212, 175, 55, 0.25);
}

body.dark-gold .sushi-father-tooltip .tooltip-btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #bbb;
}

body.dark-gold .sushi-father-tooltip .tooltip-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

/* Oushi Layout: Ou-style horizontal generation blocks */
.oushi-format .pedigree-page-content {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: 100%;
    overflow: hidden;
}

.oushi-gen-section {
    width: 100%;
    border-bottom: 1.5px solid rgba(212, 175, 55, 0.25);
    padding-bottom: 15px;
    margin-bottom: 15px;
}

body.traditional-book-theme .oushi-gen-section,
body.pedigree-print-color .oushi-gen-section{
    border-bottom: 1.5px solid rgba(139, 0, 0, 0.2) !important;
}

.oushi-gen-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.oushi-gen-header {
    font-family: var(--font-calligraphy);
    font-size: 1.05rem;
    color: var(--gold);
    font-weight: bold;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

body.traditional-book-theme .oushi-gen-header,
body.pedigree-print-color .oushi-gen-header{
    color: var(--crimson) !important;
}

.oushi-nodes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.oushi-member-card {
    background: rgba(15, 15, 18, 0.8);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 4px;
    padding: 12px 14px;
    box-sizing: border-box;
    cursor: pointer;
    transition: all 0.3s ease;
}

.oushi-member-card:hover {
    border-color: var(--gold);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

body.traditional-book-theme .oushi-member-card,
body.pedigree-print-color .oushi-member-card{
    background: #fefdf9 !important;
    border: 1px solid rgba(139, 0, 0, 0.15) !important;
    box-shadow: 0 1px 4px rgba(139, 0, 0, 0.03) !important;
}

body.traditional-book-theme .oushi-member-card:hover,
body.pedigree-print-color .oushi-member-card:hover{
    border-color: var(--crimson) !important;
    box-shadow: 0 3px 8px rgba(200, 35, 35, 0.08) !important;
}

.oushi-card-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 6px;
    margin-bottom: 8px;
}

body.traditional-book-theme .oushi-card-title,
body.pedigree-print-color .oushi-card-title{
    border-bottom: 1px solid rgba(139, 0, 0, 0.06) !important;
}

.oushi-card-title .name {
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--text-primary);
    font-family: var(--font-calligraphy);
}

body.traditional-book-theme .oushi-card-title .name,
body.pedigree-print-color .oushi-card-title .name{
    color: var(--parchment-text-primary) !important;
}

.oushi-card-title .meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

body.traditional-book-theme .oushi-card-title .meta,
body.pedigree-print-color .oushi-card-title .meta{
    color: var(--parchment-text-secondary) !important;
}

.oushi-card-body {
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

body.traditional-book-theme .oushi-card-body,
body.pedigree-print-color .oushi-card-body{
    color: var(--parchment-text-secondary) !important;
}

.oushi-card-body .father-relation {
    color: var(--gold);
    font-size: 0.75rem;
    margin-bottom: 4px;
}

body.traditional-book-theme .oushi-card-body .father-relation,
body.pedigree-print-color .oushi-card-body .father-relation{
    color: var(--crimson) !important;
}

.oushi-card-body .notes {
    font-style: italic;
    color: var(--text-muted);
}

body.traditional-book-theme .oushi-card-body .notes,
body.pedigree-print-color .oushi-card-body .notes{
    color: #8c826e !important;
}

/* Global media hiding for print tab in mobile */
@media (max-width: 768px) {
    .header-nav button[data-tab="pedigree"],
    .header-nav button[data-tab="dashboard"] {
        display: none !important;
    }
}

/* Screen B&W Print Preview Style */
body.pedigree-print-bw .pedigree-page {
    background: #ffffff !important;
    background-image: none !important;
    border: 2px solid #000000 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1) !important;
    color: #000000 !important;
}

body.pedigree-print-bw .pedigree-page-border {
    border: 1px solid #000000 !important;
}

body.pedigree-print-bw .pedigree-page-middle-crease {
    border-left: 1px solid rgba(0, 0, 0, 0.1) !important; /* Changed to extremely faint solid line for clean print folding guides */
    border-right: 1px solid rgba(0, 0, 0, 0.1) !important; /* Changed to extremely faint solid line for clean print folding guides */
}

body.pedigree-print-bw .fish-mouth {
    border-top-color: #000000 !important;
}
body.pedigree-print-bw .fish-mouth.bottom {
    border-bottom-color: #000000 !important;
}

body.pedigree-print-bw .page-center-title,
body.pedigree-print-bw .pedigree-page-header .header-left,
body.pedigree-print-bw .pedigree-page-header .header-right,
body.pedigree-print-bw .pedigree-page-footer span,
body.pedigree-print-bw .sushi-row-title,
body.pedigree-print-bw .sushi-member-node,
body.pedigree-print-bw .sushi-member-node .node-status,
body.pedigree-print-bw .sushi-continuation-link {
    color: #000000 !important;
}
body.pedigree-print-bw .sushi-continuation-link {
    border-color: #000000 !important;
    background: transparent !important;
}

body.pedigree-print-bw .sushi-line {
    stroke: #000000 !important;
}

body.pedigree-print-bw .sushi-gen-row {
    border-bottom: 1px solid #000000 !important;
}

body.pedigree-print-bw .stitch-hole {
    background: #444444 !important;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.5) !important;
}
body.pedigree-print-bw .stitch-line,
body.pedigree-print-bw .stitch-hole::after,
body.pedigree-print-bw .stitch-hole::before {
    background: #666666 !important;
    box-shadow: none !important;
}

/* PDF Print Media Query Overrides */
@media print {
    @page {
        margin: 0;
    }
    @page landscape-page {
        size: A4 landscape;
        margin: 0;
    }
    @page portrait-page {
        size: A4 portrait;
        margin: 0;
    }

    /* Break page clamping limits for multi-page printing */
    html, body {
        height: auto !important;
        overflow: visible !important;
        position: static !important;
        width: auto !important;
    }

    /* Hide all non-printable tabs/pages */
    .page-content {
        display: none !important;
    }
    #page-pedigree {
        display: block !important;
    }

    /* Hide faux binding stitch thread & punch holes in print outputs */
    .pedigree-page-stitches {
        display: none !important;
    }

    /* Hide all browser components */
    body {
        background: #fff !important;
        color: #000 !important;
        margin: 0 !important;
        padding: 0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    header, footer, nav,
    .header-nav, .pedigree-controls-card,
    .tab-page-header, .app-header {
        display: none !important;
    }

    .app-pages-container {
        position: static !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
    }

    #page-pedigree {
        background: #fff !important;
        position: static !important;
        height: auto !important;
        overflow: visible !important;
    }

    .pedigree-scrollable {
        padding: 0 !important;
        overflow: visible !important;
        height: auto !important;
    }

    .pedigree-book-viewport {
        overflow: visible !important;
        padding: 0 !important;
    }

    .pedigree-preview-container {
        display: block !important;
        width: 794px !important; /* Keep exact A4 width */
        gap: 0 !important;
        padding: 0 !important;
        margin: 0 auto !important;
    }
    .pedigree-landscape .pedigree-preview-container {
        width: 1123px !important;
    }
    .pedigree-portrait .pedigree-preview-container {
        width: 794px !important;
    }

    /* Format printable page container */
    .pedigree-page {
        page-break-after: always !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        position: relative !important;
        width: 794px !important; /* Keep exact A4 width */
        height: 1123px !important; /* Keep exact A4 height */
        margin: 0 !important;
        box-shadow: none !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        background: #fff !important; /* Default background for printing is white */
        color: #000 !important;
    }
    .pedigree-landscape .pedigree-page {
        page: landscape-page;
        width: 1123px !important;
        height: 794px !important;
    }
    .pedigree-portrait .pedigree-page {
        page: portrait-page;
        width: 794px !important;
        height: 1123px !important;
    }

    /* Default Color Print styles for pedigree elements to prevent dark theme inheritance */
    .pedigree-page-border {
        border: 1px solid rgba(139, 0, 0, 0.15) !important;
    }

    .pedigree-page-middle-crease {
        border-left: 1px solid rgba(139, 0, 0, 0.12) !important; /* Changed to solid fine line */
        border-right: 1px solid rgba(139, 0, 0, 0.12) !important; /* Changed to solid fine line */
    }

    .fish-mouth {
        border-top-color: rgba(139, 0, 0, 0.4) !important;
    }
    .fish-mouth.bottom {
        border-bottom-color: rgba(139, 0, 0, 0.4) !important;
    }

    .page-center-title {
        display: none !important; /* Hide to prevent messy name overlaps during printing */
    }

    .pedigree-page-header {
        border-bottom: 1px solid rgba(139, 0, 0, 0.15) !important;
    }
    .pedigree-page-header .header-left {
        color: var(--crimson) !important;
    }
    .pedigree-page-header .header-right {
        color: var(--parchment-text-secondary) !important;
    }

    .pedigree-page-footer {
        border-top: 1px solid rgba(139, 0, 0, 0.15) !important;
    }
    .pedigree-page-footer span {
        color: var(--parchment-text-secondary) !important;
    }

    /* Sushi Layout print colors */
    .sushi-gen-row {
        border-bottom: 1px solid rgba(139, 0, 0, 0.12) !important;
    }
    .sushi-row-title {
        color: var(--crimson) !important;
    }
    .sushi-member-node {
        color: #1a1a1a !important; /* Traditional black ink */
        background: transparent !important;
        box-shadow: none !important;
    }
    .sushi-member-node .node-relation {
        color: #1a1a1a !important;
        opacity: 0.75 !important;
    }
    .sushi-member-node .node-name {
        color: #1a1a1a !important;
    }
    .sushi-member-node .node-status {
        color: #8b0000 !important; /* Crimson red status for color print */
    }
    .sushi-line {
        stroke: rgba(139, 0, 0, 0.25) !important;
        stroke-width: 1.5 !important;
    }
    .sushi-continuation-link {
        color: var(--crimson) !important;
    }

    /* Oushi Layout print colors */
    .oushi-gen-section {
        border-bottom: 1.5px solid rgba(139, 0, 0, 0.2) !important;
    }
    .oushi-gen-header {
        color: var(--crimson) !important;
    }
    .oushi-member-card {
        background: #fefdf9 !important;
        border: 1px solid rgba(139, 0, 0, 0.15) !important;
        box-shadow: none !important;
    }
    .oushi-card-title {
        border-bottom: 1px solid rgba(139, 0, 0, 0.06) !important;
    }
    .oushi-card-title .name {
        color: var(--parchment-text-primary) !important;
    }
    .oushi-card-title .meta {
        color: var(--parchment-text-secondary) !important;
    }
    .oushi-card-body {
        color: var(--parchment-text-secondary) !important;
    }
    .oushi-card-body .father-relation {
        color: var(--crimson) !important;
    }
    .oushi-card-body .notes {
        color: #8c826e !important;
    }

    /* Hard B&W Print overrides */
    body.pedigree-print-bw .pedigree-page {
        background: #fff !important;
        color: #000 !important;
        border: 2px solid #000 !important;
    }
    body.pedigree-print-bw .pedigree-page-border {
        border: 1px solid #000 !important;
    }
    body.pedigree-print-bw .pedigree-page-middle-crease {
        border-left: 1px solid rgba(0, 0, 0, 0.1) !important; /* Changed to extremely faint solid line */
        border-right: 1px solid rgba(0, 0, 0, 0.1) !important; /* Changed to extremely faint solid line */
    }
    body.pedigree-print-bw .fish-mouth {
        border-top-color: #000 !important;
    }
    body.pedigree-print-bw .fish-mouth.bottom {
        border-bottom-color: #000 !important;
    }
    body.pedigree-print-bw .page-center-title {
        color: #000 !important;
    }
    body.pedigree-print-bw .pedigree-page-header {
        border-bottom: 1px solid #000 !important;
    }
    body.pedigree-print-bw .pedigree-page-header .header-left,
    body.pedigree-print-bw .pedigree-page-header .header-right {
        color: #000 !important;
    }
    body.pedigree-print-bw .pedigree-page-footer {
        border-top: 1px solid #000 !important;
    }
    body.pedigree-print-bw .pedigree-page-footer span {
        color: #000 !important;
    }

    /* Sushi print B&W overrides */
    body.pedigree-print-bw .sushi-gen-row {
        border-bottom: 1px solid #000 !important;
    }
    body.pedigree-print-bw .sushi-row-title {
        color: #000 !important;
    }
    body.pedigree-print-bw .sushi-member-node {
        color: #000 !important;
        background: transparent !important;
        box-shadow: none !important;
    }
    body.pedigree-print-bw .sushi-member-node .node-status {
        color: #000 !important;
    }
    body.pedigree-print-bw .sushi-line {
        stroke: #000 !important;
    }
    body.pedigree-print-bw .sushi-continuation-link {
        color: #000 !important;
        border-color: #000 !important;
        background: transparent !important;
    }

    /* Oushi print B&W overrides */
    body.pedigree-print-bw .oushi-gen-header {
        color: #000 !important;
    }
    body.pedigree-print-bw .oushi-gen-section {
        border-bottom: 1.5px solid #000 !important;
    }
    body.pedigree-print-bw .oushi-member-card {
        background: #fff !important;
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
    body.pedigree-print-bw .oushi-card-title {
        border-bottom: 1px solid #000 !important;
    }
    body.pedigree-print-bw .oushi-card-title .name,
    body.pedigree-print-bw .oushi-card-title .meta,
    body.pedigree-print-bw .oushi-card-body,
    body.pedigree-print-bw .oushi-card-body .father-relation,
    body.pedigree-print-bw .oushi-card-body .notes {
        color: #000 !important;
    }

    /* Stitch styling for print B&W */
    body.pedigree-print-bw .stitch-hole {
        background: #666 !important;
        box-shadow: none !important;
    }
    body.pedigree-print-bw .stitch-line,
    body.pedigree-print-bw .stitch-hole::after,
    body.pedigree-print-bw .stitch-hole::before {
        background: #999 !important;
        box-shadow: none !important;
    }
}

/* ==========================================================================
   12. GIS Migration Map Styles (地理播迁足迹图)
   ========================================================================== */

.migration-map-box {
    margin-top: 15px;
    margin-bottom: 25px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 215, 0, 0.15);
    background: rgba(18, 18, 18, 0.6);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
}

body.traditional-book-theme .migration-map-box {
    border: 1px solid rgba(139, 115, 85, 0.25);
    background: #fbf8f3;
    box-shadow: 0 4px 15px rgba(139, 115, 85, 0.1);
}

.map-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(255, 215, 0, 0.05);
    border-bottom: 1px solid rgba(255, 215, 0, 0.15);
    font-size: 0.9rem;
    font-weight: bold;
    color: #e5c158;
}

body.traditional-book-theme .map-title-bar {
    background: rgba(139, 115, 85, 0.05);
    border-bottom: 1px solid rgba(139, 115, 85, 0.25);
    color: #5c3a21;
}

.map-title-bar small {
    font-weight: normal;
    font-size: 0.75rem;
}

.migration-svg-container {
    width: 100%;
    height: 300px;
    position: relative;
    overflow: hidden;
}

.map-province {
    fill: rgba(255, 215, 0, 0.015);
    stroke: rgba(255, 215, 0, 0.12);
    stroke-width: 1.2px;
    stroke-linejoin: round;
    transition: all 0.3s ease;
}

body.traditional-book-theme .map-province {
    fill: rgba(139, 115, 85, 0.03);
    stroke: rgba(139, 115, 85, 0.2);
    stroke-width: 1.2px;
}

.map-province:hover {
    fill: rgba(255, 215, 0, 0.04);
}

body.traditional-book-theme .map-province:hover {
    fill: rgba(139, 115, 85, 0.06);
}

.province-label {
    font-family: "Noto Serif SC", serif;
    font-size: 0.85rem;
    font-weight: 600;
    fill: rgba(255, 215, 0, 0.25);
    pointer-events: none;
    letter-spacing: 2px;
}

body.traditional-book-theme .province-label {
    fill: rgba(139, 115, 85, 0.45);
}

.migration-vector {
    fill: none;
    stroke: #e5c158;
    stroke-width: 2px;
    stroke-linecap: round;
    stroke-dasharray: 6, 6;
    animation: line-flow 1.5s linear infinite;
    filter: drop-shadow(0 0 3px rgba(229, 193, 88, 0.4));
}

body.traditional-book-theme .migration-vector {
    stroke: #c0392b; /* vermilion cinnabar */
    filter: drop-shadow(0 0 2px rgba(192, 57, 43, 0.25));
}

@keyframes line-flow {
    to {
        stroke-dashoffset: -24;
    }
}

.pulse-pin-group {
    cursor: pointer;
}

.pulse-ring {
    fill: none;
    stroke: #e5c158;
    stroke-width: 1.5px;
    animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    transform-origin: center;
}

body.traditional-book-theme .pulse-ring {
    stroke: #c0392b;
}

@keyframes pulse-ring {
    0% {
        r: 2px;
        opacity: 1;
    }
    80%, 100% {
        r: 15px;
        opacity: 0;
    }
}

.pin-core {
    fill: #e5c158;
    stroke: #121212;
    stroke-width: 1.2px;
    transition: all 0.3s ease;
}

body.traditional-book-theme .pin-core {
    fill: #c0392b;
    stroke: #fff;
}

.pulse-pin-group:hover .pin-core {
    transform: scale(1.3);
    fill: #fff;
}

body.traditional-book-theme .pulse-pin-group:hover .pin-core {
    fill: #000;
}

.pin-label {
    font-family: "Noto Serif SC", serif;
    font-size: 0.75rem;
    font-weight: bold;
    fill: #e5c158;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 6px rgba(229, 193, 88, 0.3);
}

body.traditional-book-theme .pin-label {
    fill: #5c3a21;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
}

/* Tooltip on Map */
.map-tooltip {
    position: absolute;
    padding: 8px 12px;
    background: rgba(18, 18, 18, 0.95);
    border: 1px solid #e5c158;
    color: #fff;
    border-radius: 6px;
    font-size: 0.75rem;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    max-width: 250px;
    line-height: 1.4;
    transition: opacity 0.2s ease;
}

body.traditional-book-theme .map-tooltip {
    background: #fbf8f3;
    border: 1px solid #5c3a21;
    color: #5c3a21;
    box-shadow: 0 4px 10px rgba(139, 115, 85, 0.2);
}

/* ==========================================================================
   13. Memorial Button in Sidebar (纪念堂入口按钮)
   ========================================================================== */

.profile-memorial-row {
    margin-top: 10px;
    width: 100%;
}

.action-btn-memorial {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #8a1f1f, #c0392b);
    border: 1px solid #e5c158;
    border-radius: 8px;
    color: #fff;
    font-family: "Noto Serif SC", serif;
    font-weight: bold;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(192, 57, 43, 0.35);
}

.action-btn-memorial:hover {
    background: linear-gradient(135deg, #a02828, #d35400);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(192, 57, 43, 0.5), 0 0 8px rgba(229, 193, 88, 0.3);
}

body.traditional-book-theme .action-btn-memorial {
    background: linear-gradient(135deg, #5c1818, #8a1f1f);
    border: 1px solid #8b7355;
    box-shadow: 0 4px 8px rgba(138, 31, 31, 0.15);
}

/* ==========================================================================
   14. Full-Screen Memorial Hall (数字化追思纪念堂)
   ========================================================================== */

.memorial-fullscreen-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.memorial-fullscreen-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.memorial-modal-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(15px);
}

body.traditional-book-theme .memorial-modal-overlay {
    background: rgba(246, 241, 230, 0.96);
    backdrop-filter: blur(8px);
}

.memorial-hall-container {
    position: relative;
    width: 90%;
    max-width: 960px;
    height: 90vh;
    background: #110e0c;
    border: 2px solid #e5c158;
    border-radius: 16px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(229, 193, 88, 0.2);
    z-index: 2005;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #e5c158 #110e0c;
}

body.traditional-book-theme .memorial-hall-container {
    background: #fbf8f3;
    border: 2px solid #5c3a21;
    box-shadow: 0 10px 30px rgba(139, 115, 85, 0.25);
}

.memorial-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: #e5c158;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    z-index: 2010;
}

.memorial-close-btn:hover {
    background: #c0392b;
    border-color: #fff;
    color: #fff;
    transform: rotate(90deg);
}

body.traditional-book-theme .memorial-close-btn {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid #5c3a21;
    color: #5c3a21;
}

.memorial-hall-main {
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100%;
    box-sizing: border-box;
}

/* Altar Gold Tablet (匾额) */
.memorial-tablet {
    margin-bottom: 30px;
    width: 100%;
    max-width: 500px;
    display: flex;
    justify-content: center;
}

.tablet-frame {
    padding: 10px 40px;
    background: linear-gradient(135deg, #1c1510, #36281e);
    border: 3px double #e5c158;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), inset 0 0 10px rgba(229, 193, 88, 0.3);
}

body.traditional-book-theme .tablet-frame {
    background: #f5f0e6;
    border: 3px double #5c3a21;
    box-shadow: 0 4px 10px rgba(139, 115, 85, 0.1);
}

.tablet-frame h1 {
    margin: 0;
    font-family: "Noto Serif SC", serif;
    font-size: 1.6rem;
    font-weight: 900;
    color: #e5c158;
    letter-spacing: 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    text-align: center;
}

body.traditional-book-theme .tablet-frame h1 {
    color: #5c3a21;
    text-shadow: none;
}

/* Ancestral Shrine (神龛) */
.memorial-shrine {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 380px;
    background: linear-gradient(to bottom, #191410, #0c0907);
    border: 2px solid #5c4033;
    border-radius: 12px;
    box-shadow: inset 0 0 50px rgba(0,0,0,0.9), 0 10px 30px rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-bottom: 25px;
    overflow: hidden;
}

body.traditional-book-theme .memorial-shrine {
    background: #fbf8f3;
    border: 2px solid #8b7355;
    box-shadow: inset 0 0 20px rgba(139, 115, 85, 0.1), 0 5px 15px rgba(139, 115, 85, 0.1);
}

.shrine-light-glow {
    position: absolute;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 165, 0, 0.18) 0%, rgba(255, 165, 0, 0) 70%);
    pointer-events: none;
    z-index: 1;
    transition: all 0.5s ease;
}

.memorial-shrine.candle-lit .shrine-light-glow {
    background: radial-gradient(circle, rgba(255, 165, 0, 0.35) 0%, rgba(255, 165, 0, 0) 75%);
    width: 320px;
    height: 320px;
}

/* Ancestor Wood Tablet (神位牌) */
.ancestor-tablet-card {
    position: relative;
    z-index: 5;
    width: 160px;
    height: 250px;
    background: linear-gradient(135deg, #4a140f, #2b0c0a);
    border: 4px solid #e5c158;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6), 0 0 15px rgba(229, 193, 88, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px 10px;
    box-sizing: border-box;
    transition: all 0.5s ease;
}

.memorial-shrine.candle-lit .ancestor-tablet-card {
    box-shadow: 0 10px 30px rgba(255, 165, 0, 0.4), 0 0 25px rgba(229, 193, 88, 0.3);
}

body.traditional-book-theme .ancestor-tablet-card {
    background: linear-gradient(135deg, #f7f2e8, #ede6d9);
    border: 4px solid #5c3a21;
    box-shadow: 0 5px 15px rgba(139, 115, 85, 0.15);
}

.tablet-ancestor-rank {
    font-family: "Noto Serif SC", serif;
    font-size: 0.75rem;
    color: #e5c158;
    border-bottom: 1px solid rgba(229, 193, 88, 0.4);
    padding-bottom: 4px;
    margin-bottom: 12px;
    letter-spacing: 2px;
}

body.traditional-book-theme .tablet-ancestor-rank {
    color: #5c3a21;
    border-bottom: 1px solid rgba(92, 58, 33, 0.3);
}

.tablet-ancestor-name {
    font-family: "Noto Serif SC", serif;
    font-size: 1.4rem;
    font-weight: bold;
    color: #fff;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 6px;
    margin-bottom: 12px;
}

body.traditional-book-theme .tablet-ancestor-name {
    color: #c0392b; /* Red vermilion */
}

.tablet-ancestor-status {
    font-family: "Noto Serif SC", serif;
    font-size: 0.7rem;
    color: #e5c158;
    letter-spacing: 1px;
}

body.traditional-book-theme .tablet-ancestor-status {
    color: #5c3a21;
}

/* Incense Burner (香炉) */
.incense-burner-area {
    position: absolute;
    bottom: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100px;
}

.incense-burner {
    position: relative;
    width: 60px;
    height: 35px;
}

.burner-body {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #bf953f, #fcf6ba, #b38728, #fbf5b7, #aa771c);
    border: 1px solid #996515;
    border-radius: 50% 50% 30% 30% / 40% 40% 60% 60%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

body.traditional-book-theme .burner-body {
    background: linear-gradient(135deg, #8a7355, #c5b49e, #8a7355);
    border: 1px solid #5c3a21;
}

.incense-sticks-container {
    position: absolute;
    bottom: 25px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 4px;
    height: 60px;
}

.incense-stick {
    width: 2px;
    height: 45px;
    background: #cd7f32;
    position: relative;
    transform-origin: bottom center;
}

.incense-stick.lit::after {
    content: '';
    position: absolute;
    top: 0;
    left: -1px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #ff4500;
    box-shadow: 0 0 6px #ff8c00, 0 0 12px #ff4500;
}

/* Smoldering smoke simulation */
.incense-smoke-wrapper {
    position: absolute;
    bottom: 45px;
    width: 40px;
    height: 80px;
    pointer-events: none;
}

.smoke-particle {
    position: absolute;
    bottom: 0;
    left: 18px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(240, 240, 240, 0.35);
    filter: blur(4px);
    animation: smoke-float 3.5s ease-out infinite;
}

@keyframes smoke-float {
    0% {
        transform: translateY(0) scale(1) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 0.5;
    }
    50% {
        transform: translateY(-40px) scale(2) translateX(-8px);
        opacity: 0.35;
    }
    100% {
        transform: translateY(-90px) scale(3.5) translateX(12px);
        opacity: 0;
    }
}

/* Candles (蜡烛) */
.candle-stand {
    position: absolute;
    bottom: 25px;
    width: 20px;
    height: 90px;
    z-index: 4;
}

.candle-stand.left {
    left: 60px;
}

.candle-stand.right {
    right: 60px;
}

.candle-body {
    width: 100%;
    height: 65px;
    background: linear-gradient(to right, #b22222, #ff4500, #b22222);
    border: 1px solid #8b0000;
    border-radius: 3px 3px 1px 1px;
    position: absolute;
    bottom: 0;
    box-shadow: 0 5px 10px rgba(0,0,0,0.6);
}

.candle-fire {
    width: 10px;
    height: 18px;
    background: radial-gradient(ellipse at bottom, #ff8c00 0%, #ff4500 40%, rgba(255,0,0,0) 80%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    position: absolute;
    top: 5px;
    left: 5px;
    transform-origin: center bottom;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.memorial-shrine.candle-lit .candle-fire {
    opacity: 1;
    animation: flame-flicker 1.8s ease-in-out infinite alternate;
}

.candle-glow {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 140, 0, 0.4) 0%, rgba(255, 140, 0, 0) 70%);
    position: absolute;
    top: -12px;
    left: -15px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.memorial-shrine.candle-lit .candle-glow {
    opacity: 1;
}

@keyframes flame-flicker {
    0%, 100% {
        transform: scale(1) rotate(-1deg);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.06) rotate(2deg);
        filter: brightness(1.2) drop-shadow(0 0 6px rgba(255,140,0,0.9));
    }
}

/* Offering Table & Plate (供桌与祭品) */
.offering-table {
    display: flex;
    justify-content: center;
    gap: 30px;
    width: 100%;
    max-width: 500px;
    margin-bottom: 25px;
}

.tribute-plate {
    flex: 1;
    background: rgba(25, 20, 16, 0.8);
    border: 1px solid #5c4033;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

body.traditional-book-theme .tribute-plate {
    background: #ede6d9;
    border: 1px solid #8b7355;
    box-shadow: 0 2px 5px rgba(139, 115, 85, 0.1);
}

.tribute-label {
    font-size: 0.75rem;
    color: #e5c158;
    margin-bottom: 8px;
    font-weight: bold;
}

body.traditional-book-theme .tribute-label {
    color: #5c3a21;
}

.tribute-item-placeholder {
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.5s ease;
}

.respect-count-val {
    font-family: "Noto Serif SC", serif;
    font-size: 1.4rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px rgba(229, 193, 88, 0.5);
}

body.traditional-book-theme .respect-count-val {
    color: #c0392b;
    text-shadow: none;
}

/* Action Control Bar (操作台) */
.memorial-action-bar {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
    max-width: 550px;
    margin-bottom: 35px;
}

.offering-btn {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 12px 10px;
    background: linear-gradient(135deg, #1f1a16, #2d2620);
    border: 1px solid #e5c158;
    border-radius: 6px;
    color: #e5c158;
    font-family: "Noto Serif SC", serif;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
}

.offering-btn:hover {
    background: linear-gradient(135deg, #2d2620, #3e352c);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(229, 193, 88, 0.3);
}

body.traditional-book-theme .offering-btn {
    background: linear-gradient(135deg, #fbf8f3, #ede6d9);
    border: 1px solid #5c3a21;
    color: #5c3a21;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

body.traditional-book-theme .offering-btn:hover {
    background: #ede6d9;
    color: #000;
}

.offering-btn:active {
    transform: translateY(0);
}

/* Ancestor Biography Roll (先祖生平画卷) */
.memorial-scroll-section {
    width: 100%;
    max-width: 650px;
    display: flex;
    justify-content: center;
}

.memorial-scroll-paper {
    width: 100%;
    padding: 30px;
    background: linear-gradient(135deg, #1c1512, #291e19);
    border: 1px solid #7d5e3f;
    border-radius: 8px;
    box-shadow: inset 0 0 35px rgba(0,0,0,0.95), 0 8px 25px rgba(0,0,0,0.7);
    color: #e3d2bd;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
}

body.traditional-book-theme .memorial-scroll-paper {
    background: #f5eedc;
    border: 1px solid #d4c4a8;
    box-shadow: inset 0 0 30px rgba(139,115,85,0.25), 0 4px 10px rgba(139,115,85,0.05);
    color: #2b1f13;
}

.memorial-scroll-paper .scroll-title {
    font-family: "Noto Serif SC", serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #e5c158;
    border-bottom: 2px solid #e5c158;
    padding-bottom: 6px;
    margin-bottom: 20px;
    letter-spacing: 4px;
    text-align: center;
    width: 110px;
}

body.traditional-book-theme .memorial-scroll-paper .scroll-title {
    color: #8a1f1f;
    border-bottom: 2px solid #8a1f1f;
}

.memorial-scroll-paper .scroll-content {
    font-family: "Noto Serif SC", serif;
    font-size: 1.05rem;
    line-height: 2.2;
    writing-mode: vertical-rl;
    text-orientation: upright; /* 强制所有英文字符和阿拉伯数字立正，呈传统的竖排堆叠 */
    height: 220px;
    overflow-x: auto;
    width: 100%;
    padding: 10px 25px;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #e5c158 #1c1512;
}

body.traditional-book-theme .memorial-scroll-paper .scroll-content {
    scrollbar-color: #8a1f1f #f5eedc;
}

.memorial-scroll-paper .scroll-content p {
    margin: 0 0 0 35px; /* 在竖排从右往左流中，左边距即为段落（列）之间的间距 */
    white-space: normal;
    word-break: break-all;
}

.memorial-scroll-paper .scroll-content strong {
    color: #e5c158;
    font-weight: 700;
}

body.traditional-book-theme .memorial-scroll-paper .scroll-content strong {
    color: #8a1f1f;
}

/* Custom flow scroll for vertical text */
.memorial-scroll-paper .scroll-content::-webkit-scrollbar {
    height: 6px;
}
.memorial-scroll-paper .scroll-content::-webkit-scrollbar-track {
    background: #1c1512;
}
body.traditional-book-theme .memorial-scroll-paper .scroll-content::-webkit-scrollbar-track {
    background: #f5eedc;
}
.memorial-scroll-paper .scroll-content::-webkit-scrollbar-thumb {
    background-color: #e5c158;
    border-radius: 3px;
}

body.traditional-book-theme .memorial-scroll-paper .scroll-content::-webkit-scrollbar-thumb {
    background-color: #8a1f1f;
}

/* Animations and tweaks */
.flower-bundle {
    animation: fade-in-scale 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes fade-in-scale {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Page highlight flash animation for navigation */
@keyframes highlight-flash-anim {
    0% {
        box-shadow: 0 0 0 0px rgba(212, 175, 55, 0);
        outline: 2px solid transparent;
    }
    15% {
        box-shadow: 0 0 25px 8px rgba(212, 175, 55, 0.85);
        outline: 2px solid var(--gold, #d4af37);
    }
    100% {
        box-shadow: 0 0 0 0px rgba(212, 175, 55, 0);
        outline: 2px solid transparent;
    }
}
.highlight-flash {
    animation: highlight-flash-anim 2.5s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Timeline event media link styling */
.timeline-event-media {
    margin-top: 8px;
}
.timeline-event-media-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--gold, #d4af37);
    border: 1px dashed rgba(212, 175, 55, 0.4);
    background: rgba(212, 175, 55, 0.05);
    padding: 4px 10px;
    border-radius: 6px;
    text-decoration: none;
    transition: var(--transition-fast);
}
.timeline-event-media-link:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: var(--gold, #d4af37);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.15);
}
.traditional-book-theme .timeline-event-media-link {
    color: var(--crimson, #8b0000);
    border-color: rgba(139, 0, 0, 0.3);
    background: rgba(139, 0, 0, 0.03);
}
.traditional-book-theme .timeline-event-media-link:hover {
    background: rgba(139, 0, 0, 0.08);
    border-color: var(--crimson, #8b0000);
    box-shadow: 0 2px 8px rgba(139, 0, 0, 0.08);
}

/* Dashboard Era Lifespan Analytics Container */
.dashboard-era-lifespan-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
}

.dashboard-analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .dashboard-analytics-grid {
        grid-template-columns: 1fr;
    }
}

/* KPI Summary inside Era Lifespan Box */
.dashboard-analytics-summary {
    grid-column: span 2;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 10px;
}
.traditional-book-theme .dashboard-analytics-summary {
    background: rgba(0, 0, 0, 0.01);
    border-color: rgba(0, 0, 0, 0.04);
}
.analytics-summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.analytics-summary-item .summary-label {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-bottom: 4px;
}
.analytics-summary-item .summary-value {
    font-size: 1.25rem;
    font-family: 'Noto Serif SC', serif;
    font-weight: 700;
    color: var(--gold, #d4af37);
}
.traditional-book-theme .analytics-summary-item .summary-value {
    color: var(--crimson, #8b0000);
}

/* Lifespan distribution chart */
.lifespan-distribution-chart, .era-distribution-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.chart-subtitle {
    font-family: 'Noto Serif SC', serif;
    font-size: 0.95rem;
    margin-bottom: 8px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 6px;
    color: var(--text-primary);
}
.traditional-book-theme .chart-subtitle {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

.lifespan-bar-row, .era-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
}
.bar-label {
    width: 110px;
    opacity: 0.85;
}
.bar-track {
    flex: 1;
    height: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}
.traditional-book-theme .bar-track {
    background: rgba(0, 0, 0, 0.04);
}
.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #b38f36, #ffdf7a);
    border-radius: 6px;
    transition: width 1s ease-out;
}
.traditional-book-theme .bar-fill {
    background: linear-gradient(90deg, #8b0000, #d32f2f);
}
.bar-value {
    width: 40px;
    text-align: right;
    font-weight: 600;
    opacity: 0.9;
}

/* Fallback Card Styling */
.dashboard-fallback-card {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 32px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    width: 100%;
}
.traditional-book-theme .dashboard-fallback-card {
    background: rgba(0, 0, 0, 0.01);
    border-color: rgba(0, 0, 0, 0.08);
}
.fallback-calligraphy {
    font-family: 'Long Cang', 'Noto Serif SC', cursive, serif;
    font-size: 6.5rem;
    line-height: 1;
    opacity: 0.08;
    position: absolute;
    right: 16px;
    bottom: -16px;
    color: var(--gold, #d4af37);
    pointer-events: none;
}
.traditional-book-theme .fallback-calligraphy {
    color: var(--crimson, #8b0000);
    opacity: 0.06;
}
.fallback-icon {
    font-size: 2.2rem;
    color: var(--gold, #d4af37);
    opacity: 0.6;
    float: left;
    margin-right: 16px;
    margin-top: 4px;
}
.traditional-book-theme .fallback-icon {
    color: var(--crimson, #8b0000);
}
.fallback-content h5 {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.05rem;
    margin: 0 0 8px 0;
    color: var(--text-primary);
}
.fallback-content p {
    font-size: 0.85rem;
    line-height: 1.6;
    margin: 0;
    opacity: 0.75;
}

/* Navigation lock for privacy portal */
.nav-btn.nav-locked {
    position: relative;
    opacity: 0.55;
}
.nav-btn.nav-locked::after {
    content: '\f023'; /* FontAwesome lock icon code */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 0.72rem;
    color: var(--crimson);
    text-shadow: 0 0 2px rgba(0,0,0,0.8);
}
.nav-btn.nav-locked:hover {
    color: var(--crimson) !important;
    background: rgba(139, 0, 0, 0.1) !important;
    border-color: var(--crimson) !important;
}

/* Floating Heritage Verification Lock Badge */
.floating-gate-badge {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 10px rgba(212, 175, 55, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: badge-pulse 2s infinite alternate;
}
.floating-gate-badge i {
    font-size: 1.3rem;
    color: #000;
    margin-bottom: 2px;
}
.floating-gate-badge span {
    font-size: 0.65rem;
    font-weight: 800;
    color: #000;
    letter-spacing: 0.5px;
    font-family: var(--font-ui);
}
.floating-gate-badge:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.6), 0 0 20px rgba(212, 175, 55, 0.8);
}
@keyframes badge-pulse {
    0% {
        box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 10px rgba(212, 175, 55, 0.4);
    }
    100% {
        box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 25px rgba(212, 175, 55, 0.9);
    }
}
