html,
body {
    height: 100%;
}

body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}


main {
    width: 100%;
    max-width: unset;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

em {
    font-family: SohneHalbfett;
}

#compareOptions {
    display: none;
}

body>header {
    height: auto;
    flex: 0 0 auto;
}

body>header .first {
    display: flex;
    align-items: center;
    width: 23%;
    margin-left: 1.5rem;
    border-right: solid 2px rgba(0, 0, 0, 0.2);
    max-width: 20rem;
}

body>header .main:nth-child(1) {
    width: 100%;
    padding-top: 1rem !important;
    padding-bottom: 1rem;
    max-width: unset;

}

body>header .second ul {
    font-size: 18px;
    margin-bottom: auto;
    margin-top: auto;
    max-width: 56rem;
}

body>header .first img {
    height: 57px;
}

body>header .second {
    position: relative;
    padding-right: 21%;
    width: 65%;
}

body>header .second img {
    position: absolute;
    right: 3%;
    top: -2rem;
    height: 87px;
    transform: rotate(5deg);
}

body>header .first h1 {
    font-size: 16px;
    text-align: left;
    margin-bottom: 0;
    margin-left: 0.2rem;
    width: 100%;
}


/* EDITION */
.edition {
    display: flex;
    height: 100%;
    position: relative;
}

/* CONTROL PANEL */
.control-panel {
    box-shadow: 0 4px 4px rgba(0, 0, 0, 0.27);
    width: 13rem;
    font-size: 14px;
    height: 100%;
    z-index: 1;
    user-drag: none;
    /* For Safari and older browsers */
    -webkit-user-drag: none;
    /* Chrome, Safari */
    user-select: none;
    position: absolute;
    transition: width 0.15s ease-in-out;
    background-color: white;
    overflow: clip;
}

.control-panel .closeControlPanel {
    position: absolute;
    right: 0.5rem;
    top: 0.5rem;
    cursor: pointer;
    z-index: 3;
    user-drag: none;
    /* For Safari and older browsers */
    -webkit-user-drag: none;
    /* Chrome, Safari */
}

.control-panel .closeControlPanel:hover {
    transform: translateX(-2px);
}

.control-panel.closed .closeControlPanel:hover {
    transform: rotate(180deg) translateX(-2px);
}

.control-panel.closed em {
    display: none;
}


.control-panel .innerContainer {
    margin-left: 0.75rem;
    margin-top: 1rem;
    margin-right: 0.75rem;
    transform-origin: left center;
    transition: transform 0.15s ease-in-out;
    /* scale instead of moving */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: -webkit-fill-available;
}

.control-panel .helpContainer {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-left: 0.1rem;
    margin-bottom: 0.5rem;
    border: solid 1px rgba(0, 0, 0, 0.1);
    border-radius: 1rem;
    padding: 0.2rem;
}

.control-panel .helpContainer a {
    color: black;
    font-family: SohneHalbfett;
    text-decoration: none;
    margin-left: 0.3rem;
}

.copyright {
    display: flex;
    font-family: SohneHalbfett;
    align-items: center;
    margin-bottom: 0.6rem;
    border: solid 1px rgba(0, 0, 0, 0.1);
    border-radius: 1rem;
    cursor: pointer;
    font-size: 12px;
}

.copyright:hover,
.helpContainer:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.copyright svg {
    margin-right: 0.15rem;
    margin-left: 0.2rem;
    fill: rgb(51, 51, 51)
}

#driver-popover-title {
    height: auto;
    background-color: white;
}

/* CLOSED CONTROL PANEL */
.control-panel.closed {
    width: 2rem;
}

.control-panel.closed .helpContainer {
    border: none;
}

.control-panel.closed .innerContainer .compareOptions {
    opacity: 0;
    pointer-events: none;
    /* Prevent clicks while hidden */
    transform: scaleX(0.02);
}

.control-panel.closed .copyright {
    border: none;
}

.control-panel.closed .copyright p {
    display: none;
}

.control-panel.closed .copyright svg {
    position: absolute;
    left: 0.1rem;
    bottom: 2.5rem;
    scale: 127%;
    margin-right: 0;
    margin-left: 0.15rem
}

.control-panel.closed .closeControlPanel {
    transform: rotate(180deg);
}

.control-panel.closed .helpContainer a {
    display: none;
}

.control-panel.closed .helpContainer {
    margin-left: 0;
}

.control-panel.closed .helpContainer img {
    position: absolute;
    left: 0.15rem;
    bottom: 0.3rem;
    scale: 92%;
}

/* CHAPTER SELECT */
#chapterSwitch {
    width: 100%;
    margin-top: 0.3rem;
}

#chapterSwitch option:hover {
    background-color: var(--green) !important;
}

/* ORIËNTATION SELECT */
.orientationSwitchContainer {
    margin-top: 1rem;
    width: 100%;
}

.orientationSwitchContainer select {
    width: 100%;
    margin-top: 0.3rem;
}

/* COMPARE OPTIONS */
.innerContainer>div:nth-child(1) {
    height: 87%;
    margin-top: 0.2rem;
}

.compareOptions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    height: 95%;
    overflow: auto;
    max-height: 599px;
    padding-top: 0.4rem;
}

.compareOptions img {
    height: 45px;
    width: 2rem;
    user-select: none;
    user-drag: none;
    /* For Safari and older browsers */
    -webkit-user-drag: none;
    /* Chrome, Safari */
    margin-left: 0.5rem;
}

.compareOptions .item p {
    user-drag: none;
    /* For Safari and older browsers */
    -webkit-user-drag: none;
    /* Chrome, Safari */
    margin-top: auto;
    margin-bottom: auto;
    margin-left: 0.2rem;
}

.compareOptions>p {
    margin-bottom: 0.5rem;
}

.compareOptions .item div p:first-of-type {
    font-family: 'SohneHalbfett';
    font-size: 13px;
}

.compareOptions .item {
    width: 100%;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    border: solid 1px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    user-drag: none;
    /* For Safari and older browsers */
    -webkit-user-drag: none;
    /* Chrome, Safari */
    display: flex;
}

.compareOptions .item div {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-left: 0.1rem;
}


.compareOptions .item:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.compareOptions .item.hardSelect {
    background-color: rgba(0, 0, 0, 0.04);
    cursor: not-allowed !important;
}

.compareOptions .item.horizontalSelectedVisual {
    border-left: 3px solid var(--red);
    border-width: 50%;
    box-sizing: border-box;
}

.compareOptions .desc {
    font-size: 12px;
    color: rgba(0, 0, 0, 0.8);
}

.compareOptions .item.selectAll {
    border-bottom-left-radius: 1rem;
    border-bottom-right-radius: 1rem;
}

.compareOptions .item.selectAll .desc {
    text-align: center;
    width: 100%;
}

/* VARIATIONS */
.variations {
    margin-top: 1rem
}

/* MIRADOR */
#mirador {
    width: 100%;
    position: relative;
    margin-left: -74px;
    z-index: 0;
}

.mirador-workspace-viewport div.MuiToolbar-root {
    display: block;
}

.mosaic {
    height: 101.15% !important;
    margin-top: -0.4rem;
}

.mosaic-tile,
.mosaic-window {
    border-radius: 0px !important;
}

#mirador header {
    display: block !important;
    text-align: center;
}

#mirador header h2 {
    font-family: 'SohneBuch' !important;
}

.mirador-workspace-viewport div.MuiToolbar-root {
    border-top: none !important;
}

#mirador .mosaic-tile[style="inset: 0% 0% 0% 50%;"] .mirador-osd-navigation {
    display: initial;
}

/* SEARCH */
/* SEARCH */
.search {
    width: 90%;
    margin-left: auto;
    margin-right: auto;
    max-width: 515px;
    /* grows up to here */
    min-width: 320px;
    /* safe lower bound for mobile */
}


.search .searchHits,
#searchResults,
.searchHits {
    width: 100%;
    max-width: 515px;
    margin: 0 auto;
}

@media (min-width: 1200px) {

    .search,
    .search .searchHits,
    #searchResults,
    .searchHits {
        max-width: 614px;
        /* allow more width on big screens */
    }
}



.search #search {
    width: 98%;
    padding: 0.2rem 0.5rem 0.2rem 0.5rem;
    ;
    margin-top: 0.3rem;
    border-radius: 1rem;
}

.search .searchBox {
    display: flex;
    position: relative;
}

.search #clearButton {
    position: absolute;
    right: 0.5rem;
    top: 33%;
    background: none;
    border: none;
    cursor: pointer;
}

.search .options {
    display: flex;
    margin-top: 0.4rem;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
}

.search .options label {
    margin-right: 1rem;
    cursor: pointer;
}

.search input {
    accent-color: var(--red);
    cursor: pointer;
}

.search #search {
    cursor: text;
}

.search .options div {
    display: flex;
    align-items: center;
    user-select: none;
}

.search .heading {
    border-top: solid 1px rgba(0, 0, 0, 0.2);
    border-bottom: solid 1px rgba(0, 0, 0, 0.2);
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.search .searchHits {
    margin-top: 0.5rem;
    width: 80%;
}

.search .searchHits em {
    font-size: 15px;
}

#searchResults {
    margin-top: 1rem;
    min-width: 100%;
    font-size: 15px;
}

.searchHits {
    min-width: 100%;
}

#searchResults li {
    display: flex;
    padding-left: 0.3rem;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
}

/* Even rows */
#searchResults li:nth-child(even) {
    background-color: #f9f9f9;
}

/* Odd rows */
#searchResults li:nth-child(odd) {
    background-color: #ffffff;
}

#searchResults li:hover {
    background-color: #e6f0ff;
    cursor: pointer;
}

.kwicRow {
    display: flex;
    font-family: monospace;
    white-space: pre;
    align-items: center;
    width: 98%;
    gap: 1rem;
}

.kwicText {
    display: flex;
    flex: 1 1 auto;
    overflow: hidden;
    min-width: 0;
    /* important for ellipsis to work */
}

.kwicLeft,
.kwicRight {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
}

.kwicLeft {
    text-align: right;
    padding-right: 0.5em;
    unicode-bidi: plaintext;

}

.kwicRight {
    text-align: left;
    padding-left: 6px;
    text-overflow: ellipsis;
}

.kwicHit {
    color: black;
    background-color: yellow;
    font-weight: bold;
    padding: 0 2px;
    white-space: nowrap;
}

/* Fixed column for metadata */
.kwicMeta {
    display: flex;
    align-items: flex-end;
    width: 80px;
    min-width: 80px;
}

.hitPage,
.hitVersion {
    font-size: 0.85em;
    color: #666;
    margin: 0;
    text-align: right;
    width: 40px;
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #333;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    animation: spin 1s linear infinite;
    margin: 1em auto;
}

.inlineSection .nextChapter a {
    margin-top: 50%;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}


/* === Mobile hamburger (hidden on desktop) === */
.hamburger {
    display: none;
    position: absolute;
    /* tweak if needed */
    right: 1rem;
    top: 1rem;
    width: 42px;
    height: 42px;
    border: 0;
    background: transparent;
    z-index: 10001;
}

/* Bars */
.hamburger span {
    display: block;
    width: 28px;
    height: 2px;
    background: #111;
    border-radius: 1px;
    transition: transform .25s ease, opacity .25s ease;
}

/* X state */
.hamburger[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.hamburger[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.hamburger[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Full-screen mobile menu overlay */
.mobileMenu {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(255, 255, 255, 0.98);
    display: none;
    padding: 6rem 2rem 2rem;
}

.mobileMenu.open {
    display: block;
}

/* Typography/layout inside the cloned UL */
.mobileMenu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1.25rem;
}

.mobileMenu li a {
    font-family: SohneHalbfett, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: clamp(1.35rem, 3.5vw, 2rem);
    text-decoration: none;
    color: #111;
}

/* Prevent body scroll when menu is open */
body.menu-open {
    overflow: hidden;
}

.mobileVersion {
    display: none !important;
}

.facsC {
    display: none !important;
}

@media (max-width: 800px),
(max-height: 500px) {
    .mobileHidden {
        display: none !important;
    }

    .mobileVersion {
        display: initial !important;
    }

    header>.main:nth-child(1) {
        display: none !important;
    }

    .hamburger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 6px;
        position: absolute;
        right: 1rem;
        top: 1rem;
        width: 42px;
        height: 42px;
        border: 0;
        background: transparent;
        z-index: 10001;
    }

    header .second ul {
        display: none;
    }

    /* mobile CSS */
    header .main {
        position: relative;
    }


    .mobileMenu .mobileLogo {
        position: absolute;
        left: 1rem;
        top: 1.5rem;
        height: 28px;
        width: auto;
        display: block;
    }


    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    html,
    body {
        margin: 0;
        padding: 0;
    }

    header {
        height: auto;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        padding-left: 1rem;
    }

    header .main h1 {
        display: none;
    }

    header .main {
        width: 100% !important;
        max-width: none !important;
        align-items: center;
        display: block !important;
        background-color: var(--white);
        padding-top: 1.5rem !important;
    }



    header .main :nth-child(1)>img {
        display: none
    }

    header .main .mobileLogo {
        display: block;
        margin: 0;
        padding: 0;
        height: 28px !important;
        width: auto;
    }

    header .second {
        width: 100% !important;
        margin: 0;
        margin-top: 1rem !important;
        position: initial !important;
    }

    header .second h1 {
        font-size: 28px !important;
        margin: 0.25rem 0 0.5rem !important;
        text-align: left !important;
        color: var(--green)
    }

    header .second ul {
        display: none
    }

    header .mobileBird {
        position: absolute !important;
        top: 8.3px !important;
        right: 53px !important;
        height: 3.8rem !important;
    }

    .facsC {
        display: flex !important;
    }

    .columns {
        position: fixed;
        width: 100%;
        z-index: 500;
        background-color: var(--white);
        overflow: auto;
        height: auto !important;
        margin-top: -0.2rem;
    }

    .control-panel {
        transition: transform 0.28s cubic-bezier(.22, .61, .36, 1);
    }

    .control-panel.closed {
        transform: translateX(calc(-100% + 2rem));
    }

    .control-panel:not(.closed)+ .facs + .textContainer .text{
        pointer-events: none;
    }

    .control-panel {
        height: 84%;
        bottom: 0;
        position: fixed;
        width: 11rem;
        padding-right: 1rem;
        z-index: 501;
    }

    .control-panel.closed {
        background-color: transparent;
        box-shadow: none;
    }

    .control-panel .closeControlPanel {
        background-color: white;
        border: rgba(0, 0, 0, 0.5) solid 0.1px;
        padding: 0.2rem;
        border-bottom-left-radius: 0.9rem;
        border-top-left-radius: 0.9rem;
        padding-top: 0.4rem;
        padding-bottom: 0.3rem;
    }

    .control-panel.closed .closeControlPanel {
        top: 50% !important;
        left: -0.2rem !important;
    }

    .control-panel .closeControlPanel {
        left: 9.8rem !important;
        top: 50%;
    }

    .control-panel.closed .copyright svg {
        background-color: white;
        border-radius: 1rem;
        bottom: 0.5rem;
    }

    .helpContainer {
        display: none !important;
    }

    .textContainer {
        width: 100% !important;
        position: absolute !important;
    }

    #mirador {
        margin-left: 0 !important;
        height: 92dvh;
    }

    #mirador.hidden {
        display: initial !important;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }

    #mirador.visible {
        opacity: 1;
        pointer-events: auto;
    }



    .editionText .breadCrumbs,
    .inlineSection .breadCrumbs {
        top: 7.5rem !important;
        width: 93% !important;
    }

    .textContainer .columns p {
        margin-left: 0.2rem !important;
    }

    .textContainer .columns div {
        min-width: 33%;
        justify-content: center;
        padding-bottom: 1.3rem;
        padding-top: 1rem;
    }

    .textContainer img {
        margin-left: 0 !important;
    }

    .text .editionText {
        margin-top: 6.8rem !important;
    }

    .orientationDisplaySection {
        margin-top: 6rem !important;
    }

    .variationSection ul {
        overflow: auto;
    }

    .text {
        height: 100% !important;
        padding-bottom: 2rem;
    }

    .search #clearButton {
        scale: 183%;
    }

    .search .breadCrumbs {
        margin-top: 4.6rem;
    }

    .variationSection ul {
        height: auto !important;
    }

    .embeddedRoundCheckbox::after {
        left: 3px !important;
        width: 4px !important;
    }

    .editionText .t .activeDiff,
    .editionText .clicked .activeDiff {
        background-color: rgba(192, 192, 192, 0.5)
    }

    .text .navLeft,
    .text .navRight {
        position: fixed !important;
        top: 23% !important;
    }

    .navLeft {
        left: -0.15rem !important;
    }

    #mirador:has(.mosaic-split) .mosaic-root>.mosaic-tile:nth-child(1) {
        inset: 0% 0% 50% 0% !important;
    }

    #mirador .mosaic-root>.mosaic-tile:nth-child(3) {
        inset: 50% 0% 0% 0% !important;
    }

}