.card {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    background-color: var(--color-surface);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius);
}

.card--compact {
    gap: var(--spacing-md);
}

/* What the card is: its title, a line on it, and its actions at the right; a divider sets it off from the content. */
.card__header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: var(--spacing-md);
    row-gap: var(--spacing-xs);
    padding-bottom: var(--spacing-lg);
    border-bottom: var(--border-width) solid var(--color-divider-subtle);
}

/* A card that is only its header (a notice) needs no divider. */
.card__header:last-child {
    padding-bottom: 0;
    border-bottom: none;
}


.card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    grid-column: 2;
    grid-row: 1 / span 2;
}

/* Without a subtitle the actions share the title's one row, so the two line up on their centres. Spanning an empty
   second row would push the actions below the title. */
@media (min-width: 48rem) {
    .card__header:not(:has(.card__subtitle)) .card__actions {
        grid-row: 1;
    }
}

/* On a phone the actions go under the title. */
@media (max-width: 47.99rem) {
    .card__header {
        grid-template-columns: minmax(0, 1fr);
    }

    .card__actions {
        grid-column: 1;
        grid-row: auto;
    }
}

.card__title {
    grid-column: 1;
    margin: 0;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-medium);
    letter-spacing: -0.01em;
}

/* The figure a page is about, such as a balance. */
.card__title--large {
    font-size: var(--font-size-lg);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

/* A heading within a card, for its parts (Models, Sandboxes, Tools). */
.card__section-title {
    margin: 0;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
}

.card__subtitle {
    grid-column: 1;
    max-width: 40rem;
    margin: 0;
    color: var(--color-on-surface-muted);
}

.card__footer {
    margin: 0;
    color: var(--color-on-surface-muted);
    font-size: var(--font-size-sm);
}

/* A distinct subsection within the same card. */
.card__section {
    padding-top: var(--spacing-lg);
    border-top: var(--border-width) solid var(--color-divider-subtle);
}
