:root {
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --line-color: #ccc;
    --primary-color: #007bff;
    --text-primary: #333;
    --card-shadow: 0 4px 6px rgba(0,0,0,0.1);
    --border-radius: 8px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 20px;
}

/* Tree Container */
.tree-wrapper {
    overflow-x: auto; /* Allow horizontal scroll for large trees */
    padding: 20px;
    text-align: center;
}

/* The Root UL */
.tree, .tree ul, .tree li {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

.tree {
    display: inline-flex;
    padding-top: 20px;
}

.tree ul {
    display: flex;
    padding-top: 20px;
}

/* The Item (Node) */
.tree li {
    float: left; 
    text-align: center;
    padding: 20px 5px 0 5px;
    position: relative;
}

/* CONNECTORS: The logic to draw lines between parent and children */

/* Vertical line above the node */
.tree li::before, .tree li::after {
    content: '';
    position: absolute; 
    top: 0; 
    right: 50%;
    border-top: 2px solid var(--line-color);
    width: 50%; 
    height: 20px;
}

.tree li::after {
    right: auto; 
    left: 50%;
    border-left: 2px solid var(--line-color);
}

/* Remove connectors for single children or edges */
.tree li:only-child::after, .tree li:only-child::before {
    display: none;
}

.tree li:only-child { 
    padding-top: 0;
}

.tree li:first-child::before, .tree li:last-child::after {
    border: 0 none;
}

/* Adding the vertical connector from the parent down to the children UL */
.tree li:last-child::before {
    border-right: 2px solid var(--line-color);
    border-radius: 0 5px 0 0;
}

.tree li:first-child::after {
    border-radius: 5px 0 0 0;
}

.tree ul::before {
    content: '';
    position: absolute; 
    top: 0; 
    left: 50%;
    border-left: 2px solid var(--line-color);
    width: 0; 
    height: 20px;
}

/* CARD STYLING */
.node-card {
    border: 1px solid #ddd;
    background: var(--card-bg);
    padding: 15px;
    display: inline-block;
    border-radius: var(--border-radius);
    text-decoration: none;
    transition: all 0.3s;
    box-shadow: var(--card-shadow);
    min-width: 120px;
    position: relative;
    z-index: 2; /* Keep above lines */
}

.node-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.15);
    border-color: var(--primary-color);
}

.node-role {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-top: 5px;
}

.node-name {
    font-weight: bold;
    color: var(--text-primary);
}

/* Toggle Button Styling */
.toggle-btn {
    cursor: pointer;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: block;
    margin: 5px auto 0;
    font-size: 12px;
    line-height: 20px;
    border: none;
}

/* Hidden State */
.hidden {
    display: none !important;
}