.filter-card {
    border-color: rgba(167,139,250,0.3);
}

.library-controls {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) repeat(2, minmax(150px, 0.7fr));
    gap: 14px;
    margin-top: 14px;
}

.library-controls label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 750;
}

.library-controls input,
.library-controls select {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    color: var(--text);
    background: #25233a;
    border: 1px solid var(--border);
    border-radius: 11px;
    font: inherit;
}

.library-controls input:focus,
.library-controls select:focus {
    outline: 3px solid rgba(167,139,250,0.5);
    outline-offset: 2px;
}

.result-count {
    margin: 14px 0 0;
    color: #c4b5fd;
    font-size: 0.9rem;
    font-weight: 800;
}

.phrase-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.phrase-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin: 0;
    border-color: rgba(96,165,250,0.22);
}

.phrase-context {
    margin: 0 0 7px;
    color: #93c5fd;
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.phrase-card h2 {
    margin: 0 0 15px;
    font-size: clamp(1.15rem, 3vw, 1.42rem);
}

.phrase-lines {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.phrase-line {
    display: grid;
    gap: 4px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.phrase-line:first-child {
    padding-top: 0;
    border-top: 0;
}

.phrase-label {
    color: #a7f3d0;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.phrase-text {
    color: var(--text);
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.phrase-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: auto;
}

.phrase-actions button,
.phrase-actions a {
    min-height: 44px;
    padding: 10px 13px;
    border-radius: 10px;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 850;
    cursor: pointer;
}

.phrase-copy {
    color: #fff;
    background: #2563eb;
    border: 0;
}

.phrase-edit {
    display: inline-flex;
    align-items: center;
    color: #ddd6fe;
    background: rgba(124,58,237,0.14);
    border: 1px solid rgba(167,139,250,0.3);
    text-decoration: none;
}

.phrase-copy:focus-visible,
.phrase-edit:focus-visible {
    outline: 3px solid #c4b5fd;
    outline-offset: 2px;
}

.copy-status {
    min-height: 21px;
    margin: 9px 0 0;
    color: #86efac;
    font-size: 0.82rem;
    font-weight: 800;
}

.no-results {
    text-align: center;
    color: var(--muted);
}

.library-guide .action-row {
    margin-top: 18px;
}

[hidden] {
    display: none !important;
}

@media (max-width: 720px) {
    .library-controls {
        grid-template-columns: 1fr 1fr;
    }

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

@media (max-width: 560px) {
    .library-controls,
    .phrase-grid {
        grid-template-columns: 1fr;
    }

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

    .phrase-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .phrase-actions a,
    .phrase-actions button {
        justify-content: center;
        text-align: center;
    }
}

@media print {
    .topbar,
    .filter-card,
    .ad-card,
    .library-guide,
    .safety,
    .phrase-actions,
    footer {
        display: none !important;
    }

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

    .phrase-card {
        break-inside: avoid;
        border: 1px solid #bbb;
        box-shadow: none;
    }
}
