/* Card grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.card-tile {
    background: #f0efe9;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
}

.card-tile:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-md);
}

.card-link {
    display: flex;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
}

.card-link * {
    text-decoration: none;
}

.card-link:hover .card-name {
    text-decoration: underline;
}

.card-img {
    width: 100%;
    height: 240px;
    flex-shrink: 0;
    background: #f0efe9;
    position: relative;
    overflow: hidden;
}

.card-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.card-img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--color-muted);
    font-size: 0.8rem;
    text-align: center;
    padding: 1rem;
}

.badge-stack {
    position: absolute;
    top: 6px;
    left: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-M { background: #ede9fe; color: #5b21b6; }
.badge-R { background: #fee2e2; color: #991b1b; }
.badge-U { background: #dbeafe; color: #1e40af; }
.badge-C { background: #f3f4f6; color: #374151; }
.badge-T { background: #f3f4f6; color: #374151; }
.badge-L { background: #73f77e; color: #4c2961; }
.badge-P { background: #8716bb; color: #f4ff81; }
.badge-foil   { background: #fef3c7; color: #92400e; }
.badge-retro  { background: #dcfce7; color: #166534; }
.badge-anime  { background: #fce7f3; color: #9d174d; }
.badge-border { background: #e0f2fe; color: #075985; }

.set-tag {
    position: absolute;
    bottom: 6px;
    right: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 3px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    letter-spacing: 0.03em;
}

.card-body {
    padding: 0.75rem 0.875rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-options {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 0 0.875rem 0.5rem;
    border-top: 1px solid var(--color-border);
}

.card-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.card-meta {
    font-size: 0.75rem;
    color: var(--color-muted);
    margin-bottom: 0.5rem;
    height:40px;
}

.listing-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
    gap: 0.5rem;
}

.listing-row + .listing-row {
    border-top: 1px solid var(--color-border);
}

.listing-left {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.listing-cond {
    font-size: 0.7rem;
    color: var(--color-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.listing-price {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
}

.listing-price.sold-out {
    color: var(--color-muted);
    text-decoration: line-through;
    font-size: 0.75rem;
}

.btn-atc {
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.12s;
    flex-shrink: 0;
}

.btn-atc:hover:not(:disabled) {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.btn-atc:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 1rem;
    color: var(--color-muted);
}

.empty-state p {
    font-size: 1rem;
    margin-top: 0.5rem;
}