:root {
    --portal-blue: #073b63;
    --portal-blue-dark: #052e4d;
    --portal-blue-soft: #eaf2f7;
    --portal-red: #b01e35;
    --portal-red-dark: #8f172b;
    --surface: #ffffff;
    --surface-soft: #f5f8fa;
    --border: #d7e0e6;
    --text: #1e2c35;
    --muted: #657985;
    --shadow: 0 8px 24px rgba(25, 55, 73, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    background: #f3f7f9;
    color: var(--text);
    font-family:
        Arial,
        Helvetica,
        sans-serif;
}

button,
input,
select {
    font: inherit;
}

/* Header */

.portal-header {
    background: #ffffff;
}

.portal-header-main {
    width: min(1440px, calc(100% - 64px));
    min-height: 145px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 34px;
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 30px;
    color: #111111;
    text-decoration: none;
}

.portal-brand img {
    width: 270px;
    max-height: 105px;
    object-fit: contain;
    object-position: left center;
}

.agency-name {
    min-width: 245px;
    color: #111111;
    font-size: 25px;
    font-weight: 700;
    line-height: 1.25;
}

.brand-divider {
    width: 1px;
    height: 82px;
    background: #c9d1d6;
}

.portal-heading {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.portal-heading strong {
    color: #111111;
    font-size: 34px;
    line-height: 1.1;
}

.portal-heading span {
    color: #222222;
    font-size: 18px;
}

.portal-red-bar {
    height: 78px;
    background: var(--portal-red);
}

/* Seiteninhalt */

.page-container {
    width: min(1440px, calc(100% - 64px));
    flex: 1;
    margin: 0 auto;
    padding: 24px 0 46px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
    color: var(--muted);
    font-size: 14px;
}

.breadcrumb a {
    color: var(--portal-blue);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.library-intro {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        minmax(420px, 0.8fr);
    align-items: start;
    gap: 50px;
    margin-bottom: 25px;
}

.library-intro h1 {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0;
    color: var(--portal-blue);
    font-size: 36px;
}

.library-intro > div > p {
    margin: 7px 0 0;
    color: var(--text);
    font-size: 17px;
}

.intro-description {
    margin: 4px 0 0;
    padding-left: 26px;
    border-left: 1px solid var(--border);
    color: var(--portal-blue);
    font-size: 17px;
    line-height: 1.55;
}

.title-icon {
    width: 48px;
    height: 40px;
    display: inline-block;
    position: relative;
    flex: 0 0 auto;
}

.title-icon::before,
.title-icon::after {
    content: "";
    position: absolute;
    top: 3px;
    width: 21px;
    height: 32px;
    border: 3px solid var(--portal-blue);
    background: transparent;
}

.title-icon::before {
    left: 1px;
    border-right-width: 2px;
    transform: skewY(8deg);
}

.title-icon::after {
    right: 1px;
    border-left-width: 2px;
    transform: skewY(-8deg);
}

/* Filter */

.filter-panel {
    display: grid;
    grid-template-columns:
        minmax(280px, 1.2fr)
        minmax(220px, 0.85fr)
        minmax(220px, 0.85fr)
        auto;
    align-items: end;
    gap: 22px;
    margin-bottom: 28px;
    padding: 20px 22px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.filter-panel label {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.filter-panel label > span {
    color: var(--portal-blue-dark);
    font-size: 13px;
    font-weight: 700;
}

.filter-panel input,
.filter-panel select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #bccad3;
    border-radius: 7px;
    background: #ffffff;
    color: var(--text);
}

.filter-panel input:focus,
.filter-panel select:focus {
    outline: 2px solid rgba(7, 59, 99, 0.18);
    border-color: var(--portal-blue);
}

.primary-button {
    min-height: 44px;
    padding: 10px 20px;
    border: 0;
    border-radius: 7px;
    background: var(--portal-blue);
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.primary-button:hover {
    background: var(--portal-blue-dark);
}

/* Kategorien */

#bibliothek-kategorien h2,
.results-section h2,
.latest-section h2 {
    margin: 0 0 15px;
    color: var(--portal-blue);
    font-size: 24px;
}

.category-grid {
    display: grid;
    grid-template-columns:
        repeat(var(--kategorien-pro-zeile, 6), minmax(0, 1fr));
    gap: 16px;
}

.category-card {
    min-height: 270px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    box-shadow: 0 4px 13px rgba(25, 55, 73, 0.06);
    text-align: center;
}

.category-icon {
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 13px;
    color: var(--portal-blue);
}

.category-icon svg {
    width: 48px;
    height: 48px;
    stroke: currentColor;
}

.category-title {
    margin: 0;
    color: var(--portal-blue-dark);
    font-size: 16px;
}

.category-count {
    display: inline-flex;
    min-width: 23px;
    height: 23px;
    align-items: center;
    justify-content: center;
    margin-left: 5px;
    padding: 0 6px;
    border-radius: 999px;
    background: #edf1f3;
    color: #33454f;
    font-size: 11px;
}

.category-description {
    flex: 1;
    margin: 13px 0 18px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

.category-button {
    min-height: 39px;
    padding: 8px 16px;
    border: 1px solid #b8c8d2;
    border-radius: 7px;
    background: #ffffff;
    color: var(--portal-blue);
    font-weight: 700;
    cursor: pointer;
}

.category-card.is-featured .category-button {
    border-color: var(--portal-blue);
    background: var(--portal-blue);
    color: #ffffff;
}

.category-button:hover {
    border-color: var(--portal-blue);
    background: var(--portal-blue);
    color: #ffffff;
}

/* Ergebnisliste */

.results-section,
.latest-section {
    margin-top: 32px;
}

.result-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 13px;
}

.result-heading h2 {
    margin-bottom: 3px;
}

.result-heading p {
    margin: 0;
    color: var(--muted);
}

.text-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--portal-blue);
    font-weight: 700;
    cursor: pointer;
}

.library-list {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.library-row {
    display: grid;
    grid-template-columns:
        minmax(280px, 2fr)
        minmax(160px, 0.8fr)
        minmax(150px, 0.8fr)
        90px
        auto;
    align-items: center;
    gap: 18px;
    min-height: 68px;
    padding: 10px 18px;
    border-top: 1px solid var(--border);
}

.library-row:first-child {
    border-top: 0;
}

.library-row:hover {
    background: var(--surface-soft);
}

.library-row-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.library-row-title strong {
    color: var(--portal-blue-dark);
}

.library-row-title small {
    color: var(--muted);
}

.library-row-meta {
    color: var(--text);
    font-size: 14px;
}

.library-row-action {
    justify-self: end;
    padding: 8px 18px;
    border-radius: 6px;
    background: var(--portal-blue);
    color: #ffffff;
    font-weight: 700;
    text-decoration: none;
}

.library-row-action:hover {
    background: var(--portal-blue-dark);
}

.empty-state,
.error-message {
    padding: 34px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    text-align: center;
}

.error-message {
    margin-top: 20px;
    color: #8e2633;
}

/* Footer */

#bibliothek-footer {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px max(32px, calc((100% - 1440px) / 2));
    background: var(--portal-blue-dark);
    color: #ffffff;
}

#bibliothek-footer > div {
    display: flex;
    align-items: center;
    gap: 12px;
}

#bibliothek-footer a {
    color: #ffffff;
    text-decoration: none;
}

#bibliothek-footer a:hover {
    text-decoration: underline;
}

/* Anpassungen */

[hidden] {
    display: none !important;
}

@media (max-width: 1250px) {
    .category-grid {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

    .portal-brand img {
        width: 220px;
    }

    .agency-name {
        min-width: 200px;
        font-size: 21px;
    }

    .portal-heading strong {
        font-size: 29px;
    }
}

@media (max-width: 950px) {
    .portal-header-main {
        align-items: flex-start;
        flex-direction: column;
        gap: 16px;
        padding: 25px 0;
    }

    .brand-divider {
        display: none;
    }

    .filter-panel {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .library-intro {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .intro-description {
        padding-left: 0;
        border-left: 0;
    }

    .library-row {
        grid-template-columns:
            minmax(240px, 1fr)
            minmax(130px, 0.6fr)
            auto;
    }

    .library-row .optional-column {
        display: none;
    }
}

@media (max-width: 680px) {
    .portal-header-main,
    .page-container {
        width: min(100% - 28px, 1440px);
    }

    .portal-brand {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .portal-brand img {
        width: 210px;
    }

    .agency-name {
        min-width: 0;
        font-size: 19px;
    }

    .portal-red-bar {
        height: 48px;
    }

    .filter-panel,
    .category-grid {
        grid-template-columns: 1fr;
    }

    .library-row {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 16px;
    }

    .library-row-action {
        justify-self: start;
    }

    #bibliothek-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    #bibliothek-footer > div {
        flex-wrap: wrap;
    }
}


/* Exakter Portal-Header */

#portal-header {
    width: 100%;
    background: #ffffff;
}

#portal-header-top {
    min-height: 154px;
    display: flex;
    align-items: center;
    padding: 0 40px;
    background: #ffffff;
}

#portal-branding {
    width: min(1520px, 100%);
    min-height: 154px;
    display: flex;
    align-items: center;
    gap: 36px;
    margin: 0 auto;
    color: #111111;
    text-decoration: none;
}

#portal-logo {
    width: 275px;
    height: 110px;
    flex: 0 0 auto;
    object-fit: contain;
    object-position: left center;
}

#portal-agency-name {
    min-width: 270px;
    color: #111111;
    font-size: 25px;
    font-weight: 700;
    line-height: 1.22;
}

#portal-brand-divider {
    width: 1px;
    height: 82px;
    flex: 0 0 auto;
    background: #c9d0d4;
}

#portal-text {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

#portal-title {
    color: #111111;
    font-size: 35px;
    font-weight: 700;
    line-height: 1.1;
}

#portal-subtitle {
    color: #222222;
    font-size: 18px;
    line-height: 1.35;
}

#portal-header-bottom {
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 9px 28px;
    background: #ad1e35;
}

#portal-search {
    width: min(460px, 100%);
}

#portal-search-input {
    width: 100%;
    min-height: 43px;
    padding: 10px 14px;
    border: 0;
    border-radius: 6px;
    background: #ffffff;
    color: #26343d;
    font-size: 16px;
}

#portal-search-input:focus {
    outline: 3px solid rgba(255, 255, 255, 0.35);
}

@media (max-width: 1050px) {
    #portal-header-top {
        padding: 20px 28px;
    }

    #portal-branding {
        min-height: auto;
        gap: 22px;
    }

    #portal-logo {
        width: 220px;
        height: 90px;
    }

    #portal-agency-name {
        min-width: 210px;
        font-size: 21px;
    }

    #portal-title {
        font-size: 29px;
    }

    #portal-subtitle {
        font-size: 16px;
    }
}

@media (max-width: 760px) {
    #portal-branding {
        align-items: flex-start;
        flex-direction: column;
    }

    #portal-brand-divider {
        display: none;
    }

    #portal-logo {
        width: 210px;
    }

    #portal-agency-name {
        min-width: 0;
    }

    #portal-header-bottom {
        justify-content: stretch;
        padding: 10px 16px;
    }

    #portal-search {
        width: 100%;
    }
}

/* Portal-Suche auf der Bibliotheksseite ausblenden */

#portal-header-bottom {
    justify-content: flex-start;
}

#portal-header-bottom #portal-search {
    display: none;
}

.portal-back-navigation {
    width: min(1440px, calc(100% - 32px));
    margin: 16px auto 0;
}

.portal-back-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 13px;
    border-radius: 4px;
    background: #ffffff;
    color: #173a59;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.portal-back-link:hover,
.portal-back-link:focus-visible {
    background: #f3f5f6;
}
