body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    padding-left: 20px;
    text-align: center;
    background-color: #f4f4f4;
}

h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 24px;
}

#disclaimer-message {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    padding: 8px 16px;
    margin: 10px auto 20px;
    max-width: 800px;
    font-size: 13px;
    color: #856404;
    text-align: center;
}

/* Toolbar with expand/collapse buttons */
#toolbar {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

#toolbar button {
    padding: 6px 16px;
    font-size: 13px;
    border: 1px solid #999;
    border-radius: 4px;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: background 0.2s;
}

#toolbar button:hover {
    background: #e8e8e8;
}

#toolbar button.primary {
    background: #1a73e8;
    color: #fff;
    border-color: #1a73e8;
}

#toolbar button.primary:hover {
    background: #1557b0;
}

/* Breadcrumb trail */
#breadcrumb {
    font-size: 13px;
    color: #666;
    min-height: 22px;
    margin-bottom: 8px;
    padding: 2px 0;
}

#breadcrumb span {
    color: #999;
    margin: 0 4px;
}

#breadcrumb .crumb {
    color: #555;
    cursor: pointer;
}

#breadcrumb .crumb:hover {
    color: #1a73e8;
}

#breadcrumb .crumb:last-child {
    font-weight: bold;
    color: #333;
}

#breadcrumb .crumb-ellipsis {
    color: #aaa;
    margin: 0 2px;
    font-size: 11px;
}

/* Container for the SVG */
#tree-container {
    width: 100%;
    height: calc(100vh - 140px);
    overflow: hidden;
    border: 1px solid #ccc;
    background-color: #fff;
}

/* General node styling (rectangles) */
.node rect {
    stroke: #666;
    stroke-width: 2px;
    cursor: pointer;
    transition: stroke 0.2s, stroke-width 0.2s;
}

/* Hover highlight */
.node:hover rect {
    stroke: #1a73e8;
    stroke-width: 3px;
}

.node:hover text {
    fill: #1a73e8;
}

/* Line styling */
.link {
    fill: none;
    stroke: #aaa;
    stroke-width: 1.5px;
}

/* Text styling */
.node text {
    font-size: 12px;
    fill: #333;
    pointer-events: none;
}

/* Style for nodes that are currently collapsed (clickable parents) */
.node--collapsed rect {
    stroke: #3399cc;
    stroke-width: 2.5px;
}

/* People group cloud nodes */
.node--group rect {
    stroke: #888;
    stroke-width: 1.5px;
    stroke-dasharray: 4,3;
    fill: #f0f4ff;
    rx: 20;
    ry: 20;
}

.node--group:hover rect {
    stroke: #4a90d9;
    stroke-width: 2.5px;
    fill: #e3edfa;
}

.node--group .group-label {
    font-size: 10px;
    fill: #666;
    font-style: italic;
}

.node--group .group-region {
    font-size: 9px;
    fill: #999;
}

.node--group .group-haplo {
    font-size: 9px;
    fill: #7baaf7;
    font-weight: bold;
}

/* Collapsed people group: keep dashed style but brighter fill */
.node--collapsed.node--group rect {
    stroke: #6ab0e8;
    stroke-width: 2px;
    stroke-dasharray: 4,3;
    fill: #e8f0ff;
}

/* Style for the visual indicator (+) */
.indicator {
    font-size: 18px;
    font-weight: bold;
    fill: #3399cc;
    display: none;
    pointer-events: none;
}

/* Show the indicator ONLY when the node is collapsed */
.node--collapsed .indicator {
    display: block;
}

/* Era band labels */
.era-label {
    font-size: 11px;
    fill: #888;
    pointer-events: none;
    font-style: italic;
}

/* Person detail tooltip */
#person-tooltip {
    display: none;
    position: fixed;
    z-index: 2000;
    background: #fff;
    border: 1px solid #bbb;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    max-width: 340px;
    min-width: 200px;
    padding: 0;
    font-size: 13px;
    color: #333;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

#person-tooltip.visible {
    opacity: 1;
}

#person-tooltip.pinned {
    pointer-events: auto;
    box-shadow: 0 6px 24px rgba(0,0,0,0.25);
    border-color: #1a73e8;
}

#tooltip-header {
    background: #f0f4f8;
    padding: 10px 14px 8px;
    border-bottom: 1px solid #e0e0e0;
    border-radius: 6px 6px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    cursor: grab;
}

#tooltip-header:active {
    cursor: grabbing;
}

#tooltip-name {
    font-size: 15px;
    font-weight: bold;
    color: #1a1a1a;
    margin: 0;
    line-height: 1.3;
}

#tooltip-close {
    display: none;
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 0 0 0 8px;
    line-height: 1;
}

#tooltip-close:hover {
    color: #333;
}

#person-tooltip.pinned #tooltip-close {
    display: block;
}

#tooltip-body {
    padding: 10px 14px 12px;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
}

#tooltip-body::-webkit-scrollbar {
    width: 6px;
}

#tooltip-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

#tooltip-body::-webkit-scrollbar-track {
    background: transparent;
}

#tooltip-body .tip-row {
    margin-bottom: 6px;
    line-height: 1.4;
}

#tooltip-body .tip-label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: block;
    margin-bottom: 1px;
}

#tooltip-body .tip-value {
    font-size: 13px;
    color: #333;
}

#tooltip-body .tip-value.alternate {
    color: #555;
    font-style: italic;
}

#tooltip-body .tip-sources {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
    font-size: 11px;
    color: #999;
}

#tooltip-body .tip-sources span {
    display: inline-block;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    margin: 2px 3px 2px 0;
    font-size: 10px;
}

/* Drag-and-drop reparenting states */
.node.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.node.drag-over rect {
    stroke: #ff9800;
    stroke-width: 4px;
}

/* Right-click context menu */
#context-menu {
    display: none;
    position: fixed;
    background: #fff;
    border: 1px solid #bbb;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 180px;
    font-size: 13px;
}

#context-menu .ctx-item {
    padding: 8px 14px;
    cursor: pointer;
    color: #333;
}

#context-menu .ctx-item:hover {
    background: #e8f0fe;
    color: #1a73e8;
}

#context-menu .ctx-separator {
    border-top: 1px solid #ddd;
    margin: 2px 0;
}

/* Inline name input for adding a child */
#add-child-form {
    display: none;
    padding: 8px 10px;
}

#add-child-form input {
    width: 100%;
    box-sizing: border-box;
    padding: 4px 6px;
    border: 1px solid #999;
    border-radius: 3px;
    font-size: 12px;
    margin-bottom: 6px;
}

#add-child-form .form-buttons {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

#add-child-form .form-buttons button {
    padding: 3px 10px;
    font-size: 11px;
    border: 1px solid #999;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
}

#add-child-form .form-buttons button.primary {
    background: #1a73e8;
    color: #fff;
    border-color: #1a73e8;
}

/* Sources/Bibliography Sidebar */
#sources-sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    width: 300px;
    height: 100vh;
    background: #fff;
    border-right: 1px solid #ddd;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    transition: left 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
}

#sources-sidebar.visible {
    left: 0;
}

#sources-sidebar .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #ddd;
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 1;
}

#sources-sidebar .sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

#sources-sidebar #close-sidebar {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

#sources-sidebar #close-sidebar:hover {
    color: #333;
}

#sources-list {
    padding: 20px;
}

.source-category {
    margin-bottom: 25px;
}

.source-category h4 {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin: 0 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 2px solid #1a73e8;
}

.source-category ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.source-category li {
    padding: 6px 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.source-category li:before {
    content: "•";
    color: #1a73e8;
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
}

/* Era labels within SVG */
.era-label-name {
    font-weight: 600;
    color: #333;
    letter-spacing: 0.3px;
    pointer-events: none;
}

.era-label-date {
    font-size: 10px;
    color: #777;
    pointer-events: none;
}
