.psycheopedia-library {
    padding-bottom: 3rem;
}

.psycheopedia-topic__lead {
    font-size: 1.125rem;
    line-height: 1.55;
    color: #1f2937;
    margin: 0 auto 1.5rem;
    max-width: 48rem;
    text-align: center;
}

.psycheopedia-library__lead {
    max-width: 720px;
    margin: 0 auto 2.5rem;
    text-align: center;
    color: #6c757d;
    font-size: 1.05rem;
    line-height: 1.6;
}

.psycheopedia-search {
    max-width: 520px;
    margin: 0 auto 2rem;
}

.psycheopedia-search__field {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.psycheopedia-search__field:focus-within {
    border-color: rgba(14, 130, 253, 0.55);
    box-shadow: 0 0 0 3px rgba(14, 130, 253, 0.12);
}

.psycheopedia-search__field .feather-search {
    flex-shrink: 0;
    font-size: 1.15rem;
    color: #6c757d;
}

.psycheopedia-search__field .form-control {
    border: 0;
    box-shadow: none;
    padding: 0.35rem 0;
    font-size: 1rem;
    background: transparent;
}

.psycheopedia-search__field .form-control:focus {
    box-shadow: none;
}

.psycheopedia-search__empty {
    margin: 0.75rem 0 0;
    text-align: center;
    color: #6c757d;
    font-size: 0.95rem;
}

.psycheopedia-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
    align-items: stretch;
    padding: 0.25rem 0 1rem;
}

.psycheopedia-tile {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
    max-height: 28rem;
    margin: 0;
    transition: transform 0.35s ease, opacity 0.35s ease, max-height 0.35s ease,
        margin 0.35s ease, padding 0.35s ease, visibility 0.35s ease,
        box-shadow 0.35s ease, outline-color 0.35s ease, border-width 0.35s ease;
    transform: scale(1);
    opacity: 1;
    position: relative;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.psycheopedia-tile:focus-visible {
    outline: 2px solid rgba(15, 23, 42, 0.35);
    outline-offset: 2px;
}

article.psycheopedia-tile {
    cursor: default;
}

.psycheopedia-tile.is-leaving,
.psycheopedia-tile.is-entering {
    opacity: 0;
    transform: scale(0.88);
    max-height: 0;
    margin: 0;
    overflow: hidden;
    pointer-events: none;
    visibility: hidden;
}

.psycheopedia-tile.is-filtered-out {
    display: none;
}

.psycheopedia-tile.is-flipping {
    z-index: 1;
    will-change: transform;
}

.psycheopedia-tile__media {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    background: #f4f6f9;
}

.psycheopedia-tile__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.psycheopedia-tile__title {
    margin: 0;
    padding: 1rem 1rem 1.15rem;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    color: #1f2937;
    transition: padding 0.35s ease;
}

/* Hover: siblings shrink when any visible tile is hovered (:has) */
.psycheopedia-tiles:has(.psycheopedia-tile:hover:not(.is-filtered-out):not(.is-leaving):not(.is-entering):not(.is-flipping)) .psycheopedia-tile:not(:hover):not(.is-filtered-out):not(.is-leaving):not(.is-entering):not(.is-flipping),
.psycheopedia-tiles.is-hovering .psycheopedia-tile:not(.is-hovered):not(.is-filtered-out):not(.is-leaving):not(.is-entering):not(.is-flipping) {
    transform: scale(0.92);
    opacity: 0.72;
}

.psycheopedia-tile:hover:not(.is-filtered-out):not(.is-leaving):not(.is-entering):not(.is-flipping),
.psycheopedia-tile.is-hovered:not(.is-flipping) {
    transform: scale(1.06);
    opacity: 1;
    z-index: 2;
    box-shadow: 0 12px 40px rgba(14, 130, 253, 0.28);
    outline: 2px solid rgba(14, 130, 253, 0.45);
    outline-offset: 0;
}

.psycheopedia-tile:hover:not(.is-filtered-out):not(.is-leaving):not(.is-entering):not(.is-flipping) .psycheopedia-tile__media img,
.psycheopedia-tile.is-hovered:not(.is-flipping) .psycheopedia-tile__media img {
    transform: scale(1.03);
}

@media (prefers-reduced-motion: reduce) {
    .psycheopedia-tile,
    .psycheopedia-tile__title,
    .psycheopedia-tile__media img {
        transition-duration: 0.01s;
    }

    .psycheopedia-tile.is-leaving,
    .psycheopedia-tile.is-entering {
        transform: none;
    }
}

@media (max-width: 575.98px) {
    .psycheopedia-tiles {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }

    .psycheopedia-tile__title {
        font-size: 0.95rem;
        padding: 0.75rem 0.65rem 0.9rem;
    }
}

.psycheopedia-detail {
    align-items: stretch;
}

.psycheopedia-paragraph-nav {
    align-self: stretch;
    margin-bottom: 1.5rem;
}

@media (min-width: 992px) {
    .psycheopedia-paragraph-nav {
        margin-bottom: 0;
    }

    .psycheopedia-paragraph-nav__inner {
        position: sticky;
        top: 100px;
        z-index: 100;
    }
}

.psycheopedia-paragraph-nav__inner {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
    padding: 1.25rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.psycheopedia-paragraph-nav__title {
    margin: 0 0 1rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1f2937;
}

.psycheopedia-paragraph-nav__search {
    max-width: none;
    margin: 0 0 1rem;
}

.psycheopedia-paragraph-nav__list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.psycheopedia-paragraph-nav__link {
    display: block;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #374151;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.psycheopedia-paragraph-nav__link:hover {
    background: rgba(14, 130, 253, 0.06);
    color: #0e82fd;
}

.psycheopedia-paragraph-nav__link.is-active {
    background: rgba(14, 130, 253, 0.1);
    color: #0e82fd;
    border-left-color: #0e82fd;
    font-weight: 600;
}

.psycheopedia-paragraph-nav__link.is-filtered-out {
    display: none;
}

.psycheopedia-paragraph-nav__empty {
    margin-top: 0.5rem;
    text-align: left;
}

.psycheopedia-detail__content .support-guide-description[id] {
    scroll-margin-top: 100px;
}

@media (max-width: 991.98px) {
    .psycheopedia-paragraph-nav__inner {
        position: static;
        max-height: none;
    }
}
