.public-shell {
    min-height: 100vh;
    background: transparent;
    color: var(--text);
}

.public-header__brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.public-header .site-logo {
    width: 36px;
    height: 36px;
}

.public-header__brand .site-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.public-shell__content {
    padding: 32px 32px 48px;
}


.library-shell {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.library-hero {
    display: flex;
    gap: 24px;
    justify-content: space-between;
    align-items: flex-start;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0;
    padding: 28px;
}

.library-hero h1 {
    margin: 0 0 12px;
    font-size: 32px;
}

.library-hero p {
    margin: 0;
    color: #c6d2f0;
    max-width: 540px;
}

.library-search {
    min-width: 280px;
    flex: 1;
    max-width: 360px;
}

.library-search__label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #a9b7dd;
}

.library-search__field {
    display: flex;
    gap: 8px;
}

.library-search input {
    flex: 1;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(8, 12, 22, 0.8);
    padding: 10px 12px;
    color: #fff;
}

.library-search button {
    border-radius: 0;
    background: #5b7bff;
    border: none;
    color: #fff;
    padding: 10px 16px;
    cursor: pointer;
}

.library-layout {
    display: grid;
    grid-template-columns: 220px 1fr 240px;
    gap: 24px;
    align-items: start;
}

/* IMPORTANT FIX: remove the empty 3rd column when facts panel isn't rendered */
.library-layout:not(.has-facts) {
    grid-template-columns: 220px 1fr;
}

.library-nav {
    background: rgba(10, 14, 24, 0.9);
    border-radius: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 20px;
    position: sticky;
    top: 96px;
}

.library-nav h2 {
    margin: 0 0 12px;
    font-size: 18px;
}

.library-nav ul {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.library-nav li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #dbe4ff;
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 0;
    transition: background 0.2s ease;
}

.library-nav li.is-active a,
.library-nav li a:hover {
    background: rgba(91, 123, 255, 0.18);
}

.library-nav__count {
    font-size: 12px;
    color: #9fb0dd;
}

.library-nav__meta h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #a5b4db;
}

.library-nav__meta ul {
    margin: 0;
}

.library-nav__meta li {
    font-size: 13px;
}

.library-nav__meta a {
    color: #cbd7f7;
    text-decoration: none;
}

.library-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.library-breadcrumbs {
    font-size: 13px;
    color: #97a7cf;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.library-breadcrumbs a {
    color: #c1cff2;
    text-decoration: none;
}

.library-section h2 {
    margin-bottom: 8px;
}

.library-card-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.library-card {
    background: rgba(16, 20, 32, 0.85);
    border-radius: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.library-card__category {
    font-size: 12px;
    color: #8fa6da;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.library-card a {
    color: #5b7bff;
    text-decoration: none;
    font-weight: 600;
}

.library-card__meta {
    font-size: 12px;
    color: #94a8d6;
}

.library-detail header {
    background: rgba(16, 20, 32, 0.8);
    border-radius: 0;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.library-detail__category {
    text-transform: uppercase;
    font-size: 12px;
    color: #8fa6da;
    letter-spacing: 0.08em;
}

.library-detail section {
    background: rgba(10, 14, 24, 0.7);
    border-radius: 0;
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.library-detail ul {
    margin-top: 12px;
    padding-left: 20px;
}

.library-table {
    overflow-x: auto;
    border-radius: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.library-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.library-table th,
.library-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.library-updates {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.library-update {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    text-decoration: none;
    color: #dce4ff;
    background: rgba(12, 16, 28, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 14px;
    border-radius: 0;
}

.library-update__date {
    font-size: 12px;
    color: #9aabd4;
}

.library-facts {
    background: rgba(12, 16, 28, 0.9);
    border-radius: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 20px;
    position: sticky;
    top: 96px;
}

.library-facts ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.library-facts li {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
    color: #c7d3f6;
}

@media (max-width: 1100px) {
    .library-layout {
        grid-template-columns: minmax(0, 1fr);
        grid-auto-flow: row;
    }

    .library-facts {
        position: static;
    }

    .library-nav {
        position: static;
    }
}

@media (max-width: 900px) {
    .public-shell__content {
        padding: 24px;
    }

    .library-hero {
        flex-direction: column;
    }

    .library-layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "nav"
            "main"
            "facts";
    }

    .library-nav {
        position: static;
        grid-area: nav;
        margin: 0 auto;
        max-width: 320px;
    }

    .library-main {
        grid-area: main;
    }

    .library-facts {
        grid-area: facts;
    }
}


@media (max-width: 600px) {
    .public-header {
        grid-template-columns: 1fr;
        justify-items: start;
        gap: 12px;
    }

    .public-header .site-nav {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .public-shell__content {
        padding: 16px;
    }

    .library-shell {
        gap: 20px;
    }

    .library-hero {
        padding: 20px;
        width: 100%;
    }

    .library-hero h1 {
        font-size: 26px;
    }

    .library-search {
        min-width: 0;
        max-width: none;
        width: 100%;
    }

    .library-search__field {
        flex-direction: column;
    }

    .library-search button {
        width: 100%;
    }

    .library-layout {
        gap: 16px;
    }

    .library-nav,
    .library-facts {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 18px;
    }

    .library-main {
        gap: 18px;
    }

    .library-card-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .library-card {
        padding: 16px;
    }

    .library-detail header,
    .library-detail section {
        padding: 16px;
    }

    .library-update {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }
}

