:root {
    --testcat-ink: #17202a;
    --testcat-muted: #617080;
    --testcat-line: #dfe5ea;
    --testcat-soft: #f5f8fa;
    --testcat-accent: #1d5f46;
    --testcat-accent-dark: #134531;
    --testcat-card-radius: 16px;
    --testcat-shadow: 0 10px 30px rgba(20, 35, 50, 0.08);
}

* { box-sizing: border-box; }

body.testcat-library-body {
    margin: 0;
    background: #fff;
    color: var(--testcat-ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.testcat-library-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 52px 0 72px;
}

.testcat-library-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: end;
    padding-bottom: 30px;
}

.testcat-back-link {
    display: inline-block;
    margin-bottom: 22px;
    color: var(--testcat-accent);
    font-weight: 750;
    text-decoration: none;
}

.testcat-back-link:hover { text-decoration: underline; }

.testcat-eyebrow {
    margin: 0 0 8px;
    color: var(--testcat-accent);
    font-weight: 750;
    font-size: 0.78rem;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.testcat-library-header h1 {
    margin: 0;
    font-size: clamp(2.25rem, 6vw, 4rem);
    line-height: 1.02;
    letter-spacing: -0.04em;
}

.testcat-library-header p:not(.testcat-eyebrow) {
    max-width: 720px;
    margin: 15px 0 0;
    color: var(--testcat-muted);
    font-size: 1.08rem;
    line-height: 1.7;
}

.testcat-subject-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.testcat-subject-card {
    min-width: 0;
    border: 1px solid var(--testcat-line);
    border-radius: var(--testcat-card-radius);
    background: #fff;
    overflow: hidden;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.testcat-subject-card:hover {
    transform: translateY(-3px);
    border-color: #c9d5dd;
    box-shadow: var(--testcat-shadow);
}

.testcat-subject-card-link {
    display: block;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.testcat-subject-thumb {
    display: grid;
    place-items: center;
    aspect-ratio: 16 / 8.4;
    background: linear-gradient(135deg, #eef5f1, #f8fafb);
    overflow: hidden;
}

.testcat-placeholder-icon {
    width: 68px;
    height: 68px;
    color: var(--testcat-accent);
}

.testcat-subject-card-content {
    display: flex;
    flex-direction: column;
    min-height: 245px;
    padding: 22px;
}

.testcat-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    min-height: 27px;
}

.testcat-chip {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #e8f3ee;
    color: var(--testcat-accent-dark);
    font-size: 0.74rem;
    font-weight: 750;
}

.testcat-chip-muted {
    background: #eef1f4;
    color: #536170;
}

.testcat-subject-card h2 {
    margin: 17px 0 8px;
    font-size: 1.3rem;
    line-height: 1.24;
}

.testcat-subject-card p {
    margin: 0;
    color: var(--testcat-muted);
    line-height: 1.58;
}

.testcat-open-label {
    margin-top: auto;
    padding-top: 20px;
    color: var(--testcat-accent);
    font-weight: 750;
}

.testcat-empty-state {
    padding: 50px 26px;
    border: 1px dashed #cbd4dc;
    border-radius: 14px;
    background: var(--testcat-soft);
    text-align: center;
}

.testcat-empty-state h1,
.testcat-empty-state h2 { margin-top: 0; }

.testcat-empty-state p {
    color: var(--testcat-muted);
    line-height: 1.65;
}

.testcat-button {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 17px;
    border-radius: 9px;
    background: var(--testcat-accent);
    color: #fff;
    font-weight: 750;
    text-decoration: none;
}

@media (max-width: 900px) {
    .testcat-subject-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
    .testcat-library-shell { padding-top: 30px; }
    .testcat-subject-grid { grid-template-columns: 1fr; }
}

/* Subject availability and status badges. */
.testcat-subject-thumb {
    position: relative;
}

.testcat-subject-status {
    position: absolute;
    top: 13px;
    right: 13px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    max-width: calc(100% - 26px);
    min-height: 27px;
    padding: 4px 10px;
    border: 1px solid rgba(19, 69, 49, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--testcat-accent-dark);
    font-size: 0.74rem;
    font-weight: 800;
    line-height: 1.2;
    text-align: right;
    box-shadow: 0 3px 10px rgba(20, 35, 50, 0.08);
}

.testcat-subject-card.is-disabled {
    border-color: #d8dde2;
    background: #f3f4f5;
    box-shadow: none;
}

.testcat-subject-card.is-disabled:hover {
    transform: none;
    border-color: #d8dde2;
    box-shadow: none;
}

.testcat-subject-card.is-disabled .testcat-subject-card-link {
    cursor: not-allowed;
}

.testcat-subject-card.is-disabled .testcat-subject-thumb {
    background: #e6e8ea;
}

.testcat-subject-card.is-disabled .testcat-placeholder-icon,
.testcat-subject-card.is-disabled .testcat-subject-card-content {
    color: #747d85;
}

.testcat-subject-card.is-disabled .testcat-subject-card-content p,
.testcat-subject-card.is-disabled .testcat-open-label {
    color: #7b848c;
}

.testcat-subject-card.is-disabled .testcat-chip {
    background: #e1e4e7;
    color: #626b73;
}

.testcat-subject-card.is-disabled .testcat-subject-status {
    border-color: #d1d5d9;
    background: rgba(247, 248, 249, 0.96);
    color: #606970;
}

.testcat-unavailable-state {
    max-width: 700px;
    margin: 8vh auto 0;
}

.testcat-subject-status-inline {
    position: static;
    margin-bottom: 16px;
}

.testcat-button + .testcat-button {
    margin-left: 8px;
}

.testcat-button-secondary {
    background: #e7edf3;
    color: #263746;
}

@media (max-width: 520px) {
    .testcat-button + .testcat-button {
        margin: 10px 0 0;
    }
}
