/*
 * Agency nodes at depth 2+: force the level-1 "main branch" style.
 * Level-1 nodes (me-main > me-wrapper > me-parent > me-tpc) have no me-children
 * ancestor and are already styled correctly by mind-elixir. Deeper nodes sit inside
 * me-children and need to match: white bg, 2px border, 20px radius, 8px 25px padding.
 * Excludes channels (mech_) and external parents (meext_) which have their own styles.
 */
me-children me-tpc:not([data-nodeid^="mech_"]):not([data-nodeid^="meext_"]) {
    border-radius: 20px !important;
    background-color: #ffffff !important;
    border: 2px solid #444446 !important;
    color: #444446 !important;
    padding: 8px 25px !important;
    font-size: 15px !important;
    font-weight: normal !important;
}

/*
 * Channel nodes use the ch_ ID prefix, which becomes data-nodeid="mech_*" on me-tpc.
 * !important overrides mind-elixir's depth-based rules (main-branch border/radius,
 * deeper-node padding) so channels look identical at every level of the tree.
 */
me-tpc[data-nodeid^="mech_"] {
    border-radius: 3px !important;
    border: 1px dashed #0369a1 !important;
    background: #e0f2fe !important;
    color: #0369a1 !important;
    padding: 4px 10px !important;
    font-size: 13px !important;
    font-weight: normal !important;
}

/*
 * Virtual root node: the hidden parent used when external parents exist.
 * Hide the topic label, its connecting lines, and the expand/collapse button.
 *
 * me-root > me-tpc is the root node topic. me-nodes > svg.lines draws the
 * bezier paths from root to each level-1 child. Both must be hidden.
 */
.has-virtual-root me-root me-tpc {
    opacity: 0 !important;
    pointer-events: none !important;
    padding: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    width: 0 !important;
    height: 0 !important;
    border: none !important;
}

.has-virtual-root me-nodes > svg.lines {
    display: none !important;
}

.has-virtual-root me-root me-epd {
    display: none !important;
}

/*
 * Toggle: hide external parent nodes and all arrows when .hide-external is active.
 * :has() targets the entire me-wrapper containing an external node so no ghost space remains.
 */
.hide-external me-main > me-wrapper:has(me-tpc[data-nodeid^="meext_"]) {
    display: none !important;
}

.hide-external svg.topiclinks {
    display: none !important;
}

/*
 * External parent nodes use the ext_ ID prefix.
 * Styled with a red-toned dashed border to indicate they are outside the main tree.
 */
me-tpc[data-nodeid^="meext_"] {
    border-radius: 3px !important;
    border: 1px dashed #dc2626 !important;
    background: #fef2f2 !important;
    color: #dc2626 !important;
    padding: 4px 10px !important;
    font-weight: normal !important;
}
