body {
    font-family: sans-serif;
    background-color: #f4f4f9;
    margin: 0;
    padding: 40px;
    overflow: auto;
}

#canvas {
    display: flex;
    align-items: flex-start;
}

/* --- Tree Line Formatting --- */
.branch {
    display: flex;
    align-items: flex-start;
    position: relative;
    padding-left: 20px; /* Space for the horizontal line */
    margin: 10px 0;
}

/* Draws the horizontal line from the spine to the text box */
.branch::before {
    content: '';
    position: absolute;
    left: 0;
    top: 22px; /* Aligns with middle of a single-line text box */
    width: 20px;
    border-top: 2px solid #999;
}

/* Hide incoming lines for the root */
#root { padding-left: 0; margin-top: 0; }
#root::before { display: none; }

/* The vertical spine connecting sibling branches */
.children {
    display: flex;
    flex-direction: column;
    border-left: 2px solid #999; 
    margin-left: 0px; 
    padding-left: 0;
}

/* --- Node Formatting --- */
.node-container {
    position: relative;
    display: flex;
    align-items: center;
}

.node {
    min-width: 100px;
    min-height: 24px;
    padding: 10px;
    background-color: #ffffff;
    border: 2px solid #333;
    border-radius: 8px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    outline: none;
    z-index: 2;
    cursor: text;
    white-space: pre-wrap; /* Keeps text formatting nice */
}

.node:focus {
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.2);
}

/* --- Hover Buttons (Arrows) --- */
.controls {
    display: none;
    position: absolute;
    top: -15px;
    right: -10px;
    gap: 5px;
    z-index: 10;
}

/* Show buttons when hovering over the container */
.node-container:hover .controls {
    display: flex;
}

.btn-add {
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px 5px;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: background 0.2s;
}

.btn-add:hover {
    background: #e0f0ff;
    border-color: #0066cc;
}