.spell-library {
    display: grid;
    gap: 1.25rem;
    position: relative;
    isolation: isolate;
    padding: 1.25rem;
    border-radius: 24px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: linear-gradient(165deg, rgba(42, 45, 103, 0.84), rgba(27, 30, 84, 0.88));
}

.spell-library::before {
    content: '';
    position: absolute;
    inset: -1.25rem;
    z-index: -1;
    border-radius: 24px;
    background:
        radial-gradient(circle at 8% 5%, rgba(244, 114, 182, 0.2), transparent 32%),
        radial-gradient(circle at 86% 14%, rgba(59, 130, 246, 0.2), transparent 36%),
        radial-gradient(circle at 52% 82%, rgba(168, 85, 247, 0.16), transparent 30%);
    pointer-events: none;
}

.spell-library__header p {
    margin-top: 0.5rem;
    color: var(--text-muted);
}

.spell-library__view-link {
    display: inline-flex;
    margin-top: 0.75rem;
    color: #f9a8d4;
    font-weight: 600;
    text-decoration: none;
}

.spell-library__view-link:hover,
.spell-library__view-link:focus-visible {
    text-decoration: underline;
}

.spell-library__filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem;
    padding: 1rem;
    border-radius: 16px;
    border: 1px solid rgba(236, 72, 153, 0.22);
    background: linear-gradient(145deg, rgba(14, 20, 40, 0.88), rgba(7, 11, 28, 0.94));
    box-shadow: 0 14px 36px rgba(12, 18, 40, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.spell-library__filter {
    display: grid;
    gap: 0.35rem;
}

.spell-library__filter label {
    font-size: 0.9rem;
    font-weight: 600;
}

.spell-library__filter input,
.spell-library__filter select {
    background: rgba(10, 15, 28, 0.72);
    border: 1px solid rgba(96, 165, 250, 0.35);
    border-radius: 10px;
    color: var(--text-main);
    min-height: 42px;
    padding: 0.55rem 0.75rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.spell-library__filter input:focus,
.spell-library__filter select:focus {
    outline: none;
    border-color: rgba(236, 72, 153, 0.9);
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.22);
    transform: translateY(-1px);
}

.spell-library__count {
    margin: 0;
    color: var(--text-muted);
}

.spell-library__empty {
    margin: 0;
    color: var(--text-muted);
    font-style: italic;
}

.spell-library__grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.spell-card {
    position: relative;
    background:
        radial-gradient(circle at 100% 0%, rgba(59, 130, 246, 0.14), transparent 48%),
        radial-gradient(circle at 0% 100%, rgba(236, 72, 153, 0.13), transparent 42%),
        linear-gradient(180deg, rgba(20, 28, 48, 0.9), rgba(10, 15, 28, 0.95));
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 14px;
    transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.spell-card__content-link {
    display: block;
    color: inherit;
    text-decoration: none;
    padding: 1rem;
}

.spell-card[hidden] {
    display: none;
}

.spell-card:hover,
.spell-card:focus-within {
    border-color: rgba(236, 72, 153, 0.55);
    text-decoration: none;
    box-shadow:
        0 16px 28px rgba(37, 99, 235, 0.22),
        0 0 0 1px rgba(236, 72, 153, 0.25),
        0 0 18px rgba(236, 72, 153, 0.2);
    transform: translateY(-3px) scale(1.01);
}

.spell-card h2 {
    font-size: 1rem;
    margin: 0 0 0.25rem;
}

.spell-card__meta {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 0.8rem;
}

.spell-card__facts {
    list-style: none;
    margin: 0 0 0.8rem;
    padding: 0;
    display: grid;
    gap: 0.25rem;
    font-size: 0.9rem;
}

.spell-card__favorite {
    position: absolute;
    right: 0.6rem;
    top: 0.55rem;
    z-index: 2;
    background: rgba(12, 18, 40, 0.85);
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.5);
    border-radius: 999px;
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
}

.spell-card__favorite:hover,
.spell-card__favorite:focus-visible {
    border-color: rgba(250, 204, 21, 0.95);
    color: #fde047;
}

.spell-card__favorite.is-active {
    color: #fde047;
    border-color: rgba(250, 204, 21, 0.95);
    box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.22);
}

.spell-card__description {
    margin: 0;
    line-height: 1.45;
    white-space: pre-line;
}

.spell-card--detail {
    max-width: 860px;
    padding: 1.2rem 1.35rem;
}

.spell-card--detail h1 {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
}

.spell-detail__back-link {
    width: fit-content;
    text-decoration: none;
    color: var(--text-muted);
}

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

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

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

@media (max-width: 820px) {
    .spell-library__filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .spell-library {
        padding: 1rem;
    }

    .spell-library__grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .spell-library__filters {
        grid-template-columns: 1fr;
    }

    .spell-card--detail {
        padding: 0.95rem 1rem;
    }
}
