.communities {
    align-self: stretch;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: var(--theme-space-md, 16px);
}

.communities-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--theme-space-md, 16px);
}

.communities-item {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--theme-border, #d0d0d0);
    border-radius: 12px;
    overflow: hidden;
    background: var(--theme-bg-secondary, #f5f5f5);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.communities-item:hover {
    background: var(--theme-bg-tertiary, #ececec);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.communities-image {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: #ffffff;
    display: block;
}

.communities-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding: var(--theme-space-sm, 12px);
}

.communities-name-row {
    display: flex;
    align-items: center;
    gap: var(--theme-space-xs, 8px);
    min-width: 0;
}

.communities-name {
    font-weight: 600;
    color: var(--theme-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.communities-membership-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--theme-text-secondary);
}

.communities-membership-badge--open {
    color: var(--theme-success, #16a34a);
}

.communities-membership-badge--moderated {
    color: var(--theme-warning, #d97706);
}

.communities-membership-badge--closed {
    color: var(--theme-danger, #dc2626);
}

.communities-description {
    color: var(--theme-text-secondary);
    font-size: 0.9em;
}

.communities-filters {
    display: flex;
    gap: var(--theme-space-xs, 8px);
    margin-bottom: var(--theme-space-md, 16px);
}

.communities-filter-tab {
    appearance: none;
    border: 1px solid var(--theme-border, #d0d0d0);
    background: transparent;
    color: var(--theme-text-secondary);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.communities-filter-tab:hover {
    background: var(--theme-bg-secondary, #f0f0f0);
    color: var(--theme-text-primary);
}

.communities-filter-tab--active {
    background: var(--theme-accent, #2563eb);
    border-color: var(--theme-accent, #2563eb);
    color: var(--theme-accent-text, #ffffff);
    font-weight: 600;
}

.communities-filter-tab--active:hover {
    background: var(--theme-accent, #2563eb);
    color: var(--theme-accent-text, #ffffff);
}

.communities-member-badge {
    position: absolute;
    top: var(--theme-space-xs, 8px);
    right: var(--theme-space-xs, 8px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 999px;
    background: var(--theme-bg-primary, #ffffff);
    color: var(--theme-text-secondary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.communities-empty {
    text-align: center;
    padding: var(--theme-space-lg, 32px) var(--theme-space-md, 16px);
    color: var(--theme-text-secondary);
    font-size: 0.95em;
}
