header#titles {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: fit-content;
    max-height: fit-content;
    position: relative;
    width: 80%;
    .search-dropdown {
        position: absolute;
        width: 20rem;
        right: 1rem;
        left: auto;
        .search-btn {
            width: 8rem;
            margin-left: auto;
        }
    }
    nav {
        padding: 0;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 1rem;
        margin: 0;
        ol {
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            justify-content: center;
            align-items: center;
            width: 80%;
            padding: 0;
            margin: 0;
            font-size: 1.25rem;
            list-style-type: none;
        }
        li {
            display: inline;
        }
        ol li:not(:last-child)::after {
            content: " >> ";
            color: #666;
            font-weight: 200;
            margin-right: 0.25rem;
        }
        ol a {
            display: inline;
            margin: 0 0.25rem;
            text-decoration: none;
            color: var(--blue);
        }

        ol a:hover {
            color: var(--btn-bg);
            text-decoration: underline;
        }
    }
}

main#codes > *, main#results > * {
    width: 80%;
    box-sizing: border-box;
    margin-bottom: 0;
    /* padding-left: 0; */
}

dl#units, dl#sections, dl#codes {
    background-color: color-mix(in srgb, var(--bg-dark), var(--bg));
    padding: 1.5rem 2rem;
    padding-left: 2rem;
    margin-top: 0;
    padding-top: 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: start;
    align-items: start;
    span {
        display: grid;
        grid-template-columns: max-content 1fr;
        grid-auto-rows: 1fr;
    }
    dt, dd {
        margin-top: 0.2rem;
        font-size: 1.1rem;
        box-sizing: border-box;
        /* min-height: 1.5rem; */
    }
    dt {
        display: flex;
        flex-direction: row;
        justify-content: start;
        align-items: center;
        font-weight: normal;
        padding-right: 0.5rem;
        min-width: 8rem;
        a {
            display: inline;
            font-size: 1em;
            color: var(--blue);
            text-decoration: none;
            background-color: transparent;
            padding: 0;
            margin: 0;
        }
        a:hover {
            color: var(--btn-bg);
            text-decoration: underline;
            background-color: transparent;
        }
    }

    /* This monster of a selector basically gets all dt/dd of a lower depth than the row preceding it */
    dd.depth-2 + dt.depth-1,
    dd.depth-2 + dt.depth-1 + dd.depth-1,
    dd.depth-3 + dt.depth-2,
    dd.depth-3 + dt.depth-2 + dd.depth-2,
    dd.depth-4 + dt.depth-3,
    dd.depth-4 + dt.depth-3 + dd.depth-3 {
        margin-top: 1rem;
    }

    dt.depth-1 {
        font-weight: bold;
    }

    dt.depth-2 {
        font-weight: normal;
        padding-left: 1rem;
    }

    dt.depth-3, dt.depth-4, dt.depth-5 {
        padding-left: 2rem;
    }

    dd {
        display: flex;
        flex-direction: row;
        /* padding-left: 0; */
        margin-left: 0;
        justify-content: start;
        align-items: center;
        align-self: stretch;
        /* margin-inline-start: 0; */
        em {
            padding-left: 0.5rem;
            font-size: 0.7em;
            color: var(--text-label);
            font-style: normal;
        }
        a.view-all, button.edit {
            font-weight: normal;
            display: flex;
            flex-direction: row;
            justify-content: right;
            align-items: center;
            position: relative;
            text-decoration: none;
            width: fit-content;
            align-self: center;
            padding: 0;
            margin: 0;
            margin-left: 1rem;
            padding-left: 0.625rem;
            padding-right: 1.25rem;
            background-color: var(--bg-dark);
            border: 1px solid black;
            font-size: .8rem;
            height: 1.25rem;
            max-height: 1.25rem;
            border-radius: 0.625rem;
            box-sizing: border-box;
            color: var(--text)
        }
        a.view-all:hover, button.edit:hover {
            background-color: var(--btn-bg);
            border: 1px solid var(--btn-bg);
            color: var(--bg-dark);
        }
        a.view-all::after {
            content: '\003E';
            position: absolute;
            right: 0.625rem;
            top: 50%;
            transform: translateY(-50%);
        }
    }
}

dl:has(.depth-2) dt.depth-1, dl:has(.depth-2) dd.depth-1 {
    margin-top: 1rem;
}

dl:has(.depth-3) dt.depth-2 {
    font-weight: bold !important;
}

dl#codes {
    display: block;
}

*:has(+ div#edit-div) {
    padding-bottom: 0;
    margin-bottom: 0;
}

div#edit-div {
    padding: 0.5rem 2rem;
    padding-left: 0;
    background-color: color-mix(in srgb, var(--bg-dark), var(--bg));
    width: 80%;
    margin-top: 0;
    padding-top: 1rem;
    padding-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    a.add-btn {
        width: 90%;
        height: 2rem;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        gap: 1rem;
        margin-left: 0;
        grid-template-columns: 2rem 1fr;
        padding: 0.25rem 2rem;
        padding-left: 0.5rem;
        background-color: var(--bg-dark);
        border-radius: 0.25rem;
        font-size: 1.1rem;
        border: 1px solid var(--text);
        box-sizing: border-box;
        color: var(--text);
        .button-icon-height {
            height: 90%;
        }
    }
    a.add-btn:hover {
        background-color: var(--btn-bg);
        border-color: var(--btn-bg);
        color: var(--bg-dark);
    }
}

article.small-overlay {
    form {
        flex-grow: 1;
        height: 100%;
        width: 100%;
        span {
            width: 100%;
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 1rem;
            gap: 1rem;
        }
        select,
        ::picker(select) {
            font-size: 1.25rem;
            border: 1px solid var(--bg);
            box-shadow: 4px 4px 0 var(--box-shadow);
            background-color: var(--bg-dark);
            flex: 1;
            vertical-align: middle;
            padding: 0.5rem;
            box-sizing: border-box;
            border-radius: 0;
        }
        select {
            height: 2rem;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        p {
            white-space: wrap;
            font-size: 1rem;
            font-style: italic;
            text-align: center;
            padding: 0;
            margin: 0;
        }
        div {
            max-width: 40%;
        }

        select,
        ::picker(select) {
            /* font-size: 1.5rem; */
            appearance: base-select;
        }

        ::picker(select) {
            /* line-height: 2rem; */
            padding-left: 0.5rem !important;
        }
        label, h4 {
            font-size: 1.25rem;
            font-weight: bold;
        }
        h4 {
            text-align: center;
            padding: 0;
            margin: 0;
            margin-top: 0.5rem;
        }
        input[type="text"] {
            height: 2rem;
            font-size: 1rem;
            border: 1px solid var(--bg);
            box-shadow: 4px 4px 0 var(--box-shadow);
            background-color: var(--bg-dark);
            flex: 1;
            padding: 0.5rem;
            box-sizing: border-box;
        }
        textarea {
            font-family: 'Roboto', sans-serif;
            font-size: 1rem;
            border: 1px solid var(--bg);
            white-space: pre-wrap;
            box-shadow: 4px 4px 0 var(--box-shadow);
            background-color: var(--bg-dark);
            flex: 1;
            padding: 0.5rem;
            box-sizing: border-box;
        }
        ul {
            box-shadow: 4px 4px 0 var(--box-shadow);
            background-color: var(--bg-dark);
            border: 1px solid var(--bg);
            list-style-type: none;
            font-size: 1rem;
            flex: 1;
            max-height: 10rem;
            padding-left: 0;
            overflow-y: scroll;
            li {
                margin-left: 0;
                padding: 0.25rem 0.5rem;
                cursor: pointer;
            }
            li:hover {
                background-color: var(--btn-bg);
                color: var(--bg-dark);
            }
        }
    }
}

#sh-span {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    background-color: color-mix(in srgb, var(--bg-dark), var(--bg));
    padding-top: 1rem;
    gap: 1rem;
    h3#sub-header {
        margin: 0;
        padding: 0;
        /* width: 80%; */
        height: fit-content;
        max-height: min-content;
        text-align: center;
        font-size: 1.5rem;
        box-sizing: border-box;
    }
    a.view-all, button.edit {
        font-weight: normal;
        text-decoration: none;
        position: relative;
        display: flex !important;
        flex-direction: row !important;
        justify-content: right !important;
        align-items: center !important;
        /* transform: translateY(-50%); */
        width: fit-content;
        align-self: center;
        padding: 0;
        padding-left: 0.625rem;
        padding-right: 1.5rem;
        background-color: var(--bg-dark) !important;
        border: 1px solid black;
        height: 1.5rem;
        max-height: 1.5rem;
        line-height: 1;
        font-size: 0.9rem !important;
        border-radius: 0.625rem;
        color: var(--text) !important;
    }
    button.edit {
        padding-right: 0.625rem;
        cursor: pointer;
    }
    a.view-all:hover, button.edit:hover {
        background-color: var(--btn-bg) !important;
        border: 1px solid var(--btn-bg) !important;
        color: var(--bg-dark) !important;
    }
    a.view-all::after {
        content: '\003E';
        position: absolute;
        right: 0.625rem;
        top: 50%;
        transform: translateY(-50%);
    }
}

#all-sections, .section-text {
    a.section-link {
        font-size: 1em;
        display: inline;
        margin: 0;
        padding: 0;
        background-color: transparent;
        text-decoration: none;
        color: var(--blue);
    }
    a.section-link:hover {
        color: var(--btn-bg);
        background-color: transparent;
        text-decoration: underline;
    }
}

.section-text {
    padding: 1.5rem 2rem;
    padding-top: 0;
    margin-top: 0;
    background-color: color-mix(in srgb, var(--bg-dark), var(--bg));
    font-size: 1.1rem;
    text-align: left;
    white-space: pre-wrap;
    p {
        margin-top: 0;
    }
    p:first-child {
        margin-top: 0.2rem;
    }
    p:last-child {
        margin-bottom: 0;
    }
}

div#all-sections {
    padding: 1.5rem 2rem;
    padding-top: 0;
    margin-top: 0;
    background-color: color-mix(in srgb, var(--bg-dark), var(--bg));
    h3, h4, h5, h6 {
        margin-top: 0;
        margin-bottom: 0;
    }
    h3 {
        font-size: 1.4rem;
    }
    h4 {
        font-size: 1.25rem;
    }
    h5 {
        font-size: 1.1rem;
    }
    h6, p {
        font-size: 1rem;
    }
    p:has(strong) {
        margin: 0;
        padding: 0;
    }
    p {
        margin-top: 0;
    }
}

main#codes, main#results {
    display: flex;
    flex-direction: column;
    justify-content: start;
    align-items: center;
    gap: 0;
}

main#results {
    ul {
        list-style-type: none;
        background-color: color-mix(in srgb, var(--bg-dark), var(--bg));
        padding: 1.5rem 2rem;
        padding-left: 2rem;
        margin-top: 0;
        padding-top: 0.5rem;
        li {
            margin-bottom: 1rem;
            font-size: 1rem;
            a {
                text-decoration: none;
            }
            h3 {
                font-weight: bold;
                font-size: 1rem;
                padding: 0;
                margin: 0;
                a {
                    color: var(--blue);
                }
                a:hover {
                    text-decoration: underline;
                }
            }
            & > a {
                font-size: 1rem;
                color: var(--text-label);
            }
            & > a:hover {
                text-decoration: underline;
            }
            p {
                padding: 0;
                margin: 0;
            }
        }
    }
}


@media screen and (max-width: 768px) {
    main {
        width: 100%;
        padding: 0 0;
        margin: 0 0;
        box-sizing: border-box;
        overflow-y: auto;
        overflow-x: hidden;
    }
    dl#units, dl#sections, dl#codes {
        span {
            grid-template-columns: minmax(6rem, max-content) 1fr;
        }
        dt {
            /* min-width: 6rem;
            width: fit-content;
            max-width: 75%; */
            white-space: wrap;
        }
        dd {
            justify-content: start;
            a.view-all {
                white-space: nowrap;
            }
        }
    }
    header#titles {
        width: 100%;
        .search-dropdown {
            right: 1rem;
            position: absolute;
            display: inline-block;
            text-align: right;

            .search-btn {
                width: 2rem;
                padding: 0.25rem !important;
            }

            #searchInput {
                position: absolute;
                right: 0;
                top: 100%;
                width: 80vw;
            }
        }
    }
    main > * {
        width: 100% !important;
        margin-left: 0;
        margin-right: 0;
    }
}