ul.fancytree-container {
    padding-inline-start: 0;
}

ul.fancytree-container li {
    list-style: none;
}

span.fancytree-node.fancytree-hide {
    display: none;
}

.fancytree-title {
    flex-basis: 0; /* to allow shrinking text to make space for buttons */
    flex-shrink: 1;
    flex-grow: 1;
    overflow: hidden;
    margin-inline-start: 7px;
    outline: none;
}

.fancytree-expander {
    visibility: hidden;
}

.fancytree-folder .fancytree-expander {
    visibility: visible;
}

.fancytree-node {
    display: flex;
    align-items: center;
    height: 38px;
    padding: 4px;
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    user-select: none !important;
    -webkit-user-select: none !important;
    color: var(--custom-color, inherit);
}

.fancytree-node:not(.fancytree-loading) .fancytree-expander {
    background: none;
    height: auto;
    text-align: center;
}

.fancytree-node:not(.fancytree-loading) .fancytree-expander:before {
    font-family: "boxicons" !important;
    content: "\ea50"; /* lookup code for "chevron-right" in boxicons.css */
    speak: none;
    font-size: x-large;
    text-transform: none;
    line-height: 1;
    position: relative;
    top: 2px;
    margin-inline-end: 5px;
}

body[dir=rtl] .fancytree-node:not(.fancytree-loading):not(.fancytree-expanded) .fancytree-expander:before {
    content: "\ea4d";   /* bx bx-chevron-left */
}

.fancytree-loading span.fancytree-expander {
    background-image: none;
    display: inline-block;
    width: 16px;
    height: 16px;
    margin: 4px 8px 2px 5px;
}

.fancytree-loading span.fancytree-expander:after {
    content: " ";
    color: inherit !important;
    display: block;
    border-radius: 50%;
    border-color: var(--main-text-color) transparent var(--main-text-color) transparent;
    animation: lds-dual-ring 1.2s linear infinite;
    width: 12px;
    height: 12px;
    margin-top: 2px;
    margin-inline-start: 1px;
    border-width: 1px;
    border-style: solid;
}

@keyframes lds-dual-ring {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

ul.fancytree-container li {
    contain: layout paint;
}

/* this is done to preserve correct indentation. Better solution would be preferable */
.fancytree-node:not(.fancytree-folder) .fancytree-expander:before {
    color: var(--main-background-color); /* setting to background color makes this invisible */
}

.fancytree-node.fancytree-expanded .fancytree-expander:before {
    font-family: "boxicons" !important;
    content: "\ea4a"; /* lookup code for "chevron-down" in boxicons.css */
}

/** some common text styling for cssClass label */
span.fancytree-node.underline .fancytree-title {
    text-decoration: underline;
}
span.fancytree-node.dotted .fancytree-title {
    text-decoration: dotted;
}
span.fancytree-node.bold .fancytree-title {
    font-weight: bold;
}
span.fancytree-node.muted {
    opacity: 0.6;
}

/** following will hide ancestors of hoisted (filtered) note */
.fancytree-submatch:not(.fancytree-match) {
    display: none !important;
}

/** resets indent of hoisted note */
.fancytree-submatch:not(.fancytree-match) + ul {
    padding: 0 !important;
}

ul.fancytree-container {
    outline: none;
    background-color: inherit;
}


.fancytree-custom-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 1em;
    height: 1em;
    font-size: 1.2em;
}

/* Fallback icon */
:where(.fancytree-custom-icon)::before {
    content: "?";
}

/* Protected note icon badge */
span.fancytree-node.protected > span.fancytree-custom-icon {
    filter: drop-shadow(2px 2px 2px var(--main-text-color));
}

/* Note indicator icons (clone, shared) - real DOM elements for tooltip support */
.note-indicator-icon {
    font-family: "boxicons" !important;
    font-size: smaller;
    margin-inline-start: 4px;
    opacity: 0.8;
    cursor: help;
}

.note-indicator-icon.clone-indicator::before {
    content: "\eb3d"; /* bx-link-alt */
}

.note-indicator-icon.shared-indicator::before {
    content: "\ec03"; /* bx-share-alt */
}

body.experimental-feature-new-layout .note-indicator-icon.clone-indicator::before {
    content: "\ed82";
    opacity: 0.5;
}

span.fancytree-node.fancytree-active-clone:not(.fancytree-active) .fancytree-title {
    font-weight: bold;
}

/* first nesting level has lower left padding to avoid extra left padding. Other levels are not affected */
.ui-fancytree > li > ul {
    padding-inline-start: 5px;
}

.ui-fancytree ul {
    padding-inline-start: 20px;
}

span.fancytree-active {
    color: var(--active-item-text-color);
    background-color: var(--active-item-background-color);
    border-color: transparent; /* invisible border */
    border-radius: 5px;
}

span.fancytree-active .fancytree-title {
    font-weight: bold;
    border: 0;
}

span.fancytree-node.fancytree-selected {
    background-color: var(--selection-background-color);
    border-radius: 0;
}

span.fancytree-selected .fancytree-custom-icon::before {
    font-family: "boxicons";
    content: "\ef05";
    border: 1px solid var(--main-text-color);
    border-radius: 3px;
}

span.fancytree-node:hover {
    border: 1px solid var(--main-border-color);
}

span.fancytree-node.fancytree-menu-target {
    box-shadow: inset 0 0 0 1px var(--main-border-color);
}

.fancytree-title:hover,
span.fancytree-node:hover .fancytree-title {
    border: 0;
}

span.fancytree-node.archived {
    opacity: 0.6;
}

.fancytree-node:hover .tn-icon.tree-item-button {
    display: inline-block;
}

.tn-icon.tree-item-button {
    display: none;
    font-size: 120%;
    cursor: pointer;
    margin-inline-start: 8px;
    padding: 1px;
    border: 1px solid transparent;
    border-radius: 5px;
}

.unhoist-button.tn-icon.tree-item-button {
    margin-inline-start: 0; /* unhoist button is on the left and doesn't need more margin */
    display: block; /* keep always visible */
}

.tree-item-button:hover {
    border: 1px dotted var(--main-text-color);
}

.add-note-button {
    display: none;
}

span.fancytree-node:hover .add-note-button {
    display: inline-block;
}

.fancytree-drop-accept {
    border: 1px solid var(--main-border-color);
}

#fancytree-drop-marker.fancytree-drop-after,
#fancytree-drop-marker.fancytree-drop-before {
    width: 100px;
    /* marker is by default position: relative which doesn't make sense */
    position: absolute !important;
    /* heaving a height helps with positioning since the algorithm calculating "top" takes it into account */
    height: 19px;
}

#fancytree-drop-marker.fancytree-drop-after {
    border-bottom: 1px solid var(--muted-text-color);
}

#fancytree-drop-marker.fancytree-drop-before {
    border-top: 1px solid var(--muted-text-color);
}
