:root {
    --footer-height: 2rem;
    /*--footer-height-total: calc(var(--footer-height) + 1px);  if border, then + 1px! */
    --toolbar-height: 105px;
    --pb-box-shadow: 0px 0px 4px 0px #cdccce;
    --pb-brand-color: #0076bd;
    --scrollbarBG: #ffffff;
    --thumbBG: #d1d3d6;
    --paper-checkbox-checked-color: #0076bd;
    --pb-popover-trigger: "mouseenter";
    --pb-color-white: #F0F0F0;
    --pb-menubar-color:var(--pb-color-white);
}

/* Custom scrollbar: Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--thumbBG) var(--scrollbarBG);
}

/* Custom scrollbar: Chrome, Edge, and Safari */
*::-webkit-scrollbar {
    width: 12px;
}

*::-webkit-scrollbar-track {
    background: var(--scrollbarBG);
}

*::-webkit-scrollbar-thumb {
    background-color: var(--thumbBG);
    border-radius: 8px;
    border: 2px solid var(--scrollbarBG);
}
/* important style to fix fullscreen mode for OSD */
#viewer.fullpage{
    position: fixed !important;
    z-index: 999;
    left:0;
    top:0;
}
.pb-container {
    padding: 0 20px;
    position: relative;
    margin: 0 auto;
}


.matches .search-result-tag {
    font-size:.75rem;
    color: white;
    padding: .1rem .6rem .3rem;
    margin:.5rem;
    border-radius: .2rem;
    display: inline-block;    
    text-shadow: 0 0 1px rgba(2, 6, 1, 0.6);    
}

#document-list .matches p {
    margin-left:.5rem;
}

.menu-logo img {
    height: 4rem;
}
.menubar {
    padding: 0.4rem 5rem;
}
.menubar a,
.menubar a:hover,
.menubar a:visited,
.menubar a:link {
    color:var(--pb-menubar-color);
}


.menubar paper-item a > *,
.menubar paper-item a:hover > *{
    color:black;
}

#browseToParentCollection,
#browseToParentCollection > * {
    font-weight: 500;
    vertical-align: middle;
}

#browseToParentCollection:hover,
#browseToParentCollection:hover > * {
    text-decoration: none;
}

/* custom splash screen */
.splash {
    background-image: url("../images/logo-inverted.svg");
    background-size: 40%;
}

@media screen and (min-width: 769px) {
    .splash {
        background-size: 20rem auto;
    }
}

html {
    font-size: 100%;
}

body {
    --pb-brand-color: #0076bd;
    --pb-menubar-background-color: var(--pb-brand-color);
    --pb-content-font-size: 1rem;
    --pb-popover-font-size: 80%;
    --pb-color-primary: #333333;
    --pb-view-max-width: 1024px;
    --rqzh-link-color: var(--pb-brand-color);
    --pb-logo-image-width: 70px;
    --pb-logo-image-height: 48px;
    --pb-timeline-color-highlight: var(--pb-color-focus);
    --pb-timeline-background-color-title: var(--pb-menubar-background-color);
    --pb-timeline-title-font-size: var(--pb-font-size-small);
    --pb-timeline-tooltip-font-size: var(--pb-font-size-small);
    color: var(--pb-color-primary);
}

@media screen and (min-width: 769px) {
    body {
        --pb-content-font-size: 1.1rem;
    }
}

/**************** Utility *****************/
.sr-only {
    display: none;
}

/**************** Typography *****************/

h1, h2, h3, h4, h5, h6 {
    font-family: var(--pb-heading-font-family);
    font-weight: 400 !important;
    line-height: 1.2;
    color: var(--pb-color-primary);
}

h1 {
    font-size: 1.75rem;
    margin: 2rem 0;
}

h2 {
    font-size: 1.55rem;
}

h3 {
    font-size: 1.35rem;
}

h4 {
    font-size: 1.15rem;
}

h5 {
    font-size: 1rem;
    margin: 0.625rem 0;
}

/* Typography in TEI content / webcomponents */
:root {
    --pb-h1-font-size: 1.75rem;
    --pb-h2-font-size: 1.55rem;
    --pb-h3-font-size: 1.35rem;
    --pb-h4-font-size: 1.15rem;
    --pb-h5-font-size: 1rem;
}

@media screen and (min-width: 769px) {
    h1, h2, h3, h4, h5, h6 {
        line-height: 1.2;
    }

    h1 {
        font-size: 2.25rem;
        font-weight: 400;
    }
    h2 {
        font-size: 2rem;
    }

    h3 {
        font-size: 1.5rem;
    }

    h4 {
        font-size: 1.3rem;
    }

    h5 {
        font-size: 1.15rem;
        margin: 0.625rem 0;
    }

    :root {
        --pb-h1-font-size: 2.25rem;
        --pb-h2-font-size: 2rem;
        --pb-h3-font-size: 1.5rem;
        --pb-h4-font-size: 1.3rem;
        --pb-h5-font-size: 1.15rem;
    }
}

a {
    background-color: transparent;
    color: var(--rqzh-link-color);
    text-decoration: none;
}

a {
    color: var(--rqzh-link-color);
}

a:hover,
a:active,
a:focus,
a:hover,
a:active,
a:focus {
    color: #00558a; /* hsl(203, 100%, 27%) a tad darker than the brand color */
    text-decoration: underline;
}



/************** General styling of Checkboxes and Radios ******************/
@supports (-webkit-appearance: none) or (-moz-appearance: none) {
    input[type=checkbox],
    input[type=radio] {
        --active: var(--pb-brand-color);
        --active-inner: #fff;
        /*--focus: 2px rgba(39, 94, 254, .3);*/
        --focus: 2px transparent;
        --border: #BBC1E1;
        --border-hover: var(--pb-brand-color);
        --background: #fff;
        --disabled: #F6F8FF;
        --disabled-inner: #E1E6F9;
        --input-size: 18px;
        -webkit-appearance: none;
        -moz-appearance: none;
        height: var(--input-size);
        outline: none;
        display: inline-block;
        vertical-align: top;
        position: relative;
        margin: 0;
        cursor: pointer;
        border: 1px solid var(--bc, var(--border));
        background: var(--b, var(--background));
        transition: background 0.3s, border-color 0.3s, box-shadow 0.2s;
    }
    input[type=checkbox]:after,
    input[type=radio]:after {
        content: "";
        display: block;
        left: 0;
        top: 0;
        position: absolute;
        transition: transform var(--d-t, 0.3s) var(--d-t-e, ease), opacity var(--d-o, 0.2s);
    }
    input[type=checkbox]:checked,
    input[type=radio]:checked {
        --b: var(--active);
        --bc: var(--active);
        --d-o: .3s;
        --d-t: .6s;
        --d-t-e: cubic-bezier(.2, .85, .32, 1.2);
        border-color: var(--active);
    }
    input[type=checkbox]:disabled,
    input[type=radio]:disabled {
        --b: var(--disabled);
        cursor: not-allowed;
        opacity: 0.9;
    }
    input[type=checkbox]:disabled:checked,
    input[type=radio]:disabled:checked {
        --b: var(--disabled-inner);
        --bc: var(--border);
    }
    input[type=checkbox]:disabled + label,
    input[type=radio]:disabled + label {
        cursor: not-allowed;
    }
    input[type=checkbox]:hover:not(:checked):not(:disabled),
    input[type=radio]:hover:not(:checked):not(:disabled) {
        --bc: var(--border-hover);
    }
    input[type=checkbox]:focus,
    input[type=radio]:focus {
        box-shadow: 0 0 0 var(--focus);
    }
    input[type=checkbox],
    input[type=radio] {
        width: var(--input-size);
    }
    input[type=checkbox]:after,
    input[type=radio]:after {
        opacity: var(--o, 0);
    }
    input[type=checkbox]:checked,
    input[type=radio]:checked {
        --o: 1;
    }
    input[type=checkbox] + label,
    input[type=radio] + label {
        font-size: 14px;
        line-height: var(--input-size);
        display: inline-block;
        vertical-align: top;
        cursor: pointer;
        margin-left: 4px;
    }
    input[type=checkbox] {
        /* apply "paper-checkbox" border styles for consistency */
        border-radius: 2px;
        border: solid 2px;
    }
    input[type=checkbox]:after {
        width: 5px;
        height: 10px;
        border: 2px solid var(--active-inner);
        border-top: 0;
        border-left: 0;
        left: 4px;
        top: -1px;
        transform: rotate(var(--r, 20deg));
    }
    input[type=checkbox]:checked {
        --r: 43deg;
    }
    input[type=radio] {
        border-radius: 50%;
    }
    input[type=radio]:after {
        width: var(--input-size);
        height: var(--input-size);
        border-radius: 50%;
        background: var(--active-inner);
        opacity: 0;
        transform: scale(var(--s, 0.7));
    }
    input[type=radio]:checked {
        --s: .5;
    }
    paper-checkbox {
        display:block;
        padding-top:0.3rem;
    }
}
#volumes fieldset {
    padding-top:0.3rem;
    padding-bottom:0.3rem;
    margin-bottom:1rem;
}

/* page title */

.tp-title span {
    color: #9e9e9e;
    font-size: 26px;
    margin-top: 12px;
}

.tp-title span {
    color: #9e9e9e;
    font-size: 26px;
    margin-top: 12px;
}


.content pb-collapse {
    color: var(--pb-color-primary);
    cursor: pointer;
}

ul.control-list {
    list-style-type: none;
    padding: 0;
}

.drawer-menu {
    list-style-type: none;
    padding: 0;
}

.drawer-menu li {
    padding: .8rem 0;
}
@media screen and (min-width: 769px) {
    .drawer-menu li {
        padding: 1rem 0;
    }
}

.drawer-menu li a {
    margin-top: 1rem;
    display: inline-block;
}

.drawer-menu li pb-lang, .drawer-menu li paper-listbox {
    margin-top: -1rem;
}

.drawer-menu li h4 {
    margin-top: 1rem;
}

.drawer-menu paper-item {
    height: 1rem 1rem 3rem 1rem;
}

li.col-3 {
    display: grid;
    grid-template-columns: auto 40px 10px 40px;
    align-items: flex-start;
    grid-column-gap: 0.25rem;
    align-items: self-end;
}

.logo img {
    width: 360px;
}

main pb-view {
    margin: 0;
    position: relative;
}

/******** custom search tile with filters **********/
/* button wrapper */
#search-form .buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1rem 0;
}

/* buttons */
#search-form .buttons paper-button {
    background-color: transparent;
    border: 1px solid gray;
    color: inherit;
    margin: 0;
    font-weight: 400;
}

#search-form .buttons paper-button:last-child {
    background-color: var(--pb-menubar-background-color);
    color: #fff;
    border: 1px solid var(--pb-menubar-background-color);
}

/* search tile -> help text */
#query-help-dialog {
    top: 42px; /* offset for top navigation */
    line-height: 26px;
}

#query-help-dialog a {
    color: var(--rqzh-link-color);
}


/* Language Form in Filter Sidebar */
.sidebar.fieldset {
    border: none;
    padding: 0;
    margin: 1.3rem 0 0 0;
}

.sidebar .filter-language-form {
    justify-content: left;
    padding: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-content: stretch;
    align-items: center;
    margin: 1rem 0 0 0;
}

.sidebar .filter-language-form li {
    flex: 1 100px;
    max-width: 100px;
    padding: 10px 0;
}

@media screen and (min-width: 769px) {
    .sidebar .filter-language-form {
        justify-content: space-between;
    }

    .sidebar .filter-language-form li {
        flex: none;
        max-width: none;
    }
}

/* Landing page */

.homepage {
    min-height: 70vh;
    margin: 0 3rem;
}

@media screen and (min-width: 1300px) { 
    .homepage {
    width: 70%;
    margin: auto;
}}

.teaser {
    display: grid;
    grid-template-columns: 25% 1fr;
    text-align: justify;
    hyphens: auto;
}



.images {
    background-position: top left;
    background-repeat: no-repeat;
    background-attachment: 0 0;
    background-size: auto 100%;
    margin-right: 0;
   
}


/*********** INDEX.html - document lists *****************/

.doclist > h2 {
    margin: 16px 0;
}

.doclist ul.documents {
    padding: 0;
}

#document-list h3,
#document-list p {
    margin: 0;
}

#document-list h3 {
    margin-bottom: 1rem;
}

/* Links to documents in document lists */
.collection a:hover,
.collection a:active,
.collection a:focus,
.collection a:hover > *,
.collection a:active > *,
.collection a:focus > * {
    text-decoration: none;
}

/* document list on start page */

.collection .volume {
    margin-bottom: 2rem;
}

.panels {
    margin-bottom: 4em;
}


        .panels .doclist {
        width:100%;
            --paper-tabs-selection-bar-color: #607D8B;
            --paper-tab-content: {
                font-family: var(--pb-heading-font-family);
                font-weight: 400;
            }
            ;
            --paper-card-header: {
                background-color: #d1dae0;
            }
            ;
            --paper-card-header-text: {
                font-family: var(--pb-heading-font-family);
                font-size: 16px;
                font-weight: 400;
            }
            ;
        }

.panels .doclist .card-content {
    padding: 0;
}

.panels .doclist .browse {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 16px;
    padding: 0;
}
.search-mask aside {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.documents a,
.volumes a,
.documents a:visited,
.volumes a:visited {
    text-decoration: none;
}


.documents li {
    display: flex;
    flex-direction: row;
    margin-bottom: 1em;
    padding: 0.5em 0;
    border-bottom: thin solid var(--paper-grey-300);
}

.documents li:last-child {
    border: none;
}

.documents .document-select {
    flex: 0 0;
    margin-right: 2em;
}
#document-list {
    margin-top: 1rem;
}
.parent-link iron-icon {
    padding-right: 4px;
}
.documents ul {
    list-style: none;
}

.documents div {
    margin: 0;
}


.parent-link {
    display: block;
    margin-bottom: 10px;
    padding: 6px 0;
}

.collection {
    margin-top: 8px;
    padding-top: 12px;
    /* border-top: thin solid var(--paper-grey-300); */
}

.documents .document-select {
    flex: 0 0;
    margin-right: 20px;
}

.search-mask h5 {
    font-family: var(--pb-heading-font-family);
    font-weight: 400 !important;
    line-height: 1.2;
    font-size: 1rem;
    margin: 0;
}

.search-mask h4 {
    font-family: var(--pb-heading-font-family);
    font-size: 1.2rem;
}



.search-mask main {
    margin: 0 2em 0 2em;
    --pb-browse-toolbar-justify-content: space-between;
}

#series {
    width: min-content;
}

.document-count {
    display: inline-block;
    font-family: var(--pb-heading-font-family);
    font-weight: 400;
    margin-bottom: 1rem;
    background-color: var(--pb-timeline-background-color-title);
    padding: 4px;
    border-radius: 10px;
    color: #f0f0f0;
}

.volumes .count {
    margin-left: 20px;
    padding: 4px;
    border-radius: 10px;
    color: #f0f0f0;
    font-size: var(--pb-base-font-size);
    background-color: var(--pb-timeline-background-color-title);
}


/* document list on document landing page */

#sort {
    display: block;
    text-align: right;
    font-family: var(--paper-font-common-base_-_font-family);
}

.parent-link iron-icon {
    padding-right: 4px;
    bottom: 3px;
}

.parent-link {
    display: inline-block;
    margin: 16px 0 0 0;
    padding: 16px 0;
    border-bottom: thin solid var(--paper-grey-300);
    text-transform: none;
    font-family: var(--pb-heading-font-family);
    font-weight: 400;
}

/* list of sub-collection in index.html */
#document-list ul {
    list-style-type: none;
    padding-left: 0;
}

#document-list .document-info {
    font-family: var(--pb-heading-font-family);
    font-weight: 400;
    flex: 1 auto;
}

#document-list .document-thumbnail-link {
    cursor: pointer;
}

#document-list .document-thumbnail-image {
    max-height: 100px;
    width: auto;
}

#document-list .documents .header-short {
    font-size: .85rem;
    line-height: 1.2;
}

#document-list .documents .header-short > h4 {
    font-size: 1.125rem;
    line-height: inherit;
    font-family: inherit;
    font-weight: inherit;
    margin-top: 10px;
    margin-bottom: 10px;
}

#document-list .documents .title {
    font-weight: 400;
    font-size: 1.5rem;
    font-family: var(--pb-heading-font-family);
    line-height: 1.2;
    margin-top: 10px;
    margin-block-end: 0.5em;
    display: block;
}

#document-list .documents .title > * {
    font-family: inherit;
    font-weight: inherit;
    font-size: inherit;
}

.documents li {
    display: flex;
    flex-direction: row;
    margin-bottom: 10px;
    padding: 1.5rem 0.5rem;
    border-bottom: 0.1rem solid var(--paper-grey-300);
}

@media screen and (min-width: 769px) {
    .documents li:last-child {
        border: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }
}

pb-lang {
    color: #777777;
    width: 100px;
    margin-right: 1rem;
}

pb-login {
    color: inherit;
    font-weight: 300;
}

pb-login::part(group-invalid) {
    display: none;
}

pb-view {
    font-weight: 300;
    color: var(--pb-color-primary);
    font-family: var(--pb-base-font-family);
}

/*************** timeline ******************/

.timeline {
   --pb-timeline-padding: 0 20px;
}
pb-timeline::part(tooltip-link)  {
    color: var(--pb-color-inverse);
}

/*************** VIEW.html *****************/

#title-view1 {
    margin-bottom: 2rem;
}

#view1 {
    flex: 1 1;
    overflow: auto;
        }
        
        
.edition main {
    overflow: auto;
    height: 82vh;
    padding: 0 2rem;
    display: flex;
}

.edition .content-body {
    width: 100%;
        }

.edition pb-facsimile {
    flex: 1 1;
    --pb-facsimile-height: 80vh;
    margin-top: 1.5rem;
        }

/* facsimile visibility on mobile is now controlled by the tab switcher — see responsive section below */

.toolbar-button__label {
    font-size: 12px;
}

@media screen and (min-width: 769px) {
    .toolbar-button__label {
        font-size: 1em;
    }
}

/* other "block-title" headings are styled via rqzh.css!! */
.block-title.edition {
    margin: 1.2em 0 0 0;
}

.place {
    color: #055005;
}

.person, .organization {
    color: #395576;
}

.narrow-item {
    padding: 0;
    line-height: 1.5rem;
    display: block;
    --paper-item-min-height: 1.5rem;
}

paper-input {
    /* hide underline in all states */
    --paper-input-container-underline: {
        display: none;
    }
    ;
    --paper-input-container-underline-focus: {
        display: none
    }
    ;
    --paper-input-container-underline-disabled: {
        display: none
    }
    ;
}

paper-input label {
    height: 0;
    display: none;
}

.tei-summary {
    margin: 1rem 0;
}

.term {
    color: #740502;
}

.toolbar {
    height: 40px;
}

.hidden {
    display: none;
}

.volume paper-listbox {
    height: 10rem;
    overflow: auto;
}

/**************** SEARCH.html *******************/

.searchbox {
    --paper-item-min-height: 24px;
}

#search-info {
    color: inherit;
    text-decoration: none;
}

.card-padding [for="filter-language"] {
    display: block;
    margin-top: .5rem;
}

.card-padding [name="filter-kanton"] {
    margin-top: 1rem;
}

.card-padding .filter-grid .right {
    display: grid;
    grid-template-columns: 45% auto 45%;
}

.card-padding .filter-grid .until {
    align-self: flex-end;
    margin-bottom: 0.5rem;
    display: inline-block;
    text-align: center;
}

.card-padding .filter-grid .flexend {
    align-self: flex-end;
}

.card-padding select {
    border: none;
    font-size: 1rem;
}

/* pagination, result display, progressbar, and sorting */

.bottom-item {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
}


pb-select {
    margin: 0;
}

pb-select#sort-select {
    display: block;
    margin-top: .5rem;
    text-align: end;
}

.search__toolbar {
    margin: 1.5rem 0;
    display: block;
}

@media screen and (min-width: 769px) {
    .search__toolbar {
        margin: 1.7rem 0 0;
    }

}

@media screen and (min-width: 1024px) {
    .search__toolbar {
        display: flex;
        justify-content: space-between;
    }

    pb-select#sort-select {
        display: flex;
        flex-direction: column;
        margin-top: 1rem;
    }

}

/* search and documents tile on start- and search-page */

.card-padding h2 {
    background: #fff;
    color: inherit;
    margin: 0;
}

.card-padding h4 {
    margin-bottom: 1rem;
}

.card-padding paper-dropdown-menu {
    width: 100%;
}

.card-padding .formrow {
    margin-top: 1rem;
}

.card-padding .formrow label {
    padding: 1.5rem 0 1rem 0;
}

.card-padding option {
    font-size: 0.875rem;
}

.card-padding .subtype {
    padding-left: 2rem;
}

.card-padding aside {
    margin-bottom: 1rem;
    min-width: 200px;
}

.panel-body ul {
    list-style-type: none;
}

.panel-body>ul {
    padding: 0;
}

.upload .card-content {
    padding: 0;
}

.filter-canton {
    height: 200px;
}

pb-browse-docs::part(delete-button) {
    display: none;
}

/* ABBR.html*/

.abbr-list {
    margin-bottom: 2rem
}

.abbr-list li {
    list-style-type: none;
    font-family: var(--pb-content-font-family);
}

@media screen and (min-width: 769px) {
    .abbr-list li {
        padding-left: 1rem;
    }
}

/**************** footer ******************/

.footer__imprint {
    margin: 2rem;
    display: flex;
    justify-content: space-around;
}

.footer-col {
    display: flex;
    flex-direction: column;
}

footer.navigation {
    display: flex;
    flex-direction: row;
    justify-content: center;
    height: calc(var(--footer-height) - 1px);
    border-top: 1px solid #ebebeb;
    box-shadow: -3px 0px 14px -8px #ccc;
    width: 100%;
}


/*******************search page results**************************/
.search-page {
            main {
                display: flex;
                flex-direction: row;
                margin-top: 10px;
            }

            .search-panel {
                flex: 1 1;
                margin: 0 20px;
            }

            .search-panel paper-card {
                width: 100%;
            }

            .targets paper-checkbox {
                margin-top: 10px;
            }

            #results {
                flex: 2 1;
                overflow: scroll;
                margin: 0 20px;
                height: calc(100vh - 140px);
            }

            #results paper-card {
                width: 100%;
                margin-bottom: 15px;
                padding: 8px;
            }

            #results header {
                display: flex;
                justify-content: flex-start;
            }
            #results .count {
                margin-right: 20px;
                font-weight: bold;
            }
            .breadcrumb:link, .breadcrumb:visited {
                text-decoration: none;
                color: var(--paper-grey-600);
            }
            .breadcrumb:before {
                content: '&gt;';
                padding: 0 8px;
                font-weight: bold;
            }
            .breadcrumb:first-child::before {
                content: '';
            }
            .matches {
                display: table;
                margin-left: 20px;
                margin-top: 10px;
                font: var(--pb-results-body-font);
            }
            .matches p {
                display: table-row;
            }
            .matches p * {
                display: table-cell;
                padding: 4px 8px;
            }

            .hi {
                display: block;
            }

            #facets h3 {
                display: flex;
                flex-direction: row;
                align-self: center;
                justify-content: space-between;
            }

            #facets h3 paper-checkbox {
                font-size: 85%;
            }

            #facets table td:nth-child(2) {
                color: #808080;
                text-align: right;
                padding-left: 1em;
                vertical-align: middle;
            }

            #download-button, .menu-edit-odd {
                display: none;
            }
}

pb-tify {
    display: block;
    min-width: 40em;
    height: 80vh;
}

.content {
    margin: 0 10rem 5rem 10rem;
    text-align: justify;
}

/* ==========================================================================
   RESPONSIVE / MOBILE-FRIENDLY STYLES
   Breakpoints: ≤480px (phone), ≤768px (tablet), ≥769px (desktop, existing)
   ========================================================================== */

/* --- View page: tab switcher (mobile only) --- */

.view-tabs {
    display: none;
}

/* On desktop: panels are the flex items (sizing moved from content-body to here) */
.view-tab-panel {
    display: block;
}

.edition .view-tab-panel[data-panel="text"] {
    overflow-y: scroll;
    margin-right: 1.5rem;
    width: 58%;
}

.edition .view-tab-panel[data-panel="facsimile"] {
    flex: 1 1;
}

/* On mobile: .active class controls visibility (set in media query below) */

/* --- Tablet and below (≤768px) --- */

@media screen and (max-width: 768px) {

    /* -- Global: prevent horizontal scrolling -- */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Force all top-level layout containers to respect viewport width */
    pb-page, app-drawer-layout, app-header-layout, main,
    .panels, .doclist, .card-content, .browse {
        max-width: 100vw;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    /* Web components: constrain to viewport */
    pb-paginate {
        max-width: 100%;
        overflow-x: auto;
        display: block;
    }

    pb-timeline {
        max-width: 100%;
        overflow-x: auto;
        display: block;
    }

    pb-search, pb-select, pb-custom-form {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* -- Global: menubar -- */
    .menubar {
        padding: 0.4rem 1rem;
    }

    .menu-logo img {
        height: 3rem;
    }

    /* -- Global: footer -- */
    .footer__imprint {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
        margin: 1.5rem 1rem;
    }

    .footer-col {
        align-items: center;
        text-align: center;
    }

    /* -- Homepage (index.html): teaser -- */
    .homepage {
        margin: 0 1rem;
    }

    .teaser {
        grid-template-columns: 1fr;
        text-align: left;
        hyphens: none;
    }

    .teaser section {
        max-width: 100%;
    }

    .teaser .images {
        min-height: 200px;
        margin-top: 1.5rem;
        background-size: 100% auto;
    }

    /* -- Start page: browse grid -- */
    .panels .doclist .browse {
        grid-template-columns: 1fr;
    }

    .search-mask main {
        margin: 0 1em;
        overflow-x: hidden;
    }

    .search-mask aside {
        margin-bottom: 1.5rem;
        width: 100%;
        min-width: 0;
    }

    /* Prevent horizontal overflow from series and timeline */
    #series {
        width: 100%;
    }

    .timeline {
        overflow-x: auto;
        max-width: 100%;
    }

    pb-timeline {
        max-width: 100%;
    }

    #document-list {
        max-width: 100%;
        overflow-x: hidden;
    }

    .card-padding aside {
        min-width: 0;
    }

    /* -- Search page: stack panels, search above results -- */
    .search-page main {
        flex-direction: column;
        overflow-x: hidden;
    }

    .search-page .search-panel {
        order: -1;
        margin: 0 10px 1rem;
        width: auto;
    }

    .search-page #results {
        margin: 0 10px;
        height: auto;
        max-height: none;
        overflow: visible;
        width: auto;
    }

    /* -- View page: tab switcher visible -- */
    .view-tabs {
        display: flex;
        gap: 0;
        border-bottom: 2px solid #ddd;
        margin-bottom: 0.5rem;
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 10;
    }

    .view-tabs button {
        flex: 1;
        padding: 0.6rem 1rem;
        border: none;
        background: #f5f5f5;
        font-size: 0.95rem;
        font-family: var(--pb-heading-font-family);
        font-weight: 400;
        cursor: pointer;
        color: var(--pb-color-primary);
        border-bottom: 3px solid transparent;
        transition: border-color 0.2s, background 0.2s;
    }

    .view-tabs button.active {
        background: #fff;
        border-bottom-color: var(--pb-brand-color);
        font-weight: 500;
    }

    .view-tab-panel {
        display: none;
    }

    .view-tab-panel.active {
        display: block;
    }

    /* -- View page: layout -- */
    .edition main {
        flex-direction: column;
        height: auto;
        padding: 0 1rem;
    }

    .edition .view-tab-panel[data-panel="text"] {
        overflow-y: visible;
        margin-right: 0;
        width: 100%;
    }

    .edition .view-tab-panel[data-panel="facsimile"] {
        flex: none;
        width: 100%;
    }

    .edition .content-body {
        width: 100%;
        margin-right: 0;
        overflow-y: visible;
    }

    .edition pb-facsimile {
        display: block;
        --pb-facsimile-height: 60vh;
        margin-top: 0;
    }

    /* Override the existing max-width:769px rule that hides facsimile */
    pb-facsimile {
        display: block;
    }

    /* -- pb-tify: prevent overflow -- */
    pb-tify {
        min-width: 0;
        width: 100%;
        height: 60vh;
    }

    /* -- About page -- */
    .content {
        margin: 0 1.5rem 2rem 1.5rem;
    }

    /* -- Toolbar: ensure wrapping -- */
    .toolbar {
        height: auto;
        flex-wrap: wrap;
    }

    /* -- Document list items -- */
    .documents li {
        flex-direction: column;
    }

    .documents .document-select {
        margin-right: 0;
        margin-bottom: 0.5rem;
    }

    /* -- Timeline period inputs -- */
    #document-list > div:nth-child(2) {
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem;
        align-items: center;
    }
}

/* --- Phone (≤480px) --- */

@media screen and (max-width: 480px) {

    .menubar {
        padding: 0.3rem 0.5rem;
    }

    .menu-logo img {
        height: 2.5rem;
    }

    .homepage {
        margin: 0 0.75rem;
    }

    h1 {
        font-size: 1.4rem;
    }

    .search-mask main {
        margin: 0 0.5em;
    }

    .teaser {
        text-align: left;
    }

    .edition main {
        padding: 0 0.5rem;
    }

    .content {
        margin: 0 0.75rem 1.5rem 0.75rem;
    }

    .footer__imprint {
        margin: 1rem 0.5rem;
    }

    /* Tighter document list */
    .documents li {
        padding: 0.75rem 0.25rem;
    }

    #document-list .documents .title {
        font-size: 1.15rem;
    }

    /* Search form buttons */
    #search-form .buttons {
        flex-direction: column;
        gap: 0.5rem;
    }

    #search-form .buttons paper-button {
        width: 100%;
        text-align: center;
    }
}