.tmf-card-browser {
    width: min(100%, 1240px);
    margin: 0 auto;
    padding: 24px 0 44px;
}

/* The legacy global `header` selector in common.css sizes the site masthead.
   Card browser headers are semantic section headers, not mastheads. */
.tmf-card-browser__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    width: auto;
    height: auto;
    min-height: 0;
    gap: 20px;
    margin-bottom: 22px;
    background: transparent;
}

.tmf-card-browser__head h1 {
    margin: 0;
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    line-height: 1.08;
}

.tmf-card-browser__head p {
    max-width: 760px;
    margin: 8px 0 0;
    color: #b8b8b8;
    line-height: 1.55;
}

.tmf-card-search {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid #3a3a3a;
    border-radius: 14px;
    background: #1d1d1d;
}

.tmf-card-search__query {
    position: relative;
}

.tmf-card-search label,
.tmf-card-filter label {
    display: grid;
    gap: 6px;
    color: #d7d7d7;
    font-size: .9rem;
    font-weight: 600;
}

.tmf-card-search input,
.tmf-card-search select {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #4a4a4a;
    border-radius: 8px;
    background: #262626;
    color: #f4f4f4;
    font: inherit;
}

.tmf-card-search input:focus,
.tmf-card-search select:focus,
.tmf-card-page-button:focus-visible,
.tmf-card-tab:focus-visible,
.tmf-card-tile__open:focus-visible,
.tmf-card-dialog button:focus-visible,
.tmf-card-search button:focus-visible {
    outline: 3px solid rgba(240, 84, 84, .55);
    outline-offset: 2px;
}

.tmf-card-search__filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.tmf-card-search__actions {
    display: flex;
    justify-content: flex-end;
}

.tmf-card-primary-button,
.tmf-card-page-button,
.tmf-card-tab,
.tmf-card-dialog__close,
.tmf-card-dialog__face {
    border: 1px solid #4a4a4a;
    border-radius: 8px;
    background: #292929;
    color: #f5f5f5;
    font: inherit;
    cursor: pointer;
}

.tmf-card-primary-button {
    min-height: 44px;
    padding: 10px 22px;
    border-color: #f05454;
    background: #f05454;
    color: #fff;
    font-weight: 700;
}

.tmf-card-primary-button:hover {
    background: #d94444;
}

.tmf-card-suggestions {
    position: absolute;
    z-index: 40;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 300px;
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    list-style: none;
    border: 1px solid #484848;
    border-radius: 10px;
    background: #202020;
    box-shadow: 0 14px 30px rgba(0, 0, 0, .38);
}

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

.tmf-card-suggestions button {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #eee;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.tmf-card-suggestions button:hover,
.tmf-card-suggestions button:focus-visible {
    background: #363636;
}

.tmf-card-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 20px;
}

.tmf-card-tab {
    min-height: 42px;
    padding: 9px 15px;
}

.tmf-card-tab[aria-pressed="true"] {
    border-color: #f05454;
    background: #f05454;
    color: #fff;
}

.tmf-card-status {
    min-height: 24px;
    margin: 10px 0 14px;
    color: #c7c7c7;
    line-height: 1.5;
}

.tmf-card-status.is-error {
    color: #ff9a9a;
}

.tmf-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(158px, 210px));
    justify-content: center;
    gap: 20px;
    align-items: start;
}

.tmf-card-tile {
    min-width: 0;
    overflow: hidden;
    border: 1px solid #3a3a3a;
    border-radius: 13px;
    background: #202020;
    box-shadow: 0 8px 18px rgba(0, 0, 0, .18);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.tmf-card-tile:hover {
    transform: translateY(-3px);
    border-color: #5a5a5a;
    box-shadow: 0 12px 24px rgba(0, 0, 0, .26);
}

.tmf-card-tile__open {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.tmf-card-tile__media {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 210px;
    padding: 10px 10px 0;
    background: radial-gradient(circle at 50% 30%, #333, #181818 68%);
}

.tmf-card-tile__media img {
    display: block;
    width: 100%;
    aspect-ratio: 488 / 680;
    object-fit: contain;
    border-radius: 8px;
}

.tmf-card-tile__face-badge {
    position: absolute;
    right: 16px;
    bottom: 8px;
    padding: 4px 7px;
    border-radius: 999px;
    background: rgba(12, 12, 12, .86);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
}

.tmf-card-tile__body {
    padding: 11px 12px 13px;
}

.tmf-card-tile__title {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: #f5f5f5;
    font-size: .95rem;
    font-weight: 700;
    line-height: 1.3;
}

.tmf-card-tile__meta {
    margin: 6px 0 0;
    color: #a8a8a8;
    font-size: .78rem;
    line-height: 1.35;
}

.tmf-card-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 24px 0 0;
}

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

.tmf-card-page-button {
    min-width: 92px;
    min-height: 40px;
    padding: 8px 14px;
}

.tmf-card-page-button:disabled {
    opacity: .42;
    cursor: not-allowed;
}

.tmf-card-page-label {
    min-width: 90px;
    color: #c8c8c8;
    text-align: center;
    font-size: .9rem;
}

.tmf-card-dialog {
    width: min(92vw, 760px);
    max-width: 760px;
    max-height: 92vh;
    padding: 0;
    overflow: hidden;
    border: 1px solid #4b4b4b;
    border-radius: 16px;
    background: #1b1b1b;
    color: #f5f5f5;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
}

.tmf-card-dialog::backdrop {
    background: rgba(0, 0, 0, .82);
    backdrop-filter: blur(2px);
}

.tmf-card-dialog__inner {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(220px, .72fr);
    max-height: 92vh;
    overflow: auto;
}

.tmf-card-dialog__media {
    display: grid;
    place-items: center;
    min-height: 420px;
    padding: 22px;
    background: radial-gradient(circle at 50% 35%, #363636, #151515 70%);
}

.tmf-card-dialog__media img {
    display: block;
    width: 100%;
    max-width: 430px;
    max-height: 78vh;
    object-fit: contain;
    border-radius: 12px;
}

.tmf-card-dialog__copy {
    position: relative;
    padding: 54px 22px 22px;
}

.tmf-card-dialog__copy h2 {
    margin: 0 0 8px;
    font-size: 1.35rem;
    line-height: 1.25;
}

.tmf-card-dialog__meta {
    margin: 0;
    color: #b5b5b5;
    line-height: 1.5;
}

.tmf-card-dialog__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 1.35rem;
    line-height: 1;
}

.tmf-card-dialog__faces {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

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

.tmf-card-dialog__face {
    padding: 7px 10px;
    font-size: .82rem;
}

.tmf-card-dialog__face[aria-pressed="true"] {
    border-color: #f05454;
    background: #f05454;
    color: #fff;
}

.tmf-card-dialog__external {
    display: inline-flex;
    margin-top: 20px;
    color: #ff8a8a;
    font-weight: 700;
    text-decoration: none;
}

.tmf-card-dialog__external:hover {
    text-decoration: underline;
}

@media (max-width: 760px) {
    .tmf-card-browser {
        padding-top: 12px;
    }

    .tmf-card-browser__head {
        display: block;
    }

    .tmf-card-search__filters {
        grid-template-columns: 1fr;
    }

    .tmf-card-search__actions {
        justify-content: stretch;
    }

    .tmf-card-primary-button {
        width: 100%;
    }

    .tmf-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .tmf-card-tile__media {
        min-height: 0;
        padding: 8px 8px 0;
    }

    .tmf-card-dialog__inner {
        grid-template-columns: 1fr;
    }

    .tmf-card-dialog__media {
        min-height: 0;
        padding: 16px 16px 0;
    }

    .tmf-card-dialog__media img {
        max-height: 58vh;
    }

    .tmf-card-dialog__copy {
        padding: 48px 18px 18px;
    }
}

@media (max-width: 390px) {
    .tmf-card-grid {
        grid-template-columns: 1fr;
    }

    .tmf-card-tile {
        max-width: 230px;
        margin-inline: auto;
    }
}
