.main-shell {
    width: 100%;
    max-width: var(--maxw);
    padding: 0 var(--layout-gutter) 40px;
}

.page-shell,
.page-inner {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.norm-library {
    width: 100%;
}

.library-breadcrumb {
    display: flex;
    gap: 8px;
    padding: 24px 0 4px;
    color: var(--text-soft);
    font-size: 12.5px;
}

.library-breadcrumb a {
    color: var(--green-dark);
    font-weight: 600;
    text-decoration: none;
}

.library-section {
    padding: 20px 0 64px;
}

.library-heading {
    display: flex;
    max-width: none;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 36px;
}

.library-heading-copy {
    max-width: 640px;
}

.library-eyebrow {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--green);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.library-heading h1 {
    margin: 10px 0 12px;
    color: var(--purple);
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -.01em;
    line-height: 1.15;
}

.library-heading p {
    margin: 0;
    color: var(--text-soft);
    font-size: 15.5px;
    line-height: 1.55;
}

.library-compendium {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    gap: 8px;
    border: 1.5px solid var(--purple);
    border-radius: 11px;
    padding: 10px 22px;
    color: #fff;
    background: var(--purple);
    cursor: not-allowed;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
}

.library-compendium-wrap {
    display: flex;
    max-width: 260px;
    align-items: flex-end;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 7px;
}

.library-compendium:disabled,
.library-compendium:disabled:hover,
.library-compendium:disabled:focus-visible {
    border-color: var(--purple);
    color: #fff;
    background: var(--purple);
    box-shadow: none;
    cursor: not-allowed;
    opacity: .64;
    transform: none;
}

.library-compendium-help {
    color: var(--text-soft);
    font-size: 12.5px;
    line-height: 1.4;
    text-align: right;
}

.library-toolbar {
    display: grid;
    grid-template-columns: 291.729187px 180.666672px 227.333344px 238px 112.9375px;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 18px;
    background: var(--surface);
}

.library-search {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 9px;
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--text-soft);
    background: var(--bg-alt);
}

.library-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    padding: 0;
    color: var(--text);
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    line-height: normal;
    outline: none;
}

.library-search:focus-within {
    box-shadow: 0 0 0 3px var(--green-pale);
}

.library-toolbar select {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 12px;
    color: var(--text);
    background: var(--surface);
    font-family: inherit;
    font-size: 13px;
    line-height: normal;
}

.library-toolbar select:disabled {
    color: var(--text-soft);
    background: var(--surface);
    opacity: .72;
}

.library-clear,
.library-noscript-submit {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border);
    border-radius: 9px;
    padding: 8px 14px;
    color: var(--purple);
    background: var(--surface);
    font-size: 12.5px;
    font-weight: 700;
    line-height: normal;
    text-decoration: none;
}

.library-clear {
    width: 100%;
}

.library-clear:hover,
.library-noscript-submit:hover {
    border-color: var(--purple-mid);
    color: var(--purple);
    background: var(--lilac-pale);
}

.library-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 2px 0 14px;
}

.library-chips > span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--green-soft);
    border-radius: 20px;
    padding: 5px 7px 5px 13px;
    color: var(--green-dark);
    background: var(--green-pale);
    font-size: 12.5px;
    font-weight: 600;
}

.library-chips a {
    display: grid;
    width: 18px;
    height: 18px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: var(--green-soft);
    font-size: 13px;
    line-height: 1;
    text-decoration: none;
}

.library-counter {
    margin: 6px 0 14px;
    color: var(--text-soft);
    font-size: 12.5px;
    font-weight: 600;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 18px;
}

.library-card {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}

.library-card:hover {
    border-color: var(--green-soft);
    box-shadow: var(--shadow);
}

.library-card-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.library-badge {
    display: inline-flex;
    border-radius: 20px;
    padding: 4px 10px;
    color: var(--purple-mid);
    background: var(--lilac-pale);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .04em;
    line-height: 1.2;
    text-transform: uppercase;
}

.library-card h2 {
    margin: 0;
    color: var(--purple);
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -.01em;
    line-height: 1.3;
}

.library-card > p {
    margin: 0;
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.55;
}

.library-sectors {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}

.library-sectors span {
    border-radius: 12px;
    padding: 3px 9px;
    color: var(--green-dark);
    background: var(--green-pale);
    font-size: 10.5px;
}

.library-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
}

.library-applies {
    color: var(--text-soft);
    font-size: 11.5px;
}

.library-detail {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 8px;
    border: 1.5px solid var(--purple);
    border-radius: 9px;
    padding: 8px 14px;
    color: #fff;
    background: var(--purple);
    font: inherit;
    font-size: 12.5px;
    font-weight: 700;
}

.library-detail:hover {
    border-color: var(--purple-mid);
    background: var(--purple-mid);
}

.library-empty {
    grid-column: 1 / -1;
    padding: 50px 20px;
    color: var(--text-soft);
    text-align: center;
}

.library-empty h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.library-empty p {
    margin: 0;
    font-size: 13px;
}

.norm-dialog {
    width: min(760px, 96vw);
    max-width: 96vw;
    max-height: 100vh;
    margin: 0 0 0 auto;
    border: 0;
    padding: 0;
    background: transparent;
}

.norm-dialog::backdrop {
    background: rgba(42, 47, 46, .5);
    backdrop-filter: blur(3px);
}

.norm-dialog-content {
    position: relative;
    min-height: 100vh;
    padding: 52px 44px 60px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.norm-dialog-content h2 {
    margin: 8px 46px 16px 0;
    color: var(--purple);
    font-size: 27px;
    line-height: 1.2;
}

.norm-dialog-content > p {
    margin: 0 0 16px;
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.72;
}

.norm-dialog-content .norm-dialog-meta {
    margin-top: 20px;
    border-top: 1px solid var(--border);
    padding-top: 20px;
    color: var(--text-soft);
    font-size: 13px;
}

.norm-dialog-close {
    position: absolute;
    top: 18px;
    right: 18px;
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 0;
    color: var(--text-soft);
    background: var(--surface);
}

.norm-dialog-close:hover {
    color: var(--purple);
    background: var(--bg-alt);
}

.norm-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.norm-primary-action,
.norm-secondary-action {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--purple);
    border-radius: 11px;
    padding: 10px 20px;
    color: var(--purple);
    background: var(--surface);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.norm-primary-action {
    color: #fff;
    background: var(--purple);
}

.norm-primary-action:hover {
    color: #fff;
    background: var(--purple-mid);
}

.norm-secondary-action:hover {
    color: var(--purple);
    background: var(--lilac-pale);
}

@media (max-width: 1199.98px) {
    .library-toolbar {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .library-search {
        grid-column: 1 / -1;
    }
}

@media (max-width: 820px) {
    .library-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .library-compendium-wrap {
        max-width: 100%;
        align-items: flex-start;
    }

    .library-compendium-help {
        text-align: left;
    }

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

@media (max-width: 560px) {
    .library-heading h1 {
        font-size: 26px;
    }

    .library-toolbar {
        grid-template-columns: minmax(0, 1fr);
    }

    .library-search {
        grid-column: auto;
    }

    .library-grid {
        grid-template-columns: 1fr;
    }

    .norm-dialog-content {
        padding: 48px 22px 42px;
    }
}
