figure {
    border: none;
    padding: 15px;
    margin: auto;
}

figcaption {
    font-style: italic;
    padding: 2px;
    text-align: center;
}

#selected-node-text sup {
    user-select: none;
    vertical-align: baseline;
    position: relative;
    top: -0.7em;
    font-size: 60%;
    line-height: 1;
    margin-right: -0.3em;
}

.flex-container {
    display: flex;
    justify-content: center;
    flex-grow: 1;
    /* Make sure the flex-container can scroll if its content overflows */
    overflow-y: auto;
}

#overview-panel {
    width: 22%;
    min-width: 240px;
    max-width: 360px;
    border-right: 1px solid #e0e0e0;
    padding: 12px 16px;
    overflow-y: auto;
    background: #fafafa;
}

.nav-title {
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 10px;
    color: #444;
}

#nav-panel {
    width: 22%;
    min-width: 240px;
    max-width: 360px;
    border-left: 1px solid #e0e0e0;
    padding: 12px 16px;
    overflow-y: auto;
    background: #fafafa;
}

.nav-arrows {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}

.overview-title {
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 10px;
    color: #444;
}

.overview-branch summary {
    cursor: pointer;
    list-style: none;
    padding: 4px 0;
}

.overview-branch summary::-webkit-details-marker {
    display: none;
}

.overview-branch summary::before {
    content: "▸";
    display: inline-block;
    width: 14px;
    margin-right: 6px;
    color: #666;
    transition: transform 0.15s ease-in-out;
}

.overview-branch[open] summary::before {
    transform: rotate(90deg);
}

.overview-children {
    margin-left: 18px;
    border-left: 1px dashed #d6d6d6;
    padding-left: 10px;
}

.overview-leaf {
    display: block;
    width: 100%;
    background: none;
    border: none;
    padding: 4px 0;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: #222;
}

.overview-leaf:hover,
.overview-branch summary:hover {
    color: #000;
}

.content-panel {
    flex: 1;
    min-width: 0;
}

@media (orientation: portrait) {
    .flex-container {
        flex-direction: column;
    }

    #overview-panel {
        width: 100%;
        max-width: none;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        max-height: 40vh;
    }

    #nav-panel {
        width: 100%;
        max-width: none;
        border-left: none;
        border-top: 1px solid #e0e0e0;
    }

    #selected-node-text {
        overflow-y: visible; /* Ensures scrollbar appears if content overflows */
        flex-grow: 1;
        font-size: 18px;
        line-height: 2;
        padding: 10px 30px;
    }
}

@media (orientation: landscape) {
    body {
        margin: 0;
        overflow-y: auto; /* Prevents body scrolling in landscape */
    }

    .flex-container {
        flex-direction: row;
        /* Removed overflow: hidden to allow for internal scrolling */
    }

    #selected-node-text {
        overflow-y: auto; /* Allows for a vertical scrollbar */
        font-size: 18px;
        line-height: 1.75;
        padding: 0 6%;
        font-family: 'Raleway', sans-serif;
    }
}

body {
    font-family: 'Raleway', sans-serif;
}
